/* ============================================================
   LMS MA Mathla'ul Anwar Kedondong
   Theme: Hijau · Putih · Emas
   ============================================================ */
:root {
  --ma-green: #0d5c2e;
  --ma-green-dark: #0a3d1f;
  --ma-green-light: #1a7a42;
  --ma-gold: #c9a227;
  --ma-gold-light: #e8c84a;
  --ma-gold-dark: #a6851f;
  --ma-white: #ffffff;
  --ma-bg: #f4f7f5;
  --ma-card: #ffffff;
  --ma-text: #1a2e22;
  --ma-muted: #6b7c72;
  --ma-border: #dce8e0;
  --ma-sidebar: #0a3d1f;
  --ma-sidebar-w: 260px;
  --ma-topbar-h: 64px;
  --ma-radius: 12px;
  --ma-shadow: 0 4px 20px rgba(13, 92, 46, 0.08);
  --ma-font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
}

[data-theme="dark"] {
  --ma-bg: #0d1a12;
  --ma-card: #142419;
  --ma-text: #e8f0eb;
  --ma-muted: #8fa396;
  --ma-border: #1e3a28;
  --ma-sidebar: #06140c;
  --ma-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--ma-font);
  background: var(--ma-bg);
  color: var(--ma-text);
  margin: 0;
  min-height: 100vh;
  line-height: 1.6;
}

/* ---- Public Landing ---- */
.ma-navbar {
  background: linear-gradient(135deg, var(--ma-green-dark), var(--ma-green));
  box-shadow: 0 2px 16px rgba(13, 92, 46, 0.25);
}
.ma-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff !important;
}
.ma-navbar .nav-link {
  color: rgba(255,255,255,0.9) !important;
  font-weight: 500;
  padding: 0.5rem 0.9rem !important;
  border-radius: 8px;
  transition: 0.2s;
}
.ma-navbar .nav-link:hover,
.ma-navbar .nav-link.active {
  color: var(--ma-gold-light) !important;
  background: rgba(255,255,255,0.08);
}
.ma-navbar .btn-gold {
  background: var(--ma-gold);
  color: #1a1a1a !important;
  border: none;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.45rem 1.2rem;
}
.ma-navbar .btn-gold:hover { background: var(--ma-gold-light); }

.hero-section {
  background: linear-gradient(135deg, var(--ma-green-dark) 0%, var(--ma-green) 50%, #1a7a42 100%);
  color: #fff;
  padding: 5rem 0 4rem;
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9a227' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-section .badge-gold {
  background: var(--ma-gold);
  color: #1a1a1a;
  font-weight: 600;
  padding: 0.4rem 1rem;
  border-radius: 50px;
}
.hero-section h1 {
  font-weight: 800;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.hero-section .lead { opacity: 0.92; font-size: 1.1rem; }
.stat-card-hero {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--ma-radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card-hero .num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ma-gold-light);
}

.section-title {
  font-weight: 800;
  color: var(--ma-green-dark);
  letter-spacing: -0.02em;
  position: relative;
  display: inline-block;
  margin-bottom: 0.5rem;
}
[data-theme="dark"] .section-title { color: var(--ma-gold-light); }
.section-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, var(--ma-gold), var(--ma-green));
  border-radius: 2px;
  margin-top: 0.5rem;
}
.section-sub { color: var(--ma-muted); margin-bottom: 2rem; }

.ma-card {
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius);
  box-shadow: var(--ma-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.ma-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(13, 92, 46, 0.12);
}
.ma-card .card-img-top {
  border-radius: var(--ma-radius) var(--ma-radius) 0 0;
  height: 180px;
  object-fit: cover;
}

.btn-ma {
  background: var(--ma-green);
  color: #fff;
  border: none;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.55rem 1.4rem;
  transition: 0.2s;
}
.btn-ma:hover { background: var(--ma-green-light); color: #fff; }
.btn-ma-outline {
  background: transparent;
  color: var(--ma-green);
  border: 2px solid var(--ma-green);
  font-weight: 600;
  border-radius: 8px;
  padding: 0.5rem 1.3rem;
}
.btn-ma-outline:hover { background: var(--ma-green); color: #fff; }
.btn-gold {
  background: linear-gradient(135deg, var(--ma-gold), var(--ma-gold-light));
  color: #1a1a1a;
  border: none;
  font-weight: 700;
  border-radius: 8px;
  padding: 0.55rem 1.4rem;
}
.btn-gold:hover { filter: brightness(1.08); color: #1a1a1a; }

.feature-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, rgba(13,92,46,0.12), rgba(201,162,39,0.15));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  color: var(--ma-green);
  margin-bottom: 1rem;
}
[data-theme="dark"] .feature-icon { color: var(--ma-gold-light); }

.ma-footer {
  background: var(--ma-green-dark);
  color: rgba(255,255,255,0.85);
  padding: 3rem 0 1.5rem;
}
.ma-footer h5 { color: var(--ma-gold); font-weight: 700; }
.ma-footer a { color: rgba(255,255,255,0.75); text-decoration: none; }
.ma-footer a:hover { color: var(--ma-gold-light); }
.ma-footer .bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 2rem;
  padding-top: 1.25rem;
  font-size: 0.9rem;
}

/* ---- Auth ---- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--ma-green-dark), var(--ma-green));
}
.auth-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem;
  color: #fff;
}
.auth-form-wrap {
  width: 100%;
  max-width: 460px;
  background: var(--ma-card);
  display: flex;
  align-items: center;
  padding: 2.5rem;
}
.auth-form-wrap .form-control {
  border-radius: 10px;
  padding: 0.7rem 1rem;
  border-color: var(--ma-border);
}
.auth-form-wrap .form-control:focus {
  border-color: var(--ma-green);
  box-shadow: 0 0 0 3px rgba(13, 92, 46, 0.15);
}

/* ---- App Layout (Dashboard) ---- */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--ma-sidebar-w);
  background: linear-gradient(180deg, var(--ma-sidebar), var(--ma-green-dark));
  color: #fff;
  z-index: 1040;
  overflow-y: auto;
  transition: transform 0.3s;
}
.app-sidebar .brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.app-sidebar .brand-icon {
  width: 42px; height: 42px;
  background: var(--ma-gold);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  color: var(--ma-green-dark);
  font-size: 1.1rem;
}
.app-sidebar .brand-text { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.app-sidebar .brand-text small { display: block; font-weight: 400; opacity: 0.7; font-size: 0.7rem; }

.sidebar-nav { padding: 1rem 0.75rem; }
.sidebar-nav .nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
  padding: 0.75rem 0.75rem 0.35rem;
  font-weight: 600;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.85rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: 0.15s;
}
.sidebar-nav a i { font-size: 1.1rem; width: 22px; text-align: center; opacity: 0.85; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active {
  background: linear-gradient(90deg, var(--ma-gold), var(--ma-gold-dark));
  color: #1a1a1a;
  font-weight: 600;
}
.sidebar-nav a.active i { opacity: 1; }

.app-main {
  margin-left: var(--ma-sidebar-w);
  min-height: 100vh;
  transition: margin 0.3s;
}
.app-topbar {
  height: var(--ma-topbar-h);
  background: var(--ma-card);
  border-bottom: 1px solid var(--ma-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.app-content { padding: 1.5rem; }

.stat-box {
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--ma-shadow);
  height: 100%;
}
.stat-box .icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-box .icon.green { background: rgba(13,92,46,0.12); color: var(--ma-green); }
.stat-box .icon.gold { background: rgba(201,162,39,0.15); color: var(--ma-gold-dark); }
.stat-box .icon.blue { background: rgba(13,110,253,0.12); color: #0d6efd; }
.stat-box .icon.red { background: rgba(220,53,69,0.12); color: #dc3545; }
.stat-box .icon.purple { background: rgba(111,66,193,0.12); color: #6f42c1; }
.stat-box .icon.teal { background: rgba(32,201,151,0.12); color: #20c997; }
.stat-box .value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-box .label { font-size: 0.85rem; color: var(--ma-muted); }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}
.page-header .breadcrumb { margin: 0; font-size: 0.85rem; }

.table-ma {
  background: var(--ma-card);
  border-radius: var(--ma-radius);
  overflow: hidden;
  border: 1px solid var(--ma-border);
}
.table-ma thead {
  background: linear-gradient(90deg, var(--ma-green-dark), var(--ma-green));
  color: #fff;
}
.table-ma thead th {
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}
.table-ma tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-color: var(--ma-border);
  font-size: 0.9rem;
}
.table-ma tbody tr:hover { background: rgba(13, 92, 46, 0.04); }

.badge-role {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.35em 0.7em;
  border-radius: 6px;
}
.badge-hadir { background: #d1e7dd; color: #0f5132; }
.badge-terlambat { background: #fff3cd; color: #664d03; }
.badge-izin { background: #cfe2ff; color: #084298; }
.badge-sakit { background: #e2d9f3; color: #432874; }
.badge-alpha { background: #f8d7da; color: #842029; }

.avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ma-border);
}
.avatar-md {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ma-muted);
}
.empty-state i { font-size: 3rem; opacity: 0.4; margin-bottom: 1rem; display: block; }

/* Exam layout */
.exam-header {
  background: var(--ma-green-dark);
  color: #fff;
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.exam-timer {
  background: var(--ma-gold);
  color: #1a1a1a;
  font-weight: 800;
  font-size: 1.25rem;
  padding: 0.4rem 1rem;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.exam-timer.warning { background: #dc3545; color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }

.question-card {
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.question-card .q-num {
  background: var(--ma-green);
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  margin-right: 0.5rem;
}
.option-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--ma-border);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: 0.15s;
}
.option-label:hover { border-color: var(--ma-green-light); background: rgba(13,92,46,0.04); }
.option-label:has(input:checked) {
  border-color: var(--ma-green);
  background: rgba(13, 92, 46, 0.08);
}

/* Chat */
.chat-container { display: flex; height: calc(100vh - 140px); gap: 1rem; }
.chat-contacts {
  width: 280px;
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius);
  overflow-y: auto;
}
.chat-contact {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ma-border);
  text-decoration: none;
  color: var(--ma-text);
  cursor: pointer;
}
.chat-contact:hover, .chat-contact.active { background: rgba(13,92,46,0.08); }
.chat-messages {
  flex: 1;
  background: var(--ma-card);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-radius);
  display: flex;
  flex-direction: column;
}
.chat-body { flex: 1; overflow-y: auto; padding: 1rem; }
.chat-bubble {
  max-width: 70%;
  padding: 0.65rem 1rem;
  border-radius: 14px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.chat-bubble.mine {
  background: var(--ma-green);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  background: var(--ma-bg);
  border: 1px solid var(--ma-border);
  border-bottom-left-radius: 4px;
}
.chat-input { border-top: 1px solid var(--ma-border); padding: 0.75rem; display: flex; gap: 0.5rem; }

/* Pagination */
.pagination .page-link {
  color: var(--ma-green);
  border-color: var(--ma-border);
}
.pagination .page-item.active .page-link {
  background: var(--ma-green);
  border-color: var(--ma-green);
}

/* Mobile */
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.4rem; color: var(--ma-text); }
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .auth-brand { display: none; }
  .auth-form-wrap { max-width: 100%; }
  .chat-container { flex-direction: column; height: auto; }
  .chat-contacts { width: 100%; max-height: 200px; }
}

/* PWA install banner */
.pwa-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ma-green-dark);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}
.pwa-banner.show { display: flex; }

/* Utilities */
.text-ma { color: var(--ma-green) !important; }
.text-gold { color: var(--ma-gold) !important; }
.bg-ma { background: var(--ma-green) !important; }
.bg-gold { background: var(--ma-gold) !important; }
.border-ma { border-color: var(--ma-green) !important; }
.fw-800 { font-weight: 800; }
.gap-section { padding: 4rem 0; }

/* Print */
@media print {
  .app-sidebar, .app-topbar, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; }
}
