/* ============================================================
   LMS ERP - Premium UI Stylesheet
   Theme: Dark Blue Enterprise | Font: Syne + DM Sans
   ============================================================ */

/* ── CSS Variables ── */
:root {
  --bg-base:       #060B18;
  --bg-surface:    #0D1525;
  --bg-card:       #111827;
  --bg-elevated:   #1A2235;
  --bg-hover:      #1E293B;
  --border:        #1E2D45;
  --border-light:  #243350;

  --primary:       #2563EB;
  --primary-light: #3B82F6;
  --primary-dark:  #1D4ED8;
  --primary-glow:  rgba(37,99,235,0.25);
  --primary-dim:   rgba(37,99,235,0.1);

  --accent:        #10B981;
  --accent-light:  #34D399;
  --accent-dim:    rgba(16,185,129,0.12);

  --warning:       #F59E0B;
  --warning-dim:   rgba(245,158,11,0.12);
  --danger:        #EF4444;
  --danger-dim:    rgba(239,68,68,0.12);
  --info:          #06B6D4;
  --info-dim:      rgba(6,182,212,0.12);
  --purple:        #8B5CF6;
  --purple-dim:    rgba(139,92,246,0.12);

  --text-primary:  #F1F5F9;
  --text-secondary:#94A3B8;
  --text-muted:    #475569;
  --text-inverse:  #0F172A;

  --sidebar-w:     260px;
  --topbar-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --radius-xl:     20px;
  --radius-full:   9999px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow:        0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow:   0 0 24px rgba(37,99,235,0.3);

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

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

[data-theme="light"] {
  --bg-base:       #F8FAFC;
  --bg-surface:    #FFFFFF;
  --bg-card:       #FFFFFF;
  --bg-elevated:   #F1F5F9;
  --bg-hover:      #F8FAFC;
  --border:        #E2E8F0;
  --border-light:  #CBD5E1;
  --text-primary:  #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;
  --shadow:        0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--primary-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }

img { max-width: 100%; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-body); }

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

/* ============================================================
   LAYOUT
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition-slow);
  overflow: hidden;
}

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

/* ── Sidebar Brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon svg { width: 38px; height: 38px; }

.brand-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-tagline {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: -1px;
}

.sidebar-close {
  display: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  align-items: center;
  justify-content: center;
}

/* ── Sidebar Nav ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 0;
}

.nav-section {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 14px 10px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  margin-bottom: 2px;
}

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

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

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 10px; }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.875rem;
  color: white;
  flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-weight: 600; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
}
.hamburger span { display: block; width: 20px; height: 2px; background: var(--text-secondary); border-radius: 2px; transition: var(--transition); }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.bc-home { color: var(--text-muted); font-family: var(--font-display); font-weight: 600; }
.bc-sep { color: var(--text-muted); }
.bc-current { color: var(--text-primary); font-weight: 500; }

/* ── Global Search ── */
.global-search {
  position: relative;
  width: 300px;
}

.global-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  padding: 8px 16px 8px 38px;
  font-size: 0.82rem;
  transition: all var(--transition);
  outline: none;
}

.global-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}

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

.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.82rem;
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  display: none;
  z-index: 500;
}

.search-dropdown.visible { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-hover); }
.sri-cover { width: 32px; height: 40px; background: var(--bg-elevated); border-radius: 4px; object-fit: cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.sri-info { flex: 1; min-width: 0; }
.sri-title { font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sri-sub { font-size: 0.72rem; color: var(--text-muted); }
.sri-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 99px; flex-shrink: 0; }
.badge-avail { background: var(--accent-dim); color: var(--accent-light); }
.badge-unavail { background: var(--danger-dim); color: var(--danger); }

/* ── Icon Button ── */
.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  border: 2px solid var(--bg-surface);
}

/* ── Notification Panel ── */
.notif-wrap { position: relative; }

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 500;
}

.notif-panel.visible { display: block; animation: popIn 0.2s ease; }

@keyframes popIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.notif-header h4 { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; }
.mark-all-read { font-size: 0.72rem; color: var(--primary-light); }

.notif-list { max-height: 320px; overflow-y: auto; }

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--primary-dim); }
.notif-icon { font-size: 1.2rem; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 0.8rem; font-weight: 600; }
.notif-msg { font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; }
.notif-empty { text-align: center; padding: 30px; color: var(--text-muted); font-size: 0.82rem; }

/* ── User Menu ── */
.user-menu-wrap { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background var(--transition);
}
.user-menu-btn:hover { background: var(--bg-hover); }

.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  color: white;
}

.topbar-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  display: none;
  z-index: 500;
  overflow: hidden;
}

.user-dropdown.visible { display: block; animation: popIn 0.2s ease; }

.dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.dropdown-header strong { font-size: 0.85rem; }
.dropdown-header small { font-size: 0.72rem; color: var(--text-muted); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger:hover { background: var(--danger-dim); color: var(--danger); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px;
}

.page-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left { flex: 1; }
.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.page-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }
.page-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.blue::before   { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.stat-card.amber::before  { background: linear-gradient(90deg, #D97706, var(--warning)); }
.stat-card.red::before    { background: linear-gradient(90deg, #DC2626, var(--danger)); }
.stat-card.purple::before { background: linear-gradient(90deg, #7C3AED, var(--purple)); }
.stat-card.cyan::before   { background: linear-gradient(90deg, #0891B2, var(--info)); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 14px;
}
.stat-card.blue   .stat-icon { background: var(--primary-dim); }
.stat-card.green  .stat-icon { background: var(--accent-dim); }
.stat-card.amber  .stat-icon { background: var(--warning-dim); }
.stat-card.red    .stat-icon { background: var(--danger-dim); }
.stat-card.purple .stat-icon { background: var(--purple-dim); }
.stat-card.cyan   .stat-icon { background: var(--info-dim); }

.stat-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.04em;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.stat-trend {
  font-size: 0.72rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.trend-up   { color: var(--accent); }
.trend-down { color: var(--danger); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  background: var(--bg-elevated);
  padding: 11px 14px;
  text-align: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--bg-hover); color: var(--text-primary); }

.td-primary { font-weight: 600; color: var(--text-primary) !important; }
.td-link { color: var(--primary-light) !important; cursor: pointer; }
.td-link:hover { color: var(--primary) !important; text-decoration: underline; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-primary  { background: var(--primary-dim);  color: var(--primary-light); }
.badge-success  { background: var(--accent-dim);   color: var(--accent-light); }
.badge-warning  { background: var(--warning-dim);  color: var(--warning); }
.badge-danger   { background: var(--danger-dim);   color: var(--danger); }
.badge-info     { background: var(--info-dim);     color: var(--info); }
.badge-purple   { background: var(--purple-dim);   color: var(--purple); }
.badge-neutral  { background: var(--bg-elevated);  color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
}
.btn:active::after { opacity: 0.08; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(37,99,235,0.4);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-glow); color: white; }
.btn-primary.success { background: var(--accent); }

.btn-accent   { background: var(--accent); color: white; }
.btn-accent:hover { background: #059669; color: white; }

.btn-outline  { background: transparent; border: 1px solid var(--border-light); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); background: var(--primary-dim); }

.btn-danger   { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; color: white; }

.btn-ghost { background: var(--bg-hover); color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }

.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover { background: #D97706; }

.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-lg { padding: 12px 28px; font-size: 0.92rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-loader { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ── Forms ── */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.input-wrap { position: relative; }

.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 1;
}

.input-wrap input { padding-left: 38px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.85rem;
  transition: all var(--transition);
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

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

.form-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  cursor: pointer;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.form-check label { font-size: 0.8rem; color: var(--text-secondary); cursor: pointer; margin: 0; }

.form-error { font-size: 0.72rem; color: var(--danger); margin-top: 4px; }
.form-hint  { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.toggle-pw {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.toggle-pw:hover { opacity: 1; }

/* ── Filters Bar ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.filter-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  position: relative;
}
.filter-input input { padding-left: 36px; background: var(--bg-card); }
.filter-input .fi-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 0.82rem; }

.filter-select { width: 160px; background: var(--bg-card) !important; }
.filter-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
}

.pagination-info { font-size: 0.78rem; color: var(--text-muted); }

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--primary); color: white; font-weight: 600; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Alert ── */
.alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  font-size: 0.82rem;
  border-left: 3px solid;
  margin: 0 28px 16px;
  border-radius: var(--radius-sm);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-light); }
.alert-danger  { background: var(--danger-dim);  border-color: var(--danger);  color: var(--danger); }
.alert-warning { background: var(--warning-dim); border-color: var(--warning); color: var(--warning); }
.alert-info    { background: var(--info-dim);    border-color: var(--info);    color: var(--info); }
.alert-close   { background: none; font-size: 0.9rem; opacity: 0.7; flex-shrink: 0; margin-top: -1px; }
.alert-close:hover { opacity: 1; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  min-width: 280px;
  max-width: 360px;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 3px solid;
}
.toast.removing { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(60px); } }

.toast-success { border-left-color: var(--accent); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--info); }
.toast-icon    { font-size: 1rem; flex-shrink: 0; }
.toast-msg     { flex: 1; color: var(--text-primary); font-weight: 500; }
.toast-close   { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; }
.toast-close:hover { color: var(--text-primary); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.93) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Charts Container ── */
.chart-container {
  position: relative;
  width: 100%;
}
.chart-container canvas { max-width: 100%; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }

/* ── Avatar & member cards ── */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  overflow: hidden;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.78rem; }
.avatar-md { width: 44px; height: 44px; font-size: 1rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 90px; height: 90px; font-size: 1.8rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.member-row { display: flex; align-items: center; gap: 12px; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-id   { font-size: 0.72rem; color: var(--text-muted); font-family: monospace; }

/* ── Book card (catalog) ── */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}
.book-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }

.book-cover {
  height: 160px;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-hover));
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-avail-tag {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.62rem;
  padding: 3px 7px;
  border-radius: 99px;
  font-weight: 700;
}

.book-info { padding: 14px; }
.book-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; line-height: 1.3; }
.book-author { font-size: 0.72rem; color: var(--text-muted); }
.book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.book-isbn { font-size: 0.65rem; color: var(--text-muted); font-family: monospace; }
.book-copies-badge { font-size: 0.68rem; font-weight: 600; }

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 2px;
  margin-bottom: 24px;
}
.tab-btn {
  padding: 10px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Progress & overdue indicator ── */
.overdue-days {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
}
.overdue-days.ok   { color: var(--accent); }
.overdue-days.warn { color: var(--warning); }
.overdue-days.crit { color: var(--danger); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-text  { font-size: 0.82rem; color: var(--text-muted); max-width: 300px; margin: 0 auto 20px; }

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Barcode / QR display ── */
.barcode-display {
  font-family: 'Libre Barcode 39', monospace;
  font-size: 1.8rem;
  letter-spacing: 2px;
  text-align: center;
  padding: 8px;
}

/* ── Receipt / Print ── */
.receipt-wrap {
  max-width: 380px;
  margin: 0 auto;
  background: white;
  color: #111;
  padding: 24px;
  font-size: 0.82rem;
  border-radius: var(--radius);
}
.receipt-title { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; text-align: center; margin-bottom: 4px; }
.receipt-row { display: flex; justify-content: space-between; padding: 4px 0; }
.receipt-divider { border-top: 1px dashed #aaa; margin: 10px 0; }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-body { min-height: 100vh; display: flex; align-items: stretch; background: var(--bg-base); }

.auth-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; width: 100%; }

.auth-left {
  background: linear-gradient(140deg, #0F172A 0%, #0B1426 60%, #051020 100%);
  padding: 60px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-left-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(16,185,129,0.08) 0%, transparent 50%);
  pointer-events: none;
}

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

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 52px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.auth-headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #F1F5F9 30%, #64748B);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle { font-size: 0.92rem; color: var(--text-muted); line-height: 1.6; max-width: 380px; margin-bottom: 40px; }

.auth-features { display: flex; flex-direction: column; gap: 18px; margin-bottom: 44px; }

.auth-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.af-icon { font-size: 1.3rem; margin-top: 2px; flex-shrink: 0; }
.auth-feature strong { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.auth-feature p { font-size: 0.78rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

.auth-stats {
  display: flex;
  gap: 28px;
  padding-top: 28px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.auth-stat strong { display: block; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; color: var(--text-primary); }
.auth-stat span   { font-size: 0.72rem; color: var(--text-muted); }

/* Auth Right */
.auth-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-surface);
}

.auth-form-wrap { width: 100%; max-width: 420px; }

.auth-form-header { margin-bottom: 32px; }
.auth-form-header h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}
.auth-form-header p { font-size: 0.85rem; color: var(--text-muted); }

.forgot-link { font-size: 0.72rem; font-weight: 400; }

.demo-creds {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}
.demo-creds p { margin-bottom: 4px; }
.demo-creds code { background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; color: var(--accent-light); font-family: monospace; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.welcome-banner {
  background: linear-gradient(120deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}
.welcome-banner::after {
  content: '📚';
  position: absolute;
  right: -10px;
  top: -20px;
  font-size: 8rem;
  opacity: 0.05;
}
.wb-greeting { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
.wb-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
}
.wb-date { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.wb-actions { display: flex; gap: 10px; position: relative; z-index: 1; }

/* ── Activity Table ── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; }
.ai-issue  { background: var(--primary-dim); }
.ai-return { background: var(--accent-dim); }
.ai-fine   { background: var(--danger-dim); }
.activity-text { flex: 1; }
.activity-text strong { font-weight: 600; color: var(--text-primary); }
.activity-meta { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   ISSUE FORM PAGE
   ============================================================ */
.issue-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

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

.scan-btn {
  flex-shrink: 0;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.scan-btn:hover { border-color: var(--primary); color: var(--primary-light); }

.selected-book-card,
.selected-member-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 10px;
  animation: slideDown 0.2s ease;
}

.sbc-hidden { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .grid-2, .grid-3, .form-row-3 { grid-template-columns: 1fr 1fr; }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .issue-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close { display: flex; }

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

  .auth-split { grid-template-columns: 1fr; }
  .auth-left { display: none; }
  .auth-right { padding: 32px 24px; }

  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }

  .global-search { width: 180px; }
  .topbar-name { display: none; }

  .grid-2, .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-input { max-width: 100%; }
  .filter-select { width: 100%; }
  .filter-actions { margin-left: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 1.2rem; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { min-width: auto; }
  .global-search { display: none; }
}

/* ── Print Styles ── */
@media print {
  .sidebar, .topbar, .page-footer, .btn, .filters-bar { display: none !important; }
  .main-wrapper { margin: 0; }
  .page-content { padding: 0; }
  .card { border: 1px solid #ddd; }
  body { background: white; color: black; }
}
