/* ============================================================
   ZKTeco Dashboard — Global Stylesheet
   Design: Dark mode, glassmorphism, purple accent
   ============================================================ */

/* ---- Variables ---- */
:root {
  --bg: #0f0f18;
  --bg-2: #161624;
  --bg-3: #1e1e30;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-light: rgba(99, 102, 241, 0.12);

  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;

  --text-1: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;

  --sidebar-w: 240px;
  --topbar-h: 64px;
  --radius: 14px;
  --radius-sm: 8px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.3);

  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

button { cursor: pointer; font-family: inherit; border: none; background: none; }

input { font-family: inherit; }

/* ============================================================
   UTILITIES
   ============================================================ */

.hidden { display: none !important; }

.glass {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text-1); }

.btn-full { width: 100%; justify-content: center; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn:disabled { opacity: 0.5; pointer-events: none; }

/* Spinner */
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   FORMS
   ============================================================ */

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

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 14px;
  padding: 11px 14px 11px 40px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-wrapper input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input-wrapper input[type="date"],
.input-wrapper input[type="time"] {
  color-scheme: dark;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
  display: flex;
}

.input-icon svg { width: 16px; height: 16px; }

.toggle-password {
  position: absolute;
  right: 12px;
  color: var(--text-3);
  display: flex;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.toggle-password:hover { color: var(--text-1); }
.toggle-password svg { width: 16px; height: 16px; }

.form-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #fca5a5;
}

.form-msg {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
}
.form-msg.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}
.form-msg.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ============================================================
   AUTH PAGE
   ============================================================ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* Animated background blobs */
.auth-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  animation: blobFloat 8s ease-in-out infinite;
}

.blob-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #6366f1, transparent);
  top: -150px; left: -150px;
  animation-delay: 0s;
}
.blob-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #8b5cf6, transparent);
  bottom: -100px; right: -100px;
  animation-delay: -3s;
}
.blob-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #3b82f6, transparent);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -6s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.05); }
  66% { transform: translate(-15px, 15px) scale(0.95); }
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.auth-card {
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.auth-icon svg { width: 52px; height: 52px; }

.auth-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text-1);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 32px;
}

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

.auth-footer {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  margin-top: 28px;
}

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

.dashboard-page { overflow-x: hidden; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
}
.sidebar-logo svg { width: 32px; height: 32px; }

.sidebar-close {
  color: var(--text-3);
  display: none;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition);
}
.sidebar-close:hover { color: var(--text-1); }
.sidebar-close svg { width: 18px; height: 18px; }

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--transition);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-1);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.sidebar-footer {
  padding: 16px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .btn-ghost {
  color: var(--text-2);
  gap: 10px;
  justify-content: flex-start;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
}
.sidebar-footer .btn-ghost svg { width: 18px; height: 18px; }
.sidebar-footer .btn-ghost:hover { background: rgba(239,68,68,0.1); color: #f87171; }

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* Main wrapper */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(15,15,24,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 50;
}

.topbar-menu {
  color: var(--text-2);
  display: none;
  padding: 6px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
}
.topbar-menu:hover { color: var(--text-1); background: var(--surface); }
.topbar-menu svg { width: 20px; height: 20px; }

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  flex: 1;
}

.topbar-clock {
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Content */
.content {
  flex: 1;
  padding: 28px 28px 48px;
  max-width: 1100px;
  width: 100%;
}

/* Page sections */
.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.3s ease; }

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

/* Section header */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-2);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card);
}

.card-accent {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.08));
  border-color: rgba(99,102,241,0.3);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon svg { width: 18px; height: 18px; }

.icon-purple { background: rgba(99,102,241,0.15); color: var(--accent); }
.icon-blue   { background: rgba(59,130,246,0.15); color: var(--blue); }
.icon-green  { background: rgba(16,185,129,0.15); color: var(--green); }
.icon-orange { background: rgba(245,158,11,0.15); color: var(--orange); }

.card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
  word-break: break-word;
}
.card-value.large {
  font-size: 28px;
  font-weight: 700;
}

.card-sub {
  font-size: 12px;
  color: var(--text-3);
}

.card-title-inner {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 20px;
}

/* ============================================================
   DETAIL CARD
   ============================================================ */

.detail-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.detail-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.detail-row:last-child { border-bottom: none; }

.detail-key {
  font-size: 13px;
  color: var(--text-2);
  min-width: 180px;
  flex-shrink: 0;
}

.detail-val {
  font-size: 13px;
  color: var(--text-1);
  font-weight: 500;
  font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all;
}

/* ============================================================
   LOADING / ERROR STATE
   ============================================================ */

.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--text-2);
  text-align: center;
}

.error-state svg {
  width: 40px; height: 40px;
  color: var(--red);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SET TIME SECTION
   ============================================================ */

.set-time-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.set-time-card .set-time-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shortcut-label {
  font-size: 12px;
  color: var(--text-3);
}

/* Preview clock */
.preview-clock {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}

.preview-date {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.preview-time {
  font-size: 38px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.preview-note {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
}

.preview-compare {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.compare-label {
  font-size: 12px;
  color: var(--text-2);
}

.compare-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .set-time-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
  .sidebar-close { display: flex; }
  .sidebar-overlay.open { display: block; }

  .main-wrapper { margin-left: 0; }
  .topbar-menu { display: flex; }

  .content { padding: 20px 16px 40px; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .detail-key { min-width: 120px; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .cards-grid { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header .btn { width: 100%; justify-content: center; }
}
