/* =============================================================================
   Vocal Center — Live monitoring
   Design system aligné sur ch.vocal.my (Plus Jakarta Sans, indigo, ronds)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Variables & Theme
   ----------------------------------------------------------------------------- */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  --bg-page: #f4f5fb;
  --bg-white: #ffffff;
  --text-main: #1e1b4b;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --success: #16a34a;
  --warning: #f59e0b;
  --danger:  #dc2626;
  --live:    #ef4444;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --shadow-hover: 0 10px 30px -8px rgba(99, 102, 241, 0.25);
  --shadow-primary-glow: 0 4px 14px rgba(99, 102, 241, 0.45);
  --shadow-live-glow: 0 4px 18px rgba(239, 68, 68, 0.35);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 1.5rem;
  --header-height: 68px;
}

/* -----------------------------------------------------------------------------
   2. Reset & Base
   ----------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  background: var(--bg-page);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

button, input, select, textarea { font-family: inherit; }

a { color: var(--primary); text-decoration: none; }

/* Loader initial */
.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-page);
}
.app-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* -----------------------------------------------------------------------------
   3. Layout principal
   ----------------------------------------------------------------------------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 2rem;
  min-height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-header h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-primary-glow);
}

/* Pulsation "live" rouge dans le header */
.live-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--live);
  flex-shrink: 0;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  50%      { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* User info à droite */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.user-info .user-email {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: #f1f5f9;
  border-radius: 999px;
  font-weight: 600;
  color: var(--text-main);
}

.monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(118, 75, 162, 0.1));
  color: var(--primary-dark);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8125rem;
}
.monitor-badge .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse-dot 1.4s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.85); }
}

/* -----------------------------------------------------------------------------
   4. Boutons (pill, type Taxibook)
   ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.005em;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn:hover:not(:disabled) {
  border-color: var(--primary-light);
  color: var(--primary-dark);
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover:not(:disabled) {
  color: #fff;
  box-shadow: var(--shadow-primary-glow);
}

.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  gap: 0.4rem;
}

/* -----------------------------------------------------------------------------
   5. Dashboard container
   ----------------------------------------------------------------------------- */
.dashboard {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.75rem 0 1rem;
}

.section-title h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.section-title .auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: #ecfdf5;
  color: #166534;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
}
.section-title .auto-refresh .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #16a34a;
  animation: pulse-dot 1.4s infinite;
}

/* -----------------------------------------------------------------------------
   6. Stats grid (cartes avec gros "ronds" colorés en haut)
   ----------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1.5rem;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(99, 102, 241, 0.25);
}

.stat-card:hover .stat-icon { transform: scale(1.05); }

/* Le rond coloré */
.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.375rem;
  transition: transform 0.25s ease;
}

.stat-icon.live    { background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.06)); color: #dc2626; }
.stat-icon.warning { background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.06)); color: #d97706; }
.stat-icon.purple  { background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(118, 75, 162, 0.08)); color: var(--primary-dark); }
.stat-icon.blue    { background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.06)); color: #2563eb; }
.stat-icon.green   { background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.06)); color: var(--success); }

.stat-card .stat-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}

.stat-card .stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.stat-card .stat-value.live-color { color: var(--live); }

/* -----------------------------------------------------------------------------
   7. Grille des appels actifs
   ----------------------------------------------------------------------------- */
.calls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.call-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 1.5rem;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
}

.call-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.call-card.monitoring {
  border-color: var(--primary);
  box-shadow: var(--shadow-primary-glow);
}

/* Barre live en haut de la carte */
.call-card.live::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--live), transparent);
  animation: shimmer 2.2s infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.call-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.call-from-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

/* "Rond" avatar pour l'appelant */
.call-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.call-from-info {
  min-width: 0;
}

.call-from {
  font-size: 1.0625rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  color: var(--text-main);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-line {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pill de statut d'appel */
.call-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.call-status .dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
}
.call-status.in-progress { background: #dcfce7; color: #166534; }
.call-status.in-progress .dot { background: #16a34a; }
.call-status.ringing     { background: #fef3c7; color: #b45309; }
.call-status.ringing     .dot { background: #f59e0b; }
.call-status.hold        { background: #f1f5f9; color: #475569; }
.call-status.hold        .dot { background: #94a3b8; }

/* Métadonnées (durée, direction, bot) */
.call-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.call-meta .meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: #f1f5f9;
  color: var(--text-main);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.call-meta .meta-pill.direction-in  { background: #dcfce7; color: #166534; }
.call-meta .meta-pill.direction-out { background: #dbeafe; color: #1e40af; }
.call-meta .meta-pill.bot           { background: #ede9fe; color: #6d28d9; }

.call-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

/* Transcript */
.transcript-box {
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted);
}
.transcript-box .me   { color: var(--primary-dark); font-weight: 600; }
.transcript-box .them { color: var(--success); font-weight: 600; }

/* -----------------------------------------------------------------------------
   8. Empty state
   ----------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-white);
  border: 1px dashed var(--border);
  border-radius: var(--radius-2xl);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 1.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(118, 75, 162, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 2rem;
}

.empty-state h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9375rem;
  font-weight: 500;
  max-width: 28rem;
}

/* -----------------------------------------------------------------------------
   8b. Module gate (feature non activée)
   ----------------------------------------------------------------------------- */
.module-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
  max-width: 38rem;
  margin: 2rem auto;
}

.module-gate-icon {
  width: 96px;
  height: 96px;
  margin-bottom: 1.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(118, 75, 162, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.module-gate h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.module-gate p {
  font-size: 0.9375rem;
  font-weight: 500;
  max-width: 30rem;
  margin: 0 0 0.5rem;
  line-height: 1.55;
}

.module-gate .module-gate-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.module-gate-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* -----------------------------------------------------------------------------
   9. Login card
   ----------------------------------------------------------------------------- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(99, 102, 241, 0.08), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(118, 75, 162, 0.08), transparent 50%),
    var(--bg-page);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 2.25rem;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.login-card h1 {
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.login-card .login-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 1.75rem;
}

.login-card label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  letter-spacing: -0.005em;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
  color: var(--text-main);
  margin-bottom: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.login-card .btn { width: 100%; }

.login-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* -----------------------------------------------------------------------------
   10. Toast
   ----------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.85rem 1.15rem;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 360px;
}
.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------------------------------------------------
   11. Spinners
   ----------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -----------------------------------------------------------------------------
   12. Scrollbar
   ----------------------------------------------------------------------------- */
.transcript-box::-webkit-scrollbar { width: 6px; }
.transcript-box::-webkit-scrollbar-track { background: transparent; }
.transcript-box::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.transcript-box::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* -----------------------------------------------------------------------------
   13. Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .app-header { padding: 0.75rem 1rem; }
  .app-header h1 { font-size: 1.125rem; }
  .dashboard { padding: 1rem; }
  .stat-card { padding: 1.25rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .calls-grid { grid-template-columns: 1fr; }
  .user-info .user-email { display: none; }
}
