/* ============================================
   E-ARSIP SMP N 3 OKU — Premium Dark CSS
   Modern Glassmorphism Design System v2.0
   ============================================ */

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

/* ---- CSS Custom Properties ---- */
:root {
  --bg-deep:      #060b14;
  --bg-base:      #0d1424;
  --bg-surface:   #111827;
  --bg-card:      #141e2f;
  --bg-elevated:  #1a2540;
  --border:       rgba(99, 118, 160, 0.18);
  --border-glow:  rgba(99, 102, 241, 0.35);

  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow:  rgba(99, 102, 241, 0.25);
  --accent-light: #818cf8;

  --emerald:      #10b981;
  --emerald-dim:  rgba(16, 185, 129, 0.15);
  --yellow:       #f59e0b;
  --yellow-dim:   rgba(245, 158, 11, 0.15);
  --red:          #ef4444;
  --red-dim:      rgba(239, 68, 68, 0.12);
  --cyan:         #06b6d4;
  --cyan-dim:     rgba(6, 182, 212, 0.12);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --text-accent:    #818cf8;

  --radius-sm:  0.5rem;
  --radius-md:  0.875rem;
  --radius-lg:  1.25rem;
  --radius-xl:  1.75rem;
  --radius-2xl: 2rem;

  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.45);
  --shadow-deep: 0 20px 60px rgba(0, 0, 0, 0.7);

  --sidebar-w: 260px;
  --topbar-h:  70px;

  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
#loginPage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(to bottom, rgba(6, 11, 20, 0.4), rgba(6, 11, 20, 0.8)), url('../img/login_bg.png') center/cover no-repeat;
  position: relative;
}

.login-card {
  background: rgba(13, 20, 36, 0.55);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-2xl);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255,255,255,0.05) inset, 0 0 80px rgba(99,102,241,0.25);
  position: relative;
  z-index: 10;
  animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.92) translateY(30px); filter: blur(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.login-logo {
  width: 96px; height: 96px;
  background: #ffffff;
  border-radius: 50%;
  margin: 0 auto 1.5rem;
  border: 2px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
  box-shadow: 0 0 30px rgba(99,102,241,0.5), 0 10px 40px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.login-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.2);
}

.login-logo img { width: 100%; height: 100%; object-fit: cover; z-index: 2; }

.login-title {
  text-align: center;
  margin-bottom: 2.5rem;
}
.login-title h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: -0.03em;
  margin-bottom: 0.2rem;
  text-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.login-title p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Form Controls ---- */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-wrap { position: relative; }

.input-icon {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  display: flex;
  align-items: center;
  padding-left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.form-input {
  width: 100%;
  background: rgba(6, 11, 20, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem 0.8rem 2.75rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.form-input:focus + .input-icon,
.input-wrap:focus-within .input-icon {
  color: var(--accent-light);
}

.form-input::placeholder { color: var(--text-muted); }

/* Eye toggle untuk password */
.input-eye {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  display: flex;
  align-items: center;
  padding-right: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition);
}
.input-eye:hover { color: var(--text-secondary); }
.form-input.has-eye { padding-right: 2.75rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #3730a3);
  box-shadow: 0 8px 28px rgba(99,102,241,0.45);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-full { width: 100%; }

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 1.25rem;
  font-size: 0.85rem;
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text-primary); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Login info box */
.login-info {
  margin-top: 1.5rem;
  background: rgba(6, 11, 20, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
}

.login-info .icon { color: var(--yellow); margin-top: 0.1rem; flex-shrink: 0; }
.login-info p { color: var(--text-secondary); line-height: 1.6; }
.login-info strong { color: var(--yellow); }
.login-info .mono { color: var(--text-accent); font-family: 'Courier New', monospace; font-size: 0.72rem; display: block; margin-top: 0.4rem; }

.login-footer {
  margin-top: 1.75rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */
#mainApp {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(11, 17, 28, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  padding: 0 1.25rem;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  border: 2px solid rgba(245,158,11,0.4);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-brand h2 { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }
.sidebar-brand span { font-size: 0.72rem; color: var(--text-accent); font-weight: 500; }

.sidebar-close-btn {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.2rem;
  transition: color var(--transition);
}
.sidebar-close-btn:hover { color: var(--text-primary); }

/* User Info */
.sidebar-user {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.user-info { overflow: hidden; }
.user-info .name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info .role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Navigation */
nav.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

nav.sidebar-nav::-webkit-scrollbar { width: 4px; }
nav.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.75rem 0.75rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
  border: 1px solid transparent;
  user-select: none;
  text-decoration: none;
}

.nav-item i {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
  color: var(--text-muted);
  transition: color var(--transition);
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}

.nav-item:hover i { color: var(--accent-light); }

.nav-item.active {
  background: rgba(99,102,241,0.12);
  color: var(--accent-light);
  border-color: rgba(99,102,241,0.25);
}

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

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.75rem;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-logout:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
  color: var(--red);
}

/* Sidebar overlay */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  backdrop-filter: blur(2px);
}

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

/* ---- Topbar ---- */
#topbar {
  height: var(--topbar-h);
  background: rgba(13, 20, 36, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 80;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.hamburger-btn {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 38px; height: 38px;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
}
.hamburger-btn:hover { color: var(--text-primary); background: var(--bg-surface); }

.topbar-school {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.topbar-page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.topbar-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.9rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--emerald);
}

.topbar-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
  letter-spacing: 0.04em;
}

/* ---- Page Content ---- */
main#content {
  flex: 1;
  padding: 1.75rem;
  overflow-x: hidden;
}

/* App pages */
.app-page { display: none; }
.app-page.active { display: block; animation: pageFadeIn 0.25s ease; }

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

/* ============================================
   DASHBOARD CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-gradient, linear-gradient(90deg, var(--accent), var(--accent-light)));
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  border-color: var(--border-glow);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.indigo  { background: rgba(99,102,241,0.15); color: var(--accent-light); }
.stat-icon.emerald { background: var(--emerald-dim); color: var(--emerald); }
.stat-icon.yellow  { background: var(--yellow-dim); color: var(--yellow); }
.stat-icon.cyan    { background: var(--cyan-dim); color: var(--cyan); }

.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.04em;
}
.stat-sub {
  font-size: 0.72rem;
  color: var(--emerald);
  margin-top: 0.2rem;
  font-weight: 600;
}

/* Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg,
    rgba(13,20,36,0.9) 0%,
    rgba(30,40,68,0.85) 50%,
    rgba(17,24,39,0.9) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,0.1), transparent 70%);
  border-radius: 50%;
  top: -100px; right: -100px;
  pointer-events: none;
}

.welcome-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}
.welcome-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  line-height: 1.6;
  max-width: 500px;
}

/* ============================================
   CONTENT CARDS & TABLES
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.card-title i { color: var(--accent); }

.card-body { padding: 1.5rem; }

/* Table */
.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.835rem;
}

table.data-table thead tr {
  background: rgba(6, 11, 20, 0.5);
  border-bottom: 1px solid var(--border);
}

table.data-table thead th {
  padding: 0.9rem 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

table.data-table tbody tr {
  border-bottom: 1px solid rgba(99, 118, 160, 0.08);
  transition: background var(--transition);
}

table.data-table tbody tr:hover { background: rgba(99,102,241,0.04); }
table.data-table tbody tr:last-child { border-bottom: none; }

table.data-table td {
  padding: 0.9rem 1rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

table.data-table td.text-white { color: var(--text-primary); font-weight: 600; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-masuk  { background: rgba(99,102,241,0.15); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.2); }
.badge-keluar { background: var(--emerald-dim); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.2); }
.badge-kat    { background: var(--bg-elevated); color: var(--text-accent); border: 1px solid var(--border); }

/* ---- Toolbar ---- */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar-left  { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* ---- Search & Filter Inputs ---- */
.search-input, .filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input { padding-left: 2.5rem; min-width: 220px; }
.search-input::placeholder { color: var(--text-muted); }

.search-wrap { position: relative; }
.search-wrap i {
  position: absolute;
  left: 0.9rem;
  top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-input:focus,
.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-select option { background: var(--bg-card); }

/* ---- Action Buttons Group ---- */
.action-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-view {
  background: rgba(99,102,241,0.1);
  color: var(--accent-light);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.btn-view:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-qr {
  background: rgba(245,158,11,0.1);
  color: var(--yellow);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-qr:hover { background: var(--yellow); color: #000; border-color: var(--yellow); }

.btn-edit {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-edit:hover { background: var(--bg-surface); color: var(--text-primary); }

.btn-delete {
  background: rgba(239,68,68,0.08);
  color: rgba(239,68,68,0.8);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-delete:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-deep);
  animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal-box.modal-lg { max-width: 820px; }
.modal-box.modal-sm { max-width: 400px; }

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(6,11,20,0.4);
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.modal-title i { color: var(--accent); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  transition: color var(--transition);
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(6,11,20,0.3);
}

/* Form grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* File upload area */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(6,11,20,0.3);
}
.file-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.file-upload-area i { font-size: 1.5rem; color: var(--text-muted); }
.file-upload-area .file-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; }

/* File attached state */
.file-upload-area.has-file {
  border-color: var(--emerald);
  background: var(--emerald-dim);
}
.file-upload-area.has-file i { color: var(--emerald); }
.file-upload-area.has-file .file-label { color: var(--emerald); }

/* ---- Preview Modal ---- */
.preview-area {
  flex: 1;
  background: #0a0f1a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-height: 400px;
}

#previewIframe {
  width: 100%; height: 100%; border: none;
  border-radius: var(--radius-md);
  min-height: 500px;
}

#previewImage {
  max-width: 100%; max-height: 500px;
  border-radius: var(--radius-md);
  object-fit: contain;
  box-shadow: var(--shadow-deep);
}

/* Simulated document (official letter) */
.simulated-doc {
  background: #fff;
  color: #1e293b;
  padding: 3rem;
  border-radius: var(--radius-md);
  max-width: 680px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  font-family: 'Times New Roman', serif;
}

/* QR Modal */
.qr-box {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 1rem;
  display: inline-block;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ============================================
   LOADING
   ============================================ */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(99,102,241,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
.loading-overlay.show { display: flex; }

/* Page section loader */
.section-loader {
  display: none;
  padding: 4rem 2rem;
  text-align: center;
}
.section-loader.show { display: block; }
.section-loader p { color: var(--text-muted); font-size: 0.85rem; margin-top: 1rem; }

/* Empty state */
.empty-state {
  padding: 4rem 2rem;
  text-align: center;
}
.empty-state i { font-size: 3rem; color: var(--text-muted); margin-bottom: 1rem; display: block; }
.empty-state h4 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.82rem; color: var(--text-muted); }

/* ============================================
   UTILITY
   ============================================ */
.d-none { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-1 { margin-top: 0.4rem; }
.mt-2 { margin-top: 0.75rem; }
.mt-3 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: 0.4rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1.25rem; }
.mb-4 { margin-bottom: 1.75rem; }
.gap-1 { gap: 0.4rem; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

.file-attach-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-accent);
  margin-top: 0.3rem;
}
.no-file { color: var(--text-muted); }

/* Log page */
.log-action {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* Category list */
.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  transition: background var(--transition);
}
.cat-item:hover { background: rgba(99,102,241,0.05); }
.cat-item + .cat-item { border-top: 1px solid var(--border); }

/* ============================================
   SCROLL BAR GLOBAL
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,118,160,0.35); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  #sidebar {
    transform: translateX(-260px);
    width: 260px;
    box-shadow: var(--shadow-deep);
  }

  #sidebar.open { transform: translateX(0); }

  #sidebarOverlay.show { display: block; }

  .main-wrapper { margin-left: 0; }

  .hamburger-btn { display: flex; }
  .sidebar-close-btn { display: flex; }

  .topbar-time { display: none; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .welcome-banner { flex-direction: column; text-align: center; }
  .welcome-banner .btn-primary { width: 100%; }

  .form-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  main#content { padding: 1rem; }

  .stats-grid { grid-template-columns: 1fr; }

  .page-toolbar { flex-direction: column; align-items: stretch; }

  .toolbar-left, .toolbar-right { width: 100%; }

  .search-input { min-width: unset; width: 100%; }

  .modal-box.modal-lg { max-width: 100%; }

  #topbar { padding: 0 1rem; }
}

/* Print */
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    position: absolute; left: 0; top: 0;
    width: 100%; text-align: center;
  }
}
