/* =====================================================================
   Spoofer — Softphone WebRTC
   ===================================================================== */

:root {
  --bg: #0b0f14;
  --surface: #141b24;
  --surface-2: #1c2530;
  --border: #263140;
  --text: #e8eef5;
  --muted: #8695a8;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --green: #22c55e;
  --green-2: #16a34a;
  --red: #ef4444;
  --red-2: #dc2626;
  --r: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(59,130,246,.10), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(34,197,94,.06), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  -webkit-font-smoothing: antialiased;
}

.app { width: 100%; max-width: 900px; }

/* --- Icônes --- */
.icon { width: 20px; height: 20px; flex: none; }
.icon.sm { width: 15px; height: 15px; }

/* --- Écrans : un seul visible à la fois --- */
.screen { animation: in .25s ease both; }
.screen[hidden] { display: none !important; }
@keyframes in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
}

/* --- Champs --- */
.field { display: block; margin-bottom: 16px; }
.field-label,
label > span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: .2px;
}

input, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input::placeholder { color: #55657a; }
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 18px;
  border: none;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  transition: background .18s, opacity .18s, transform .06s;
}
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn-primary { width: 100%; background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-call { flex: 1; background: var(--green); }
.btn-call:hover:not(:disabled) { background: var(--green-2); }
.btn-hangup { flex: 1; background: var(--red); }
.btn-hangup:hover:not(:disabled) { background: var(--red-2); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.btn-icon:hover { color: var(--text); border-color: #3a4a5e; background: var(--surface-2); }

/* --- Login --- */
.login-screen { display: flex; justify-content: center; }
.login-card { width: 100%; max-width: 420px; text-align: center; }
.login-logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
}
.login-logo .icon { width: 26px; height: 26px; }
.login-card h1 { font-size: 23px; font-weight: 700; letter-spacing: -.3px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 5px 0 22px; line-height: 1.45; }
.hint a { color: var(--accent); }
.call-hint { margin: 12px 0 0; text-align: center; }
.login-card label { text-align: left; display: block; margin-bottom: 15px; }
.login-card .btn-primary { margin-top: 6px; }

/* --- Password strength --- */
.pwd-strength {
  text-align: left;
  margin: -4px 0 16px;
  padding: 12px 12px 10px;
  background: #151b22;
  border: 1px solid #232b36;
  border-radius: 12px;
}
.pwd-strength-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: #8b95a3;
  margin-bottom: 8px;
}
#pwd-strength-label {
  font-weight: 600;
  color: #9aa5b4;
  transition: color .2s;
}
.pwd-strength-track {
  height: 4px;
  border-radius: 999px;
  background: #2a323d;
  overflow: hidden;
  margin-bottom: 10px;
}
.pwd-strength-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: #ef4444;
  transition: width .25s ease, background .25s ease;
}
.pwd-strength[data-score="1"] .pwd-strength-bar { background: #ef4444; }
.pwd-strength[data-score="2"] .pwd-strength-bar { background: #f59e0b; }
.pwd-strength[data-score="3"] .pwd-strength-bar { background: #eab308; }
.pwd-strength[data-score="4"] .pwd-strength-bar { background: #84cc16; }
.pwd-strength[data-score="5"] .pwd-strength-bar { background: #22c55e; }
.pwd-strength[data-score="1"] #pwd-strength-label { color: #f87171; }
.pwd-strength[data-score="2"] #pwd-strength-label { color: #fbbf24; }
.pwd-strength[data-score="3"] #pwd-strength-label { color: #facc15; }
.pwd-strength[data-score="4"] #pwd-strength-label { color: #a3e635; }
.pwd-strength[data-score="5"] #pwd-strength-label { color: #4ade80; }

.pwd-reqs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 0;
  padding: 0;
}
.pwd-reqs li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: #7d8794;
  transition: color .2s;
  white-space: nowrap;
}
.pwd-reqs li .pwd-mark {
  font-size: 11px;
  line-height: 1;
  width: 12px;
  text-align: center;
  color: #6b7280;
}
.pwd-reqs li.ok {
  color: #86efac;
}
.pwd-reqs li.ok .pwd-mark {
  color: #22c55e;
}

.error {
  margin-top: 14px;
  padding: 11px 13px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.32);
  border-radius: 10px;
  color: #fca5a5;
  font-size: 13.5px;
}

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 2px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 9px;
  padding: 5px;
  width: 30px; height: 30px;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.reg-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}
.reg-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #55657a;
  transition: background .25s, box-shadow .25s;
}
.reg-status[data-state="on"] { color: #86efac; border-color: rgba(34,197,94,.35); }
.reg-status[data-state="on"] .dot { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,.7); }
.reg-status[data-state="off"] { color: #fca5a5; border-color: rgba(239,68,68,.3); }
.reg-status[data-state="off"] .dot { background: var(--red); }

/* --- Grille téléphone --- */
.phone-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
}
@media (max-width: 720px) {
  .phone-grid { grid-template-columns: 1fr; }
}

.dial-card { padding: 24px; }

.display { position: relative; margin-bottom: 18px; }
#dial-input {
  font-size: 22px;
  text-align: center;
  letter-spacing: 1.5px;
  padding: 14px 46px;
  font-weight: 600;
}
.clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
}
.clear:hover { color: var(--red); }

.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 18px;
}
.key {
  padding: 15px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background .12s, transform .05s, border-color .12s;
}
.key b { font-size: 19px; font-weight: 600; }
.key i { font-size: 9px; font-style: normal; color: var(--muted); letter-spacing: 1px; }
.key:hover { background: #232f3d; border-color: #34445a; }
.key:active { transform: scale(.95); }

.call-timer {
  text-align: center;
  margin-bottom: 14px;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--green);
}

.call-controls { display: flex; gap: 10px; }

/* --- Colonne latérale --- */
.side { display: flex; flex-direction: column; gap: 18px; }
.side .card { padding: 20px; }
.side h3 {
  display: flex; align-items: center; gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.history-head h3 { margin: 0; }

.history-list {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.history-list li:hover { background: #232f3d; }
.history-list li .dir-icon {
  width: 26px; height: 26px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  color: #fff;
}
.history-list li.in .dir-icon { background: rgba(34,197,94,.22); color: #86efac; }
.history-list li.out .dir-icon { background: rgba(59,130,246,.22); color: #93c5fd; }
.history-list li.missed .dir-icon { background: rgba(239,68,68,.22); color: #fca5a5; }
.history-list .dir-icon svg { width: 13px; height: 13px; }
.history-list .info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.history-list .num { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-list .meta { font-size: 11.5px; color: var(--muted); }
.history-list .empty {
  justify-content: center;
  background: transparent;
  color: var(--muted);
  cursor: default;
  font-size: 13px;
  padding: 18px 0;
}
.history-list .empty:hover { background: transparent; }

::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* --- Écran d'appel (overlay) --- */
.call-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(59,130,246,.14), transparent 55%),
    linear-gradient(180deg, #0a1628 0%, #07101c 55%, #050b14 100%);
}
.call-screen[hidden] { display: none !important; }

.call-screen-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.call-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  background: linear-gradient(145deg, #34d399, #0ea5e9);
  color: #0b1220;
  box-shadow: 0 12px 36px rgba(14,165,233,.28);
}
.call-avatar .icon { width: 40px; height: 40px; }

.call-status {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.call-dest {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .5px;
  line-height: 1.2;
  margin-bottom: 8px;
  word-break: break-all;
}

.call-cid {
  font-size: 16px;
  font-weight: 600;
  color: #7dd3fc;
  margin-bottom: 18px;
}

.call-screen-timer {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  margin-bottom: 14px;
  min-height: 1.2em;
}
.call-screen-timer[hidden] { display: none !important; }

/* Attente / sonnerie */
.call-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  min-height: 52px;
}
.call-waiting[hidden] { display: none !important; }
.wait-label {
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 500;
}
.wait-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 14px;
}
.wait-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7dd3fc;
  opacity: .35;
  animation: waitPulse 1.2s ease-in-out infinite;
}
.wait-dots span:nth-child(2) { animation-delay: .2s; }
.wait-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes waitPulse {
  0%, 80%, 100% { opacity: .25; transform: scale(.85); }
  40% { opacity: 1; transform: scale(1.15); }
}

.call-screen[data-phase="wait"] .call-avatar {
  animation: avatarRing 1.6s ease-in-out infinite;
}
@keyframes avatarRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(14,165,233,.45), 0 12px 36px rgba(14,165,233,.28); }
  50% { box-shadow: 0 0 0 16px rgba(14,165,233,0), 0 12px 36px rgba(14,165,233,.28); }
}

.dtmf-display {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #93c5fd;
  margin-bottom: 12px;
  min-height: 1.2em;
  word-break: break-all;
}
.dtmf-display[hidden] { display: none !important; }

/* Clavier DTMF en appel */
.call-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 18px;
}
.call-keypad[hidden] { display: none !important; }
.call-keypad.is-waiting { opacity: .72; }
.call-key {
  padding: 12px 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: background .12s, transform .05s, border-color .12s;
  font-family: inherit;
}
.call-key b { font-size: 18px; font-weight: 650; }
.call-key i { font-size: 9px; font-style: normal; color: var(--muted); letter-spacing: 1px; }
.call-key:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.22); }
.call-key:active { transform: scale(.94); background: rgba(59,130,246,.28); }

.call-screen-actions {
  display: flex;
  gap: 22px;
  justify-content: center;
  margin-bottom: 28px;
}

.btn-round {
  width: 72px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}
.btn-round .icon {
  width: 22px;
  height: 22px;
  padding: 18px;
  box-sizing: content-box;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  transition: background .18s, border-color .18s, color .18s;
}
.btn-round:hover .icon {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.22);
}
.btn-round[aria-pressed="true"] .icon {
  background: rgba(239,68,68,.2);
  border-color: rgba(239,68,68,.45);
  color: #fca5a5;
}
.btn-round#btn-hold[aria-pressed="true"] .icon {
  background: rgba(245, 158, 11, .22);
  border-color: rgba(245, 158, 11, .5);
  color: #fcd34d;
}
.btn-round:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-round:disabled:hover .icon {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
}

.btn-hangup-round {
  width: 72px;
  height: 72px;
  border: none;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(239,68,68,.35);
  transition: background .18s, transform .06s;
}
.btn-hangup-round:hover { background: var(--red-2); }
.btn-hangup-round:active { transform: scale(.96); }
.btn-hangup-round .icon { width: 28px; height: 28px; }

.hold-music-field { margin-top: 14px; }
.hold-music-select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.hold-music-select:focus {
  outline: none;
  border-color: rgba(59,130,246,.55);
}

.tts-card { margin-top: 12px; }
.tts-text {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
  min-height: 72px;
}
.tts-text:focus {
  outline: none;
  border-color: rgba(59,130,246,.55);
}
.tts-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.tts-actions .btn { flex: 1; }
.btn-ghost {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }
.tts-mix-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted, #9aa8bc);
  cursor: pointer;
  user-select: none;
}
.tts-mix-check input {
  width: 15px;
  height: 15px;
  accent-color: #3b82f6;
  cursor: pointer;
}
.tts-hint { margin-top: 8px; color: #93c5fd; }
