/* Baqi PWA - Tema hijau BaQi, mobile-first */

:root {
  --green: #53a173;
  --green-dark: #458a63;
  --green-darker: #37724f;
  --green-light: #e7f3ec;
  --green-pale: #f2f9f5;

  --c-quran: #7ba95c;
  --c-petro: #1f618d;
  --c-exam: #ee6c4d;
  --c-rank: #00af90;
  --c-group: #9700af;
  --c-dark: #303c54;
  --c-olive: #a7bd3c;

  --text: #1c2422;
  --text-muted: #6b7a75;
  --bg: #f4f6f4;
  --card: #ffffff;
  --border: #e2e8e4;
  --danger: #d64545;
  --amber: #d99a2b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(30, 60, 45, 0.09);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ===== Splash ===== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  gap: 12px;
  transition: opacity .3s;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { width: 128px; height: 128px; }
.splash-name { font-size: 28px; font-weight: 700; color: var(--green-dark); letter-spacing: 3px; }
.splash-sub { font-size: 12.5px; color: var(--text-muted); }
.splash-loading span {
  display: block;
  width: 34px; height: 34px;
  border: 3px solid var(--green-light);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .back {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  color: #fff; text-decoration: none; font-size: 18px; flex-shrink: 0;
}
.app-header img.brand { width: 32px; height: 32px; border-radius: 50%; background: #fff; }
.app-header .title { font-size: 17px; font-weight: 700; }
.app-header .spacer { flex: 1; }
.app-header .header-right { font-size: 13px; opacity: .92; }

/* ===== Konten ===== */
.page {
  flex: 1;
  padding: 16px;
  padding-bottom: 86px;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.section-title {
  font-size: 15.5px;
  font-weight: 700;
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title a { font-size: 12.5px; color: var(--green-dark); text-decoration: none; font-weight: 600; }

/* ===== Kartu ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

/* ===== Login ===== */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 22px;
  gap: 6px;
  min-height: 100dvh;
}
.login-logo { width: 96px; height: 96px; margin-bottom: 6px; }
.login-title { font-size: 26px; font-weight: 800; color: var(--green-dark); letter-spacing: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; text-align: center; }
.login-form {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== Form ===== */
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: var(--green); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter .15s, transform .05s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-outline { background: #fff; color: var(--green-dark); border: 1.5px solid var(--green); }
.btn-ghost { background: var(--green-light); color: var(--green-darker); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-sm { padding: 9px 13px; font-size: 13px; border-radius: 9px; }

.form-msg { font-size: 13.5px; padding: 10px 12px; border-radius: 10px; display: none; }
.form-msg.error { display: block; background: #fdecec; color: #a33; }
.form-msg.ok { display: block; background: var(--green-light); color: var(--green-darker); }

.login-alt { margin-top: 16px; font-size: 13.5px; color: var(--text-muted); text-align: center; }
.login-alt a { color: var(--green-dark); font-weight: 700; text-decoration: none; }

.login-sep {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-muted); margin: 4px 0;
}
.login-sep::before, .login-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ===== Home ===== */
.greet-card {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.greet-card .hi { font-size: 13px; opacity: .9; }
.greet-card .name { font-size: 21px; font-weight: 800; margin-top: 2px; }
.progress-wrap { margin-top: 14px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; opacity: .95; margin-bottom: 6px; }
.progress-bar { height: 8px; background: rgba(255,255,255,.28); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width .5s; }

.banner-box {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  background: var(--green-light);
  aspect-ratio: 16 / 7;
  position: relative;
}
.banner-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-box .dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.banner-box .dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.55); }
.banner-box .dots i.on { background: #fff; }

.menu-list { display: flex; flex-direction: column; gap: 14px; }
.menu-card {
  width: 100%;
  min-height: 88px;
  border-radius: 15px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  transition: transform .08s;
}
.menu-card:active { transform: scale(.985); }
.menu-card .ico { font-size: 34px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.2)); }
.menu-card .txt .label { font-size: 18px; font-weight: 700; line-height: 1.25; }
.menu-card .txt .sub { font-size: 12.5px; opacity: .93; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.menu-tile .ico {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px; color: #fff;
}
.menu-tile .label { font-size: 13px; font-weight: 700; }
.menu-tile .sub { font-size: 11px; color: var(--text-muted); }

/* ===== Daftar level / sublevel / materi ===== */
.level-item {
  display: flex;
  align-items: center;
  gap: 13px;
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 12px;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
  min-height: 74px;
}
.level-item:active { transform: scale(.99); }
.level-item .num {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
}
.level-item .body .t { font-size: 15px; font-weight: 700; line-height: 1.35; }
.level-item .body .d { font-size: 12px; opacity: .9; margin-top: 3px; }
.level-item .arrow { margin-left: auto; opacity: .8; font-size: 18px; }

.materi-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.materi-item .judul { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.materi-item .desk { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.materi-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.materi-actions .btn { flex: 1 1 44%; }

.exam-footer-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px;
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
}
.exam-footer-btn:active { transform: scale(.99); }
.divider-line { height: 1px; background: var(--border); margin: 14px 0 4px; }

/* ===== Media (tonton / baca) ===== */
.media-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius);
  background: #000;
  box-shadow: var(--shadow);
}
.pdf-frame {
  width: 100%;
  height: 68dvh;
  border: none;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

/* ===== Ujian ===== */
.quiz-head {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.quiz-head .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.quiz-head .bar { height: 7px; background: var(--green-light); border-radius: 999px; overflow: hidden; }
.quiz-head .bar span { display: block; height: 100%; background: var(--green); transition: width .3s; }

.question-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.question-box .q-text { font-size: 16px; font-weight: 600; line-height: 1.6; direction: rtl; text-align: right; }
.question-box .q-text.ltr { direction: ltr; text-align: left; }
.question-box .q-img { width: 100%; border-radius: 10px; margin-top: 10px; }

.options { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.option {
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 13px 14px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.option:disabled { cursor: default; }
.option.selected { background: #eaf3ff; border-color: #2f6fb3; font-weight: 600; }
.option.correct { background: #e6f6ec; border-color: #43a06a; }
.option.wrong { background: #fdecec; border-color: var(--danger); }
.option.dim { opacity: .6; }
.multi-hint { margin-top: 12px; font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.question-box #multi-ok { margin-top: 16px; }

.quiz-result { text-align: center; padding: 26px 16px; }
.quiz-result .big { font-size: 46px; font-weight: 800; color: var(--green-dark); }
.quiz-result .sub { font-size: 14px; color: var(--text-muted); margin-top: 6px; }

/* ===== Ranking ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  flex: 1 1 auto;
  min-width: 74px;
  text-align: center;
  padding: 10px 8px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.tab.active { background: var(--green); border-color: var(--green); color: #fff; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-bottom: 9px;
}
.rank-row.me { border-color: var(--green); background: var(--green-pale); }
.rank-row .pos {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-darker);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.rank-row .pos.top1 { background: #ffe9a8; color: #8a6410; }
.rank-row .pos.top2 { background: #e8e8e8; color: #555; }
.rank-row .pos.top3 { background: #f5dcc8; color: #8a5a2b; }
.rank-row .ava {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; background: var(--green-light); flex-shrink: 0;
}
.rank-row .ava-ph {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green-light); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.rank-row .nm { flex: 1; min-width: 0; }
.rank-row .nm .n { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .nm .s { font-size: 11.5px; color: var(--text-muted); }
.rank-row .sc { font-size: 16px; font-weight: 800; color: var(--green-dark); }

/* ===== Grup ===== */
.group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 10px;
  cursor: pointer;
}
.group-row .gico {
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--c-group); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; flex-shrink: 0;
}
.group-row .gt { flex: 1; min-width: 0; }
.group-row .gt .n { font-size: 14.5px; font-weight: 700; }
.group-row .gt .d { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.member-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-row .ava {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: var(--green-light); flex-shrink: 0;
}
.member-row .ava-ph {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green-light); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.member-row .m { flex: 1; min-width: 0; }
.member-row .m .n { font-size: 14px; font-weight: 700; }
.member-row .m .e { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 3px 8px; background: var(--green-light); color: var(--green-darker); }
.tag.owner { background: #efe0ff; color: var(--c-group); }

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input {
  flex: 1; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14.5px; font-family: inherit; outline: none;
}
.search-bar input:focus { border-color: var(--green); }

/* ===== Profil ===== */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 18px 0 8px; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--green-light); color: var(--green-dark);
  font-size: 26px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-head .who .nama { font-size: 17px; font-weight: 800; }
.profile-head .who .mail { font-size: 12.5px; color: var(--text-muted); word-break: break-all; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.list-row .ico {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--green-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.list-row .chev { margin-left: auto; color: var(--text-muted); }
.list-row.danger { color: var(--danger); }
.list-row.danger .ico { background: #fdecec; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10.5px; font-weight: 600;
}
.bottom-nav a .ico { font-size: 21px; line-height: 1; }
.bottom-nav a.active { color: var(--green-dark); }

/* ===== Umum ===== */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 14px;
}
.empty .big { font-size: 40px; margin-bottom: 10px; }
.loading-inline { display: flex; align-items: center; justify-content: center; padding: 30px; }
.loading-inline span {
  width: 28px; height: 28px;
  border: 3px solid var(--green-light);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--green-dark); text-decoration: none;
  font-size: 14px; font-weight: 700; margin-bottom: 12px;
}

#offline-bar {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--amber); color: #fff;
  text-align: center; font-size: 12.5px;
  padding: 5px; z-index: 50;
}

#install-btn {
  position: fixed; right: 16px; bottom: 90px;
  background: var(--green-dark); color: #fff;
  border: none; border-radius: 999px;
  padding: 11px 18px; font-size: 13.5px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  z-index: 30; animation: pop .3s ease;
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 100px;
  background: #2c3632; color: #fff;
  padding: 10px 20px; border-radius: 999px;
  font-size: 13px; z-index: 60; animation: pop .25s ease;
  max-width: 90%; text-align: center;
}

.badge {
  display: inline-block;
  background: #eef1ef; color: var(--text-muted);
  font-size: 10.5px; font-weight: 700;
  border-radius: 6px; padding: 2px 7px; margin-left: 6px;
}
.badge.guest { background: #fff1e2; color: #a4610d; }

.note {
  background: #fff8e6; border: 1px solid #ead092; color: #8a6410;
  border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.5;
}

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 70; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
.modal {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 20px 18px 26px;
  max-height: 86dvh; overflow: auto;
}
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.modal .m-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.modal .m-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .m-actions .btn { flex: 1; }
