/* ================================================================
   Portail Utilisateur - style.css
   Theme sombre — Syne + DM Mono
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@400;500;700&display=swap');

:root {
  --bg:          #0d0f14;
  --bg-raised:   #141720;
  --surface:     #1a1e2a;
  --surface-2:   #222737;
  --border:      rgba(255,255,255,0.07);
  --border-md:   rgba(255,255,255,0.13);
  --accent:      #00c2ff;
  --accent-dim:  rgba(0,194,255,0.10);
  --accent-dark: #0098cc;
  --text:        #e8eaf0;
  --text-muted:  #7a8099;
  --text-dim:    #4a5068;
  --success:     #22c55e;
  --success-dim: rgba(34,197,94,0.12);
  --danger:      #f87171;
  --danger-dim:  rgba(248,113,113,0.12);
  --font-sans:   'Syne', system-ui, sans-serif;
  --font-mono:   'DM Mono', 'Fira Mono', monospace;
  --radius:      8px;
  --radius-lg:   12px;
  --gap:         12px;
  --shadow:      0 2px 8px rgba(0,0,0,0.5);
  --glow:        0 0 0 1px rgba(0,194,255,0.2), 0 2px 12px rgba(0,194,255,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; outline: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

body { font-family: var(--font-sans); background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* ===== LOGIN ===== */
#screen-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(0,194,255,0.06) 0%, transparent 70%), var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--border-md); border-radius: var(--radius-lg); box-shadow: var(--shadow), 0 0 0 1px rgba(0,194,255,0.06); padding: 40px 32px; width: 100%; max-width: 360px; }
.login-box h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; text-align: center; margin-bottom: 0; }
.login-box h1::after { content: ''; display: block; width: 28px; height: 2px; background: var(--accent); margin: 10px auto 26px; border-radius: 2px; }
#login-form label { display: block; font-size: 0.7rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
#login-form input { width: 100%; padding: 11px 13px; margin-bottom: 16px; background: var(--bg-raised); border: 1px solid var(--border-md); border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 0.9rem; transition: border-color 0.15s, box-shadow 0.15s; }
#login-form input:focus { border-color: var(--accent); box-shadow: var(--glow); }

/* ===== TOPBAR ===== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.app-title { font-weight: 700; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); font-family: var(--font-mono); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
#extension-select { padding: 6px 10px; background: var(--bg-raised); border: 1px solid var(--border-md); border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 0.82rem; -webkit-appearance: none; appearance: none; }

/* ===== TABS ===== */
.tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 8px; overflow-x: auto; position: sticky; top: 49px; z-index: 9; }
.tab-btn { flex: 1; padding: 12px 10px; border: none; background: none; font-family: var(--font-sans); font-size: 0.8rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 6px; transition: color 0.15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 0.95rem; }

/* ===== CONTENT ===== */
.tab-content { padding: 16px; max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap); }
.tab-pane { display: none; flex-direction: column; gap: var(--gap); }
.tab-pane.active { display: flex; }

/* ===== CARDS ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-header h2 { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-family: var(--font-mono); }

/* ===== CF ===== */
.input-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input-row input { flex: 1 1 160px; padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--border-md); border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 0.9rem; min-width: 0; transition: border-color 0.15s; }
.input-row input:focus { border-color: var(--accent); box-shadow: var(--glow); }
.current-value { background: var(--accent-dim); border: 1px solid rgba(0,194,255,0.18); border-radius: var(--radius); padding: 9px 13px; font-size: 0.82rem; color: var(--accent); font-family: var(--font-mono); }

/* ===== DND SWITCH ===== */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--surface-2); border: 1px solid var(--border-md); border-radius: 999px; transition: 0.2s; }
.slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: var(--text-muted); border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.switch input:checked + .slider { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--accent); }
.switch input:disabled + .slider { opacity: 0.4; cursor: not-allowed; }

/* ===== BUTTONS (globaux) ===== */
/* Reset couleur navigateur sur tous les <button> pour eviter texte noir sur fond sombre */
button { color: inherit; background: none; border: none; font-family: inherit; }

.btn { padding: 9px 16px; border: 1px solid var(--border-md); border-radius: var(--radius); font-family: var(--font-sans); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all 0.15s; white-space: nowrap; color: var(--text); background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: var(--surface-2); border-color: var(--border-md); color: var(--text-muted); }
.btn-secondary:hover { color: var(--text); }
.btn-link { background: none; border: none; color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; font-size: 0.78rem; padding: 4px 0; }
.btn-link:hover { color: var(--text); }
.btn-icon { background: var(--surface-2); border: 1px solid var(--border-md); border-radius: var(--radius); padding: 5px 10px; font-size: 1rem; cursor: pointer; line-height: 1; color: var(--text-muted); }
.btn-icon:hover { color: var(--text); }
.btn-danger { background: var(--danger-dim); border-color: rgba(248,113,113,.25); color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; font-family: var(--font-mono); letter-spacing: 0.05em; }
.badge-on { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,.22); }
.badge-off { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-closed { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248,113,113,.22); }

/* Ouvert / Ferme (day/night) */
.daynight-list { display: flex; flex-direction: column; }
.daynight-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.daynight-row:last-child { border-bottom: none; }
.daynight-info { flex: 1; min-width: 0; }
.daynight-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.daynight-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }

/* ===== CALL LOG ===== */
.calls-list { display: flex; flex-direction: column; }
.call-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.call-item:last-child { border-bottom: none; }
.call-direction { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.call-info { flex: 1; min-width: 0; }
.call-number { font-family: var(--font-mono); font-weight: 500; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.call-duration { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); flex-shrink: 0; }

/* ===== VOICEMAIL ===== */
.vm-list { display: flex; flex-direction: column; gap: 8px; }
.vm-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); }
.vm-item.unread { border-color: rgba(0,194,255,.22); background: var(--accent-dim); }
.vm-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.vm-caller { font-weight: 600; font-size: 0.88rem; font-family: var(--font-mono); }
.vm-meta { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); }
.vm-actions { display: flex; gap: 6px; flex-shrink: 0; padding-top: 2px; }
.vm-player { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.vm-play-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--accent); background: var(--accent-dim); color: var(--accent); font-size: 0.75rem; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.vm-play-btn:hover { background: rgba(0,194,255,.2); }
.vm-progress-wrap { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.vm-progress { flex: 1; height: 4px; border-radius: 2px; cursor: pointer; -webkit-appearance: none; appearance: none; background: var(--surface-2); border: none; }
.vm-progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 2px; }
.vm-progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
.vm-progress::-moz-progress-bar { background: var(--accent); border-radius: 2px; }
.vm-time { font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-muted); flex-shrink: 0; min-width: 28px; text-align: right; }

/* ===== KEYS GRID ===== */
.keys-group-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.keys-group-btn {
  padding: 5px 14px;
  border: 1px solid var(--border-md);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.keys-group-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.keys-page { display: flex; flex-direction: column; gap: 6px; }
.keys-page-label { font-size: 0.65rem; font-family: var(--font-mono); color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; padding-left: 2px; }

.keys-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.key-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  cursor: grab;
  transition: all 0.15s;
  min-height: 60px;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.key-btn--set { border-color: rgba(0,194,255,0.25); background: var(--accent-dim); }
.key-btn--empty:hover { border-color: var(--border-md); background: var(--surface-2); }
.key-btn--set:hover { border-color: var(--accent); box-shadow: var(--glow); }
.key-btn--locked { opacity: 0.45; cursor: default; pointer-events: none; }
.key-btn--locked-admin { border-style: dashed; border-color: rgba(248,113,113,.35); }

.key-btn.dragging { opacity: 0.4; cursor: grabbing; box-shadow: 0 0 0 2px var(--accent); }
.key-btn.drag-over { border-color: var(--accent); background: var(--accent-dim); box-shadow: var(--glow); transform: scale(1.05); }

.key-num { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-dim); line-height: 1; }
.key-type-badge { font-family: var(--font-mono); font-size: 0.55rem; font-weight: 700; letter-spacing: 0.06em; color: var(--accent); background: rgba(0,194,255,0.12); border-radius: 3px; padding: 1px 4px; line-height: 1.4; }
.key-label { font-size: 0.7rem; font-weight: 600; color: var(--text); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; padding: 0 4px; }
.key-btn--empty .key-label { color: var(--text-dim); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal { background: var(--surface); border: 1px solid var(--border-md); border-radius: var(--radius-lg); box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,194,255,0.08); width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 0; overflow: hidden; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--accent); }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.modal-field label { display: block; font-size: 0.68rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.modal-field input, .modal-select { width: 100%; padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--border-md); border-radius: var(--radius); color: var(--text); font-family: var(--font-mono); font-size: 0.9rem; transition: border-color 0.15s; }
.modal-field input:focus, .modal-select:focus { border-color: var(--accent); box-shadow: var(--glow); }
.modal-fields { display: flex; flex-direction: column; gap: 12px; }

/* Boutons type de touche (BLF, Num. rapide, Fonction, Vider...) */
.key-type-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.key-type-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-md);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.key-type-btn:hover { color: var(--text); }
.key-type-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.key-type-btn[data-type="clear"].active { background: var(--danger-dim); border-color: rgba(248,113,113,.35); color: var(--danger); }

/* Boutons de fonction XML (DND, CFWD, Messagerie...) */
.xml-func-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.xml-func-btn:hover { color: var(--text); }
.xml-func-btn.active { background: rgba(0,194,255,0.15); border-color: var(--accent); color: var(--accent); }
#modal-xml-func-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.modal-footer { display: flex; gap: 8px; padding: 12px 18px 18px; border-top: 1px solid var(--border); }
.modal-footer .btn { flex: 1; }

/* ===== LOCK TOGGLE (admin) ===== */
.lock-row { display: flex; align-items: center; gap: 8px; cursor: pointer; text-transform: none; letter-spacing: normal; font-size: 0.8rem; color: var(--text); }
.lock-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }

/* ===== ADMIN DEVICES LIST ===== */
.admin-device-item .btn { flex-shrink: 0; }

/* ===== MISC ===== */
.hint-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.empty-state { font-size: 0.78rem; color: var(--text-dim); text-align: center; padding: 20px 0; font-family: var(--font-mono); }
.error-message { color: var(--danger); font-size: 0.8rem; text-align: center; margin-top: 6px; }
.feedback-message { font-size: 0.8rem; padding: 9px 13px; border-radius: var(--radius); font-family: var(--font-mono); }
.feedback-message.success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,.18); }
.feedback-message.error { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248,113,113,.18); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
