/* ========================================================================
   vFace Web — Premium Dark Mode Design System
   ======================================================================== */

:root {
  /* Core palette */
  --bg-base:        #080d14;
  --bg-surface:     #0f1724;
  --bg-card:        #151f2e;
  --bg-card-hover:  #1a2740;
  --bg-input:       #1e2d44;
  --border:         rgba(255,255,255,0.07);
  --border-focus:   rgba(99,179,237,0.5);

  /* Brand gradient */
  --grad-start:     #3b82f6;
  --grad-end:       #8b5cf6;
  --brand-grad:     linear-gradient(135deg, var(--grad-start), var(--grad-end));

  /* Text */
  --text-primary:   #f0f6ff;
  --text-secondary: #8fa3c0;
  --text-muted:     #4a6080;

  /* Status */
  --green:   #22d3a8;
  --red:     #f87171;
  --yellow:  #fbbf24;
  --blue:    #60a5fa;

  /* Sizes */
  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --sidebar-w:  240px;

  /* Transitions */
  --t-fast:  0.15s ease;
  --t-med:   0.25s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ──────────────────────────────────────── */
.hidden  { display: none !important; }
.flex    { display: flex; }
.center  { align-items: center; justify-content: center; }

/* ── Buttons ──────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--brand-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: 0 4px 20px rgba(59,130,246,0.3);
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(59,130,246,0.4);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: rgba(248,113,113,0.1);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.btn-secondary:hover { background: rgba(248,113,113,0.18); transform: translateY(-1px); }

/* ── Spinner ──────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======================================================================== */
/* LOGIN PAGE                                                                */
/* ======================================================================== */

.login-body { overflow: hidden; }

.login-root {
  display: flex;
  height: 100vh;
}

/* Brand panel */
.brand-panel {
  flex: 1;
  background: linear-gradient(145deg, #0a1628 0%, #0f1f3d 60%, #12243a 100%);
  position: relative;
  display: flex;
  align-items: center;
  padding: 60px;
  overflow: hidden;
}
.brand-panel::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
  top: -100px; left: -100px;
  pointer-events: none;
}
.brand-panel::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
  bottom: -80px; right: 60px;
  pointer-events: none;
}

.brand-content { position: relative; z-index: 1; }

.brand-logo-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.brand-icon {
  width: 56px; height: 56px;
  background: var(--brand-grad);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(59,130,246,0.4);
}
.brand-icon svg { width: 32px; height: 32px; }

.brand-name {
  font-size: 2.8rem;
  font-weight: 800;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.brand-tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 36px;
  max-width: 340px;
}

.brand-features {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-pill {
  padding: 8px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  backdrop-filter: blur(8px);
  transition: background var(--t-fast), color var(--t-fast);
}
.feature-pill:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

/* Login panel */
.login-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

.card-header { margin-bottom: 32px; }

.card-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.login-form { display: flex; flex-direction: column; gap: 18px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field-input::placeholder { color: var(--text-muted); }
.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,179,237,0.12);
}

.input-wrap { position: relative; }
.input-wrap .field-input { padding-right: 46px; }

.eye-btn {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex; align-items: center;
  transition: color var(--t-fast);
}
.eye-btn:hover { color: var(--text-secondary); }
.eye-btn svg { width: 18px; height: 18px; }

.status-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
}
.status-box.info  { background: rgba(96,165,250,0.12); color: var(--blue);  border: 1px solid rgba(96,165,250,0.2); }
.status-box.error { background: rgba(248,113,113,0.12); color: var(--red);  border: 1px solid rgba(248,113,113,0.2); }
.status-box.ok    { background: rgba(34,211,168,0.12);  color: var(--green); border: 1px solid rgba(34,211,168,0.2); }

.login-form .btn-primary { width: 100%; justify-content: center; padding: 14px; font-size: 0.95rem; }

/* ── Step progress bar ────────────────────────────────────────── */
.step-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-track {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.step-bar {
  height: 100%;
  background: var(--brand-grad);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.step-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  letter-spacing: 0.02em;
}

/* ── Platform picker modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-overlay.visible { opacity: 1; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: min(480px, 90vw);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: fadeUp 0.25s ease;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.platform-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 24px;
}

.platform-item {
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.platform-item:hover    { background: var(--bg-card-hover); color: var(--text-primary); }
.platform-item.selected {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.4);
  color: var(--blue);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}


/* ======================================================================== */
/* DASHBOARD                                                                 */
/* ======================================================================== */

.dashboard-body { overflow: hidden; }

.dashboard-root {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 0 0 20px;
}

.sidebar-header {
  padding: 26px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.sidebar-icon {
  width: 36px; height: 36px;
  background: var(--brand-grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-icon svg { width: 20px; height: 20px; }

.sidebar-brand {
  font-size: 1.3rem;
  font-weight: 800;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-tagline {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-left: 48px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
  width: 100%;
}
.nav-btn .nav-icon { font-size: 1rem; }
.nav-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-btn.active {
  background: rgba(59,130,246,0.12);
  color: var(--blue);
  font-weight: 600;
}

.sidebar-footer {
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.engine-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.loading { background: var(--yellow); animation: pulse 1.2s ease infinite; }
.status-dot.ready   { background: var(--green); animation: none; }
.status-dot.error   { background: var(--red);   animation: none; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.logout-btn { color: var(--red); }
.logout-btn:hover { background: rgba(248,113,113,0.08) !important; }

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-base);
}

.page { display: none; flex-direction: column; height: 100%; padding: 28px 32px; gap: 24px; }
.page.active { display: flex; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.feed-controls { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* Feed body */
.feed-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

/* Camera grid */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  align-content: start;
  overflow-y: auto;
}

.grid-placeholder {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-align: center;
}
.placeholder-icon { font-size: 3rem; }
.grid-placeholder p { font-size: 0.9rem; line-height: 1.6; }

/* Device video card */
.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--t-med);
}
.device-card:hover { border-color: rgba(59,130,246,0.3); }

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.device-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.device-card-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  letter-spacing: 0.06em;
}
.badge-in  { background: rgba(34,211,168,0.15); color: var(--green); }
.badge-out { background: rgba(248,113,113,0.15); color: var(--red);  }

.device-card-body { position: relative; }

.device-stream {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: #0a0f1a;
}

.stream-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(10,15,26,0.85);
  color: var(--text-muted);
  font-size: 0.82rem;
  pointer-events: none;
}

.device-card-footer {
  padding: 8px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Attendance log panel */
.attendance-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

.live-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--green);
  animation: pulse 1.5s ease infinite;
  letter-spacing: 0.05em;
}

.log-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.log-scroll::-webkit-scrollbar { width: 4px; }
.log-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.log-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 12px;
  line-height: 1.6;
}

.log-entry {
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity:0; transform:translateX(10px); } to { opacity:1; transform:translateX(0); } }

.log-name   { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.log-meta   { font-size: 0.75rem; color: var(--text-muted); display:flex; gap:8px; align-items:center; }
.log-dir    { font-size: 0.72rem; font-weight:700; padding:2px 7px; border-radius:100px; }
.dir-in     { background:rgba(34,211,168,0.15); color:var(--green); }
.dir-out    { background:rgba(248,113,113,0.15); color:var(--red); }

/* Devices page */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  align-content: start;
}

.dev-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--t-med), transform var(--t-med);
}
.dev-info-card:hover { border-color: rgba(59,130,246,0.3); transform: translateY(-2px); }

.dev-info-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.dev-info-location { font-size: 0.82rem; color: var(--text-secondary); }

.dev-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.dev-info-row span:last-child { color: var(--text-secondary); font-weight:500; }

.dev-info-counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.count-box {
  padding: 10px;
  border-radius: var(--radius-sm);
  text-align: center;
}
.count-box.in-box  { background: rgba(34,211,168,0.08); border:1px solid rgba(34,211,168,0.15); }
.count-box.out-box { background: rgba(248,113,113,0.08); border:1px solid rgba(248,113,113,0.15); }

.count-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}
.in-box  .count-value { color: var(--green); }
.out-box .count-value { color: var(--red);   }

.count-label { font-size: 0.7rem; font-weight:600; letter-spacing:0.08em; color:var(--text-muted); margin-top:3px; }

/* Enabled dot */
.enabled-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
.enabled-dot.on  { background: var(--green); }
.enabled-dot.off { background: var(--text-muted); }

/* Scrollbar */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }
