/* =====================================================
   Aplikasi Penilaian & Jurnal Guru
   Custom Stylesheet v2.0 — Sidebar Layout
   ===================================================== */

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

:root {
  --sidebar-width:    250px;
  --sidebar-bg:       #1a2332;
  --sidebar-active:   #3b82f6;
  --sidebar-hover:    rgba(255,255,255,.07);
  --sidebar-text:     rgba(255,255,255,.78);
  --sidebar-subtext:  rgba(255,255,255,.55);
  --topbar-h:         56px;
  --apj-primary:      #3b82f6;
  --apj-success:      #22c55e;
  --apj-warning:      #f59e0b;
  --apj-danger:       #ef4444;
  --apj-info:         #06b6d4;
  --apj-bg:           #f1f5f9;
  --apj-card:         #ffffff;
  --apj-shadow:       0 2px 12px rgba(0,0,0,.08);
  --apj-radius:       0.75rem;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--apj-bg);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  margin: 0;
  overflow-x: hidden;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .25s ease, width .25s ease;
  overflow: hidden;
  box-shadow: 3px 0 20px rgba(0,0,0,.18);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,.2);
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: var(--topbar-h);
}
.sidebar-brand i { font-size: 1.3rem; color: var(--apj-primary); flex-shrink: 0; }
.sidebar-brand span { overflow: hidden; text-overflow: ellipsis; }

/* Nav area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* Direct link */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-radius: 0;
  white-space: nowrap;
}
.sidebar-link i { width: 18px; text-align: center; flex-shrink: 0; font-size: .95rem; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active {
  background: var(--apj-primary);
  color: #fff;
  box-shadow: inset 3px 0 0 rgba(255,255,255,.4);
}

/* Group toggle */
.sidebar-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1.25rem;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-group-toggle > span { display: flex; align-items: center; gap: .75rem; }
.sidebar-group-toggle > span i { width: 18px; text-align: center; flex-shrink: 0; font-size: .95rem; }
.sidebar-group-toggle:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-group-toggle .arrow { font-size: .7rem; opacity: .7; transition: transform .2s; flex-shrink: 0; }

/* Sub links */
.sidebar-sub-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem 1.25rem .45rem 3rem;
  color: var(--sidebar-subtext);
  text-decoration: none;
  font-size: .82rem;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-sub-link i { width: 16px; text-align: center; flex-shrink: 0; font-size: .85rem; }
.sidebar-sub-link:hover { background: var(--sidebar-hover); color: #fff; }

/* Sidebar footer / user */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .85rem 1.25rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.sidebar-user-avatar {
  font-size: 1.8rem;
  color: var(--apj-primary);
  flex-shrink: 0;
  line-height: 1;
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name {
  font-size: .82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: .72rem;
  color: var(--sidebar-subtext);
  text-transform: capitalize;
}
.sidebar-user .btn-link { color: var(--sidebar-subtext) !important; }
.sidebar-user .btn-link:hover { color: #fff !important; }

/* Collapsed state */
.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
.sidebar-overlay.active { display: block; }

/* ========================================
   MAIN WRAPPER
   ======================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}
.main-wrapper.expanded { margin-left: 0; }

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}
.topbar-toggle {
  color: #64748b;
  padding: .3rem .5rem;
  font-size: 1.1rem;
  border-radius: .4rem;
  flex-shrink: 0;
}
.topbar-toggle:hover { background: #f1f5f9; color: #1e293b; }
.topbar-title {
  font-size: .95rem;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { margin-left: auto; flex-shrink: 0; }

/* Main Content */
.main-content { flex: 1; }

/* App Footer */
.app-footer {
  background: #fff;
  border-top: 1px solid #e5e9f0;
  padding: .75rem 1.5rem;
  font-size: .78rem;
  color: #94a3b8;
  margin-left: var(--sidebar-width);
  transition: margin-left .25s ease;
}
.main-wrapper.expanded ~ .app-footer { margin-left: 0; }

/* ========================================
   CARDS
   ======================================== */
.card {
  border: none;
  border-radius: var(--apj-radius);
  box-shadow: var(--apj-shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.card-header { border-radius: var(--apj-radius) var(--apj-radius) 0 0 !important; font-weight: 600; }

/* ---- Stat Cards ---- */
.stat-card { border-radius: var(--apj-radius); color: #fff; padding: 1.2rem; }
.stat-card .stat-icon { font-size: 2.2rem; opacity: .85; }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label  { font-size: .8rem; opacity: .9; margin-top: 4px; }

/* ---- Tables ---- */
.table { font-size: 13px; }
.table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  color: #495057;
  white-space: nowrap;
}
.table tbody tr:hover { background: #f0f7ff; }
.table-sm td, .table-sm th { padding: .35rem .5rem; }

/* ---- Badges ---- */
.badge { font-size: .72rem; font-weight: 500; padding: .3em .6em; }

/* ---- Forms ---- */
.form-control, .form-select {
  border-radius: .5rem;
  border: 1.5px solid #ced4da;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--apj-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-label { font-weight: 500; color: #495057; margin-bottom: .3rem; }

/* ---- Buttons ---- */
.btn { border-radius: .5rem; font-weight: 500; }
.btn-sm { font-size: .78rem; }

/* ---- Page Header ---- */
.page-header {
  background: linear-gradient(135deg, var(--apj-primary) 0%, #1d4ed8 100%);
  color: #fff;
  border-radius: var(--apj-radius);
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--apj-shadow);
}
.page-header h4 { margin: 0; font-weight: 700; }
.page-header p  { margin: .2rem 0 0; font-size: .85rem; opacity: .85; }

/* ---- Presensi Grid ---- */
.presensi-grid { overflow-x: auto; }
.presensi-grid table { min-width: 900px; font-size: 11px; }
.presensi-grid td, .presensi-grid th { padding: .2rem .3rem; text-align: center; }
.ps-H  { background: #d1e7dd; color: #0a3622; font-weight: 600; }
.ps-S  { background: #fff3cd; color: #664d03; font-weight: 600; }
.ps-I  { background: #cff4fc; color: #055160; font-weight: 600; }
.ps-A  { background: #f8d7da; color: #58151c; font-weight: 600; }
.ps-TK { background: #e2e3e5; color: #41464b; font-weight: 600; }

/* ---- Status badges ---- */
.badge-tuntas { background: #d1e7dd; color: #0a3622; border-radius: .4rem; padding: .2em .5em; font-size: .72rem; }
.badge-belum  { background: #f8d7da; color: #58151c; border-radius: .4rem; padding: .2em .5em; font-size: .72rem; }

/* ---- Input Nilai ---- */
.nilai-input { width: 75px; text-align: center; padding: .2rem .3rem !important; }
.nilai-input:disabled { background: #f8f9fa !important; }
.remedial-input { width: 75px; text-align: center; padding: .2rem .3rem !important; }

/* ---- Jurnal Status ---- */
.jurnal-draft     { border-left: 4px solid #6c757d; }
.jurnal-submitted { border-left: 4px solid #3b82f6; }
.jurnal-verified  { border-left: 4px solid #22c55e; }
.jurnal-rejected  { border-left: 4px solid #ef4444; }

/* ---- Login Page ---- */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}
.login-logo { font-size: 3rem; color: var(--apj-primary); }

/* ========================================
   RESPONSIVE — Mobile
   ======================================== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.collapsed { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .main-wrapper.expanded { margin-left: 0; }
  .app-footer { margin-left: 0; }
  .stat-card .stat-number { font-size: 1.5rem; }
  .page-header { padding: .8rem 1rem; }
  .table-responsive { font-size: 12px; }
  .nilai-input, .remedial-input { width: 60px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #888; }

/* ---- Toast ---- */
.toast-container { z-index: 9999; }

/* ---- Loading Spinner ---- */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
}

/* ---- Chart container ---- */
.chart-container { position: relative; }

/* ---- Print ---- */
@media print {
  .sidebar, .topbar, .btn, .page-header .btn, .app-footer { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
  body { background: white; }
}

/* ========================================
   THEMES
   ======================================== */
.theme-emerald {
  --apj-primary: #10b981;
  --sidebar-bg: #064e3b;
  --sidebar-active: #059669;
}
.theme-emerald .page-header { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.theme-emerald .btn-primary { background-color: #10b981; border-color: #10b981; }
.theme-emerald .btn-primary:hover { background-color: #059669; border-color: #059669; }
.theme-emerald .text-primary { color: #10b981 !important; }

.theme-violet {
  --apj-primary: #8b5cf6;
  --sidebar-bg: #4c1d95;
  --sidebar-active: #7c3aed;
}
.theme-violet .page-header { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }
.theme-violet .btn-primary { background-color: #8b5cf6; border-color: #8b5cf6; }
.theme-violet .btn-primary:hover { background-color: #7c3aed; border-color: #7c3aed; }
.theme-violet .text-primary { color: #8b5cf6 !important; }

.theme-midnight {
  --apj-primary: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-active: #1e293b;
  --apj-bg: #1e293b;
  --apj-card: #0f172a;
}
.theme-midnight body { background: var(--apj-bg); color: #e2e8f0; }
.theme-midnight .card { background: var(--apj-card); color: #e2e8f0; border: 1px solid #334155; }
.theme-midnight .topbar { background: var(--apj-card); border-bottom: 1px solid #334155; }
.theme-midnight .topbar-title { color: #f8fafc; }
.theme-midnight .table thead th { background: #1e293b; color: #f8fafc; border-bottom: 2px solid #334155; }
.theme-midnight .table tbody tr td, .theme-midnight .table tbody tr th { color: #e2e8f0; border-bottom: 1px solid #334155; }
.theme-midnight .table tbody tr:hover { background: #334155; }
.theme-midnight .form-label { color: #cbd5e1; }
.theme-midnight .form-control, .theme-midnight .form-select { background: #1e293b; color: #f8fafc; border: 1px solid #334155; }
.theme-midnight .form-control:focus, .theme-midnight .form-select:focus { background: #1e293b; color: #fff; border-color: #475569; }
.theme-midnight .page-header { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); border: 1px solid #334155; }
.theme-midnight .btn-primary { background-color: #3b82f6; border-color: #3b82f6; color: #fff; }
.theme-midnight .btn-primary:hover { background-color: #2563eb; }


/* ----- Explicit theme overrides (fallback for browsers that may not inherit vars) ----- */
.theme-emerald .sidebar { background: #064e3b !important; }
.theme-emerald .sidebar-link.active { background: #10b981 !important; }
.theme-emerald .topbar { background: #10b981 !important; }
.theme-emerald .btn-primary { background-color: #10b981 !important; border-color: #10b981 !important; }
.theme-emerald .btn-primary:hover { background-color: #059669 !important; border-color: #059669 !important; }

.theme-violet .sidebar { background: #4c1d95 !important; }
.theme-violet .sidebar-link.active { background: #8b5cf6 !important; }
.theme-violet .topbar { background: #8b5cf6 !important; }
.theme-violet .btn-primary { background-color: #8b5cf6 !important; border-color: #8b5cf6 !important; }
.theme-violet .btn-primary:hover { background-color: #7c3aed !important; border-color: #7c3aed !important; }

.theme-midnight .sidebar { background: #0f172a !important; }
.theme-midnight .sidebar-link.active { background: #3b82f6 !important; }
.theme-midnight .topbar { background: #1e293b !important; }
.theme-midnight .btn-primary { background-color: #3b82f6 !important; border-color: #3b82f6 !important; }
.theme-midnight .btn-primary:hover { background-color: #2563eb !important; }

  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}
.login-wrapper.has-bg::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); /* darken overlay */
}
.login-wrapper.has-bg .login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.15) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  z-index: 10;
}
.login-wrapper.has-bg .login-card h5,
.login-wrapper.has-bg .login-card p,
.login-wrapper.has-bg .login-card label,
.login-wrapper.has-bg .login-card .text-muted,
.login-wrapper.has-bg .login-card .login-logo {
  color: #fff !important;
}
.login-wrapper.has-bg .login-card .form-control {
  background: rgba(255,255,255,0.85);
  border: none;
}
