@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ══════════════════════════════════════════
   SMARTHOME AI — Base Styles
   MASSE MASSE PAUL-BASTHYLLE © 2026
══════════════════════════════════════════ */

:root {
  /* ─ Palette principale ─ */
  --bg-color:        #0a0f1e;
  --bg-secondary:    #0f172a;
  --card-bg:         #131f35;
  --card-hover:      #182544;
  --surface:         #1e2d45;
  --surface-2:       #243351;

  /* ─ Texte ─ */
  --text-primary:    #e8f0fe;
  --text-secondary:  #7b92b4;
  --text-muted:      #4a5f7c;

  /* ─ Accent bleu ─ */
  --accent:          #3b82f6;
  --accent-hover:    #2563eb;
  --accent-soft:     rgba(59, 130, 246, 0.12);
  --accent-glow:     rgba(59, 130, 246, 0.35);

  /* ─ États ─ */
  --green:           #10b981;
  --green-soft:      rgba(16, 185, 129, 0.12);
  --green-glow:      rgba(16, 185, 129, 0.3);
  --red:             #ef4444;
  --red-soft:        rgba(239, 68, 68, 0.12);
  --gold:            #f59e0b;
  --gold-soft:       rgba(245, 158, 11, 0.12);
  --gold-glow:       rgba(245, 158, 11, 0.3);

  /* ─ Bordures & ombres ─ */
  --border:          rgba(59, 130, 246, 0.12);
  --border-strong:   rgba(59, 130, 246, 0.25);
  --shadow-sm:       0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg:       0 10px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow:     0 0 30px rgba(59, 130, 246, 0.15);

  /* ─ Formes ─ */
  --radius-sm:       8px;
  --radius:          14px;
  --radius-lg:       20px;

  /* ─ Typo ─ */
  --font-main:       'Space Grotesk', system-ui, sans-serif;
  --font-mono:       'JetBrains Mono', monospace;

  /* ─ Transitions ─ */
  --transition:      0.2s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset ─────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  outline: none;
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-color);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59,130,246,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 90% 10%, rgba(16,185,129,0.04) 0%, transparent 50%);
  color: var(--text-primary);
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Scrollbar ─────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Liens ─────────────────────────────── */
a {
  text-decoration: none;
  color: var(--accent);
  transition: color var(--transition);
}
a:hover { color: var(--text-primary); }

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
header {
  background: rgba(10, 15, 30, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}
.brand span { color: var(--accent); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--accent); opacity: 1; }
  50%       { box-shadow: 0 0 16px var(--accent); opacity: 0.7; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Role pill ─────────────────────────── */
.role-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
}
.role-pill.role-admin {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: rgba(245, 158, 11, 0.3);
}
.role-pill.role-owner {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ── MQTT Status ───────────────────────── */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
  transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
  animation: pulse-dot-green 2.5s ease-in-out infinite;
}
@keyframes pulse-dot-green {
  0%, 100% { box-shadow: 0 0 6px var(--green-glow); }
  50%       { box-shadow: 0 0 18px var(--green-glow); }
}

/* ══════════════════════════════════════════
   BOUTONS
══════════════════════════════════════════ */
button {
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.4rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: rgba(255,255,255,0.03);
}

.btn-gold {
  background: var(--gold);
  color: #0a0f1e;
  font-weight: 700;
  box-shadow: 0 4px 16px var(--gold-glow);
}
.btn-gold:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 24px var(--gold-glow);
  transform: translateY(-1px);
}
.btn-gold:disabled { opacity: 0.45; cursor: not-allowed; }

/* ══════════════════════════════════════════
   INPUTS & FORMS
══════════════════════════════════════════ */
input[type="text"],
input[type="number"],
input[type="password"],
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.95rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, .form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-muted); }

/* ══════════════════════════════════════════
   CAMÉRA / VIDÉO (partagé)
══════════════════════════════════════════ */
.video-box, .photo-box, .auth-vid-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 auto 1.5rem auto;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}
video, canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

/* Vignette */
.cam-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(circle, transparent 45%, rgba(10,15,30,0.85) 100%);
  pointer-events: none;
  z-index: 1;
}

/* Ligne de scan */
.cam-scan {
  position: absolute; left: 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent), 0 0 24px var(--accent);
  animation: scanMove 3s ease-in-out infinite;
  z-index: 2;
  opacity: 0;
}
@keyframes scanMove {
  0%   { top: 5%;  opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.9; }
  100% { top: 95%; opacity: 0; }
}

/* Coins animés */
.cam-corner {
  position: absolute;
  width: 28px; height: 28px;
  border: 2px solid var(--accent);
  z-index: 3;
  animation: pulseCorner 2.5s ease-in-out infinite;
}
.tl { top: 16px; left: 16px; border-right: none; border-bottom: none; }
.tr { top: 16px; right: 16px; border-left: none; border-bottom: none; animation-delay: 0.6s; }
.bl { bottom: 16px; left: 16px; border-right: none; border-top: none; animation-delay: 1.2s; }
.br { bottom: 16px; right: 16px; border-left: none; border-top: none; animation-delay: 1.8s; }

@keyframes pulseCorner {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1; box-shadow: 0 0 8px var(--accent); }
}

/* ══════════════════════════════════════════
   TOASTS
══════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--text-primary);
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 280px;
  max-width: 360px;
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.toast.show  { transform: translateX(0); }
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--gold); }

/* ══════════════════════════════════════════
   MODAL SYSTÈME
══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 15, 30, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}
.overlay.open { display: flex; }

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(59,130,246,0.1);
  animation: modalPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.93) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.step-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 1.5rem;
}
.step-dot {
  width: 32px; height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: all 0.3s;
}
.step-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.step-dot.done {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
}

.modal-icon { font-size: 2.5rem; margin-bottom: 0.75rem; line-height: 1; }
.modal h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
  text-align: center;
}
.modal-sub {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.modal-msg {
  text-align: center;
  min-height: 1.4rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.modal-msg.ok  { color: var(--green); }
.modal-msg.err { color: var(--red); }

.modal-btns {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.75rem;
}
.modal-btns button { flex: 1; }

.modal-step { display: none; width: 100%; }
.modal-step.active { display: flex; flex-direction: column; align-items: center; }

.pwd-input {
  width: 100%;
  margin-top: 0.75rem;
  text-align: center;
  font-size: 1.5rem;
  font-family: var(--font-mono);
  letter-spacing: 0.2em;
}
.pwd-err {
  color: var(--red);
  text-align: center;
  min-height: 1.2rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

/* ══════════════════════════════════════════
   FOOTER
══════════════════════════════════════════ */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  border-top: 1px solid var(--border);
  background: var(--bg-color);
  margin-top: auto;
  letter-spacing: 0.03em;
}

/* ══════════════════════════════════════════
   UTILITAIRES
══════════════════════════════════════════ */
.mono { font-family: var(--font-mono); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Responsive ─────────────────────────── */
@media (max-width: 600px) {
  header { padding: 0 1rem; }
  .modal { padding: 1.5rem; }
  .modal-btns { flex-direction: column; }
}
