/* ============================================================
   VICIDIAL Instant Messaging  -  Floating chat widget
   Design : simple, plat et propre
   ============================================================ */

:root {
  --vc-accent:      #2563eb;
  --vc-accent-dark: #1e50c8;
  --vc-text:        #1f2937;
  --vc-text-soft:   #6b7280;
  --vc-border:      #e5e7eb;
  --vc-bg:          #ffffff;
  --vc-bg-soft:     #f6f7f9;
  --vc-online:      #22c55e;
  --vc-busy:        #f59e0b;
  --vc-offline:     #9ca3af;
  --vc-danger:      #ef4444;
}

#vc-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--vc-text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Floating launcher button ---------- */
#vc-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--vc-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,.30);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, box-shadow .15s ease;
}
#vc-launcher:hover  { background: var(--vc-accent-dark); box-shadow: 0 6px 18px rgba(37,99,235,.38); }
#vc-launcher:active { transform: translateY(1px); }
#vc-launcher svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2; }

#vc-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--vc-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
#vc-badge.vc-hidden { display: none; }

/* ---------- Chat panel ---------- */
#vc-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 350px;
  height: 510px;
  background: var(--vc-bg);
  border: 1px solid var(--vc-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(17,24,39,.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: vc-pop .15s ease;
}
#vc-panel.vc-hidden { display: none; }
@keyframes vc-pop {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ---------- Header ---------- */
.vc-header {
  background: var(--vc-accent);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.vc-header-title {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.vc-header-title .vc-back {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.vc-header-title .vc-back.vc-show { display: flex; }
.vc-header-title .vc-back:hover { background: rgba(255,255,255,.28); }
.vc-header-title .vc-peer {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vc-header-actions {
  display: flex; gap: 4px;
}
.vc-header-actions button {
  background: transparent;
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.vc-header-actions button:hover { background: rgba(255,255,255,.18); }
.vc-header-actions svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.vc-presence-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--vc-online);
  flex-shrink: 0;
}
.vc-presence-dot.vc-off { background: rgba(255,255,255,.5); }

/* ---------- Body ---------- */
.vc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--vc-bg-soft);
}

/* User list wrapper (admin) - must fill .vc-body so the inner list can scroll */
.vc-userlist-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* User list (admin) */
.vc-userlist {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.vc-userlist::-webkit-scrollbar       { width: 8px; }
.vc-userlist::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.vc-userlist::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
.vc-userlist .vc-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--vc-text-soft);
  font-size: 12px;
}
.vc-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--vc-border);
  transition: background .12s ease;
}
.vc-user:hover { background: #eef2ff; }
.vc-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #e5e9f2;
  color: #4b5563;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  position: relative;
  flex-shrink: 0;
}
.vc-user-avatar .vc-status-dot {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--vc-bg-soft);
  background: var(--vc-offline);
}
.vc-user-avatar .vc-status-dot.vc-on  { background: var(--vc-online); }
.vc-user-avatar .vc-status-dot.vc-call { background: var(--vc-busy); }
.vc-user-info {
  flex: 1;
  min-width: 0;
}
.vc-user-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--vc-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vc-user-meta {
  font-size: 11px;
  color: var(--vc-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vc-user-badge {
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--vc-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.vc-search {
  padding: 8px 10px;
  background: var(--vc-bg);
  border-bottom: 1px solid var(--vc-border);
  flex-shrink: 0;
}
.vc-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--vc-border);
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  transition: border-color .12s ease;
  box-sizing: border-box;
}
.vc-search input:focus { border-color: var(--vc-accent); }

/* Conversation pane */
.vc-conv {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vc-msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.vc-msg.vc-mine {
  align-self: flex-end;
  background: var(--vc-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.vc-msg.vc-theirs {
  align-self: flex-start;
  background: var(--vc-bg);
  color: var(--vc-text);
  border: 1px solid var(--vc-border);
  border-bottom-left-radius: 4px;
}
.vc-msg-meta {
  font-size: 10px;
  opacity: .65;
  margin-top: 3px;
  text-align: right;
}
.vc-msg.vc-theirs .vc-msg-meta { text-align: left; color: var(--vc-text-soft); opacity: 1; }

.vc-day-divider {
  align-self: center;
  font-size: 11px;
  color: var(--vc-text-soft);
  margin: 8px 0 4px;
  padding: 2px 10px;
  background: var(--vc-bg);
  border-radius: 10px;
  border: 1px solid var(--vc-border);
}

.vc-typing {
  align-self: flex-start;
  font-size: 11px;
  color: var(--vc-text-soft);
  font-style: italic;
  padding: 4px 10px;
}
.vc-typing.vc-hidden { display: none; }

.vc-conv-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--vc-text-soft);
  text-align: center;
  font-size: 12px;
  padding: 20px;
  gap: 8px;
}
.vc-conv-empty svg { width: 44px; height: 44px; stroke: currentColor; fill: none; stroke-width: 1.5; opacity: .4; }

/* ---------- Composer ---------- */
.vc-composer {
  border-top: 1px solid var(--vc-border);
  background: var(--vc-bg);
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.vc-composer textarea {
  flex: 1;
  border: 1px solid var(--vc-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 36px;
  line-height: 1.35;
  box-sizing: border-box;
  transition: border-color .12s ease;
}
.vc-composer textarea:focus { border-color: var(--vc-accent); }
.vc-composer textarea[disabled] { background: var(--vc-bg-soft); }
.vc-composer .vc-send {
  background: var(--vc-accent);
  color: #fff;
  border: none;
  width: 38px; height: 38px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease;
  flex-shrink: 0;
}
.vc-composer .vc-send:hover  { background: var(--vc-accent-dark); }
.vc-composer .vc-send[disabled] { opacity: .4; cursor: not-allowed; }
.vc-composer .vc-send svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---------- Toast for new message ---------- */
.vc-toast {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 999998;
  background: var(--vc-text);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.20);
  font-size: 13px;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  animation: vc-toast-in .2s ease;
}
@keyframes vc-toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.vc-toast strong { color: #93c5fd; }
.vc-toast .vc-toast-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ---------- Mobile / narrow ---------- */
@media (max-width: 480px) {
  #vc-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    right: -6px;
  }
}

/* Hide everything when collapsed */
.vc-hidden { display: none !important; }
