/* ============================================================
   e-Raport Digital — Pondok Pesantren Al Kamil
   Tema: VibeCoder (soft indigo/violet, glassmorphism)
   ============================================================ */
:root {
  --indigo: #4F46E5;
  --violet: #8B5CF6;
  --pink: #EC4899;
  --sky: #38BDF8;
  --ink: #1F1B3A;
  --muted: #635F82;
  --line: rgba(79, 70, 229, 0.14);
  --card-bg: rgba(255, 255, 255, 0.62);
  --card-bg-strong: rgba(255, 255, 255, 0.78);
  --grad: linear-gradient(135deg, var(--indigo), var(--violet));
  --shadow: 0 18px 45px -18px rgba(79, 70, 229, 0.35);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 8% -5%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(236, 72, 153, 0.14), transparent 55%),
    radial-gradient(760px 520px at 55% 110%, rgba(56, 189, 248, 0.16), transparent 60%),
    linear-gradient(160deg, #F3F0FF 0%, #F6F4FF 45%, #F2F6FF 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
}

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

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 6px 24px -18px rgba(79, 70, 229, 0.5);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; margin-right: 6px; }
.brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--shadow); }
.brand .t1 { font-weight: 800; font-size: 15.5px; letter-spacing: -0.2px; }
.brand .t2 { font-size: 11px; color: var(--muted); }

.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.navlink {
  padding: 8px 14px; border-radius: 12px; font-size: 13px; font-weight: 600;
  color: var(--muted); display: inline-flex; align-items: center; gap: 7px;
  transition: all .15s; white-space: nowrap;
}
.navlink:hover { background: rgba(79, 70, 229, 0.08); color: var(--indigo); text-decoration: none; }
.navlink.active {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.7);
}
.navlink .num {
  width: 20px; height: 20px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 800;
  background: rgba(255, 255, 255, 0.25);
}
.navlink:not(.active) .num { background: rgba(79, 70, 229, 0.12); color: var(--indigo); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.userchip {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255, 255, 255, 0.75); border: 1px solid var(--line);
  padding: 6px 12px 6px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.userchip .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px;
}
.userchip .role { color: var(--muted); font-weight: 500; font-size: 11px; display: block; margin-top: -2px; }

.btn-logout {
  background: rgba(255, 255, 255, 0.7); border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.btn-logout:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; text-decoration: none; }

/* ---------- Container & kartu ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 26px 22px 70px; }
.pagetitle { margin: 4px 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.pagesub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }

/* ---------- Statistik ---------- */
.statcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 24px; }
.statcard {
  background: var(--card-bg); backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.75); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.statcard .ico {
  width: 46px; height: 46px; border-radius: 14px; background: var(--grad);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 21px;
  box-shadow: 0 10px 22px -10px rgba(79, 70, 229, 0.8); flex-shrink: 0;
}
.statcard .val { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.1; }
.statcard .lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.statcard .sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.field label small { color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: rgba(255, 255, 255, 0.85); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 13px; outline: none; transition: border .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}
.field textarea { resize: vertical; min-height: 74px; }
.field .hint { font-size: 11px; color: var(--muted); }
.rtl-input { direction: rtl; text-align: right; font-family: 'Amiri', serif; font-size: 16px !important; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  border-radius: 12px; padding: 10px 18px; border: 1.5px solid transparent;
  transition: all .15s; text-decoration: none; white-space: nowrap; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 24px -10px rgba(79, 70, 229, 0.85); }
.btn-primary:hover { filter: brightness(1.07); text-decoration: none; }
.btn-ghost { background: rgba(255, 255, 255, 0.8); color: var(--indigo); border-color: var(--line); }
.btn-ghost:hover { background: rgba(79, 70, 229, 0.07); text-decoration: none; }
.btn-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; text-decoration: none; }
.btn-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.btn-success:hover { background: #d1fae5; text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 10px; }
.btn-lg { padding: 13px 26px; font-size: 14.5px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }

/* ---------- Tabel ---------- */
.tablewrap { overflow-x: auto; border-radius: 14px; border: 1px solid rgba(255,255,255,0.8); background: rgba(255,255,255,0.55); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.data th {
  text-align: left; padding: 11px 13px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--muted); font-weight: 700;
  background: rgba(79, 70, 229, 0.05); border-bottom: 1px solid var(--line);
}
table.data td { padding: 11px 13px; border-bottom: 1px solid rgba(79, 70, 229, 0.08); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: rgba(79, 70, 229, 0.04); }
table.data .num { width: 44px; color: var(--muted); font-weight: 600; }
table.data .actions { display: flex; gap: 6px; flex-wrap: wrap; }
table.data .actions .btn { padding: 5px 9px; font-size: 11.5px; border-radius: 9px; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ---------- Alert / flash ---------- */
.alert { border-radius: 13px; padding: 12px 16px; font-size: 13.5px; font-weight: 600; margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: 8px; margin: 2px 0 24px; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 9px; padding: 9px 15px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.6); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700;
  color: var(--muted);
}
.step .dot {
  width: 24px; height: 24px; border-radius: 50%; background: rgba(79, 70, 229, 0.12); color: var(--indigo);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 800;
}
.step.done { color: #047857; border-color: #a7f3d0; background: rgba(236, 253, 245, 0.8); }
.step.done .dot { background: #10b981; color: #fff; }
.step.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 10px 22px -10px rgba(79,70,229,.8); }
.step.active .dot { background: rgba(255,255,255,.25); color: #fff; }

/* ---------- Progress ---------- */
.progress { height: 9px; border-radius: 999px; background: rgba(79, 70, 229, 0.1); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--grad); transition: width .4s; }

/* ---------- Halaman nilai (entri) ---------- */
.grp-card { margin-bottom: 20px; }
.grp-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 15px; font-weight: 800; margin-bottom: 12px;
}
.grp-title .ar { font-family: 'Amiri', serif; font-size: 19px; color: var(--violet); font-weight: 700; direction: rtl; }
.nilai-grid {
  display: grid;
  grid-template-rows: repeat(5, auto);   /* 5 baris ke bawah */
  grid-auto-flow: column;                /* mengalir ke kolom berikutnya */
  gap: 8px 16px;
}
.nilai-cell {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  background: rgba(255, 255, 255, 0.8); border: 1.5px solid var(--line); border-radius: 11px; padding: 7px 12px;
  transition: border .15s;
}
.nilai-cell:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.nilai-cell .no { display: none; }
.nilai-cell .nama { flex: 1 1 90px; min-width: 0; font-weight: 700; font-size: 12px; line-height: 1.2; }
.nilai-cell .nama .ar { font-family: 'Amiri', serif; font-size: 13.5px; color: var(--ink); display: block; direction: rtl; text-align: right; }
.nilai-cell .nama .id { display: none; }
.nilai-cell .colon { font-weight: 800; color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.nilai-cell input {
  flex: 0 0 58px; width: 58px; font-family: inherit; font-weight: 800; font-size: 14px; text-align: center;
  border: 1.5px solid var(--line); border-radius: 9px; padding: 6px 4px; outline: none;
  background: #fff;
}
.nilai-cell input:focus { border-color: var(--indigo); }
.nilai-cell .desc { font-family: 'Amiri', serif; font-size: 12px; color: #059669; direction: rtl; text-align: right; min-height: 0; display: block; width: 100%; }
.nilai-cell .desc.err { color: #dc2626; font-family: inherit; font-size: 10.5px; direction: ltr; }

.small-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: rgba(255,255,255,0.75); cursor: pointer; font-size: 13px; font-weight: 600;
}
.radio-pill input { accent-color: var(--indigo); margin: 0; }
.radio-pill:has(input:checked) { border-color: var(--indigo); background: rgba(79, 70, 229, 0.08); }

/* ---------- Halaman auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 430px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 20px; }
.auth-brand img { width: 74px; height: 74px; border-radius: 20px; box-shadow: var(--shadow); }
.auth-brand h1 { font-size: 21px; margin: 12px 0 2px; letter-spacing: -0.3px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
.auth-tabs { display: flex; background: rgba(255,255,255,0.6); border: 1px solid var(--line); border-radius: 13px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; padding: 9px; border: 0; border-radius: 10px; background: transparent; font-family: inherit;
  font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer; transition: all .15s;
}
.auth-tabs button.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(79,70,229,.7); }
.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px; font-size: 13.5px;
  font-weight: 700; color: var(--ink); cursor: pointer; font-family: inherit; transition: all .15s;
}
.google-btn:hover { box-shadow: 0 8px 20px -10px rgba(0,0,0,.2); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11.5px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Grafik (SVG) ---------- */
.chart-box { background: rgba(255,255,255,0.85); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.chart-box h4 { margin: 0 0 10px; font-size: 13.5px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-row .lbl { width: 150px; font-size: 12px; font-weight: 600; text-align: right; flex-shrink: 0; }
.bar-row .bar { flex: 1; height: 18px; background: rgba(79,70,229,0.08); border-radius: 6px; overflow: hidden; }
.bar-row .bar > div { height: 100%; border-radius: 6px; background: var(--grad); min-width: 2px; }
.bar-row .val { width: 46px; font-size: 12px; font-weight: 800; }

/* ---------- Bagikan / WA ---------- */
.shareline { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,0.7); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 13px; font-size: 12.5px; word-break: break-all; }
.shareline input { flex: 1; border: 0; background: transparent; font-family: inherit; font-size: 12.5px; color: var(--ink); outline: none; }

/* ---------- Lain-lain ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt16 { margin-top: 16px; }
.mt24 { margin-top: 24px; }
.ar { font-family: 'Amiri', serif; direction: rtl; }
.ar-center { text-align: center; }
.footer-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }
.adminbar {
  background: linear-gradient(135deg, rgba(245,158,11,0.18), rgba(217,119,6,0.14));
  border: 1px solid #fcd34d; border-radius: 13px; padding: 10px 16px; font-size: 13px; font-weight: 600;
  margin-bottom: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
@media (max-width: 720px) {
  .container { padding: 18px 14px 60px; }
  .brand .t2 { display: none; }
  .nilai-grid { grid-template-columns: none; grid-template-rows: repeat(5, auto); grid-auto-flow: column; }
}
