/* ==========================================================================
   Aplikasi Tahfidz Pondok — Annur 2 Al-Murtadlo
   ========================================================================== */

:root {
  --primary: #059669;
  --primary-600: #047857;
  --primary-700: #065f46;
  --primary-800: #064e3b;
  --primary-900: #022c22;
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --accent: #f59e0b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success-bg: #f0fdf4;
  --info-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(2, 6, 23, 0.08), 0 1px 2px rgba(2, 6, 23, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(2, 6, 23, 0.12), 0 8px 10px -6px rgba(2, 6, 23, 0.06);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--primary-800), var(--primary-900));
  color: #d1fae5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}

.brand-name { font-size: 15px; font-weight: 700; line-height: 1.25; color: #fff; }
.brand-sub { font-size: 11px; color: #a7f3d0; opacity: 0.8; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(167, 243, 208, 0.55);
  padding: 10px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: #d1fae5;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--primary-600); color: #fff; font-weight: 600; box-shadow: var(--shadow); }
.nav-link svg { flex-shrink: 0; opacity: 0.9; }

.sidebar-footer { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,0.08); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  margin-bottom: 10px;
}

.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.user-chip .user-name { font-size: 13px; color: #fff; font-weight: 600; line-height: 1.2; }
.user-chip .user-role { font-size: 11px; color: #a7f3d0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.burger { display: none; background: none; border: none; cursor: pointer; padding: 6px; border-radius: 6px; }
.burger:hover { background: var(--primary-50); }
.burger svg { display: block; }

.topbar-title { font-size: 16px; font-weight: 600; margin: 0; }

.content { padding: 24px; flex: 1; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-title { margin: 0; font-size: 22px; font-weight: 700; }
.page-sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  background: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(0.96); }
.btn svg { flex-shrink: 0; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); color: #fff; }

.btn-outline { background: var(--surface); color: var(--primary-700); border-color: #a7f3d0; }
.btn-outline:hover { background: var(--primary-50); color: var(--primary-800); }

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

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger-outline:hover { background: var(--danger-bg); color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.green { background: var(--primary-100); color: var(--primary-700); }
.stat-icon.amber { background: #fef3c7; color: #b45309; }
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.violet { background: #ede9fe; color: #6d28d9; }

.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.cell-actions { display: flex; gap: 6px; white-space: nowrap; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--primary-50); color: var(--primary-700); border-color: #a7f3d0; text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: var(--primary-100); color: var(--primary-700); }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-label .req { color: var(--danger); }

.form-control,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.form-textarea { resize: vertical; min-height: 90px; }

.form-hint { font-size: 12px; color: var(--muted); }
.form-error { font-size: 12px; color: var(--danger); }

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  background: #fff;
}
.fieldset > legend {
  font-weight: 700;
  font-size: 14px;
  padding: 0 8px;
  color: var(--primary-700);
}

.radio-row { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 4px; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(16, 185, 129, 0.25), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(245, 158, 11, 0.18), transparent 60%),
    linear-gradient(180deg, #022c22, #064e3b 60%, #065f46);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 26px;
  text-align: center;
}
.auth-brand .logo-big {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-lg);
}
.auth-brand h1 { font-size: 20px; margin: 0; color: var(--primary-900); }
.auth-brand p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Progress ---------- */
.progress-track {
  height: 10px;
  background: var(--primary-100);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #34d399);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.juz-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.juz-pill {
  min-width: 40px;
  padding: 6px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
}
.juz-pill.done { background: var(--primary-100); color: var(--primary-700); }
.juz-pill.empty { background: #f1f5f9; color: #cbd5e1; }

/* ---------- Misc ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }

.avatar-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-700);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.pagination { display: flex; justify-content: flex-end; padding: 14px 16px; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
}
.pagination a:hover { background: var(--primary-50); border-color: #a7f3d0; text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

.meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }

.login-hint {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--primary-50);
  border: 1px dashed #6ee7b7;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--primary-700);
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .burger { display: inline-flex; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(2, 44, 34, 0.5);
    z-index: 35;
  }
  .overlay.show { display: block; }
}

@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
