/* AI Attendance HQ — Redesigned Glassmorphic Theme matching Noteskart Technology */

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

:root {
  --primary: #6c63ff;
  --primary-rgb: 108, 99, 255;
  --secondary: #00d2ff;
  --accent: #6c63ff;
  --bg: #0b0f19;
  --panel: rgba(15, 23, 42, 0.75);
  --panel-solid: #0f172a;
  --line: rgba(108, 99, 255, 0.15);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --sidebar-bg: #070a12;
  --sidebar-ink: #f8fafc;
  --sidebar-muted: #94a3b8;
  --sidebar-active: rgba(108, 99, 255, 0.2);
  --sidebar-border: rgba(108, 99, 255, 0.12);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ff6584;
  --bad: #ff6584;
  --warn: #f59e0b;
  --gradient: linear-gradient(135deg, #6c63ff, #00d2ff);
  --radius: 12px;
  --font: 'Outfit', 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --line: rgba(108, 99, 255, 0.12);
  --ink: #0f172a;
  --muted: #64748b;
  --sidebar-bg: #0f172a;
  --sidebar-ink: #f8fafc;
  --sidebar-muted: #94a3b8;
  --sidebar-active: rgba(108, 99, 255, 0.2);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, #151c38 0%, var(--bg) 100%);
  color: var(--ink);
  display: grid;
  grid-template-columns: 260px 1fr;
  font-family: var(--font);
  line-height: 1.6;
}

body.kiosk-mode {
  grid-template-columns: 1fr;
}

/* Sidebar */
#sidebar, .sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 24px 20px;
  min-height: 100vh;
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 800;
  font-family: var(--font);
  font-size: 1.3rem;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

nav {
  display: grid;
  gap: 6px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  background: transparent;
  color: var(--sidebar-muted);
  transition: all 0.2s ease;
}

.nav:hover {
  background: rgba(108, 99, 255, 0.1);
  color: var(--sidebar-ink);
}

.nav.active {
  background: var(--gradient);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.35);
}

/* Main Content */
main {
  padding: 32px;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

#clock {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.88rem;
  margin-top: 4px;
}

.top-banner {
  margin: 0 0 20px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(108, 99, 255, 0.08);
  color: var(--ink);
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.top-banner.info { border-color: rgba(0, 210, 255, 0.3); background: rgba(0, 210, 255, 0.08); }
.top-banner.warn { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.08); color: #f59e0b; }
.top-banner.error { border-color: rgba(255, 101, 132, 0.3); background: rgba(255, 101, 132, 0.08); color: #ff6584; }

.status-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
}

.view { display: none; }
.view.active { display: block; }

/* Grid Layouts */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.metric {
  padding: 22px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric:hover {
  transform: translateY(-2px);
  border-color: rgba(108, 99, 255, 0.4);
}

.metric span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric strong {
  display: block;
  font-size: 2.2rem;
  font-weight: 800;
  margin-top: 8px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 20px;
}

.panel {
  padding: 24px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

/* Buttons & Controls */
button, .btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--gradient);
  color: #ffffff;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.25);
}

button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.35);
}

button.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: none;
}

button.secondary:hover {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--primary);
}

button.danger {
  background: linear-gradient(135deg, #ff6584, #e11d48);
  box-shadow: 0 4px 15px rgba(255, 101, 132, 0.25);
}

/* Form inputs */
select, input, textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.88rem;
  background: var(--panel-solid);
  color: var(--ink);
  transition: border-color 0.2s ease;
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.88rem;
}

th {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.status-badge, .badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.status-badge.on_time, .badge.on_time { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-badge.late, .badge.late { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.status-badge.not_come, .badge.not_come { background: rgba(255, 101, 132, 0.15); color: #ff6584; border: 1px solid rgba(255, 101, 132, 0.3); }

/* Event Log */
.event-log {
  display: grid;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
}

.event {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--panel-solid);
  color: var(--ink);
  font-size: 0.88rem;
}

/* Face Scanner View */
.scanner-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) 360px;
  gap: 20px;
  max-width: 1040px;
  margin: 0 auto;
}

.camera-panel {
  background: #070a12;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: grid;
  gap: 14px;
}

video {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid rgba(108, 99, 255, 0.3);
}

canvas { display: none; }

.scan-actions, .inline-action, .segmented, .button-row, .inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.result-box {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-solid);
  min-height: 120px;
}

.form-grid { display: grid; gap: 12px; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

label input, label select {
  color: var(--ink);
  font-weight: 400;
}

.check { display: flex; align-items: center; gap: 8px; }

.cards { display: grid; gap: 12px; }

.employee-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-solid);
}

.employee-card small { color: var(--muted); display: block; margin-top: 3px; }

.inline-action { margin-top: 14px; }
.inline-action input { flex: 1; min-width: 220px; }

.whatsapp-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 20px;
}

.wide-panel { grid-column: 1 / -1; }

.connection-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.connection-details div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-solid);
  min-width: 0;
}

.connection-details span { display: block; color: var(--muted); font-size: 0.78rem; }
.connection-details strong { display: block; overflow-wrap: anywhere; margin-top: 4px; font-size: 0.9rem; }

.qr-box, .pairing-box {
  margin-top: 16px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: 10px;
  min-height: 80px;
  background: var(--panel-solid);
  color: var(--muted);
  text-align: center;
}

.qr-box img { max-width: 240px; width: 100%; height: auto; border-radius: 8px; }

.pairing-code {
  font-size: 28px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--secondary);
}

.table-list, .route-list { display: grid; gap: 10px; }

.table-row, .route-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-solid);
}

.route-row {
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1fr) repeat(5, auto) auto;
}

.table-row small, .route-row small { color: var(--muted); overflow-wrap: anywhere; }

pre {
  white-space: pre-wrap;
  background: #070a12;
  color: #e8eef5;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  font-family: var(--mono);
  font-size: 0.85rem;
  min-height: 420px;
  overflow: auto;
}

.settings-panel { max-width: 760px; }

/* Responsive */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .metric-grid, .two-col, .scanner-layout, .whatsapp-grid, .connection-details, .table-row, .route-row { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
}

@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td {
    display: block;
    width: 100%;
  }
  table.responsive tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--panel-solid);
  }
  table.responsive td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: none;
  }
  table.responsive td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
  }
}
