/* ============================================================================
   ANGKET PEMILIHAN EKSTRAKURIKULER - NEUMORPHISM DESIGN SYSTEM
   MA Bahrul Ulum Kepohbaru - Tahun Pelajaran 2026/2027
   ============================================================================ */

:root {
  --bg: #EEF2F7;
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --secondary: #6366F1;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --text: #1E293B;
  --text-muted: #64748B;
  --card-radius: 24px;
  --btn-radius: 18px;
  --shadow-dark: 8px 8px 16px rgba(163,177,198,.6);
  --shadow-light: -8px -8px 16px rgba(255,255,255,1);
  --shadow-dark-sm: 4px 4px 8px rgba(163,177,198,.5);
  --shadow-light-sm: -4px -4px 8px rgba(255,255,255,1);
  --nav-height: 68px;
  --header-height: 60px;
}

[data-theme="dark"] {
  --bg: #1B1F27;
  --primary: #818CF8;
  --primary-dark: #6366F1;
  --secondary: #A5B4FC;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --shadow-dark: 8px 8px 16px rgba(0,0,0,.55);
  --shadow-light: -8px -8px 16px rgba(255,255,255,.04);
  --shadow-dark-sm: 4px 4px 8px rgba(0,0,0,.5);
  --shadow-light-sm: -4px -4px 8px rgba(255,255,255,.03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  transition: background .3s ease, color .3s ease;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

.app-wrapper {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: calc(var(--nav-height) + 16px);
}

/* ============================= NEUMORPHIC CARD ============================= */
.neu-card {
  background: var(--bg);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-dark), var(--shadow-light);
  padding: 20px;
  margin-bottom: 16px;
}

.neu-flat {
  background: var(--bg);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm);
}

.neu-inset {
  background: var(--bg);
  border-radius: var(--btn-radius);
  box-shadow: inset 4px 4px 8px rgba(163,177,198,.5), inset -4px -4px 8px rgba(255,255,255,.9);
}
[data-theme="dark"] .neu-inset {
  box-shadow: inset 4px 4px 8px rgba(0,0,0,.5), inset -4px -4px 8px rgba(255,255,255,.03);
}

/* ============================= STICKY HEADER ============================= */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--bg);
  box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm);
}
.app-header h1 { font-size: 16px; font-weight: 700; margin: 0; }
.app-header .header-icon-btn {
  width: 40px; height: 40px; border-radius: 14px; border: none;
  background: var(--bg); box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.app-header .header-icon-btn:active { box-shadow: inset 3px 3px 6px rgba(163,177,198,.5), inset -3px -3px 6px rgba(255,255,255,.9); }

.app-content { padding: 16px; }

/* ============================= BUTTONS ============================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--btn-radius);
  padding: 13px 22px; font-size: 14px; font-weight: 600;
  background: var(--bg); color: var(--text);
  box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm);
  transition: transform .1s ease, box-shadow .15s ease;
  width: 100%;
}
.btn:active { transform: scale(.97); box-shadow: inset 3px 3px 6px rgba(163,177,198,.5), inset -3px -3px 6px rgba(255,255,255,.9); }
.btn-primary { background: linear-gradient(145deg, var(--secondary), var(--primary)); color: #fff; box-shadow: 6px 6px 14px rgba(79,70,229,.35), -4px -4px 10px rgba(255,255,255,.5); }
.btn-success { background: linear-gradient(145deg, #34D399, var(--success)); color: #fff; box-shadow: 6px 6px 14px rgba(34,197,94,.35), -4px -4px 10px rgba(255,255,255,.5); }
.btn-danger { background: linear-gradient(145deg, #F87171, var(--danger)); color: #fff; box-shadow: 6px 6px 14px rgba(239,68,68,.35), -4px -4px 10px rgba(255,255,255,.5); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); box-shadow: none; }
.btn-sm { padding: 8px 14px; font-size: 12px; width: auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.fab {
  position: fixed; z-index: 50;
  right: 20px; bottom: calc(var(--nav-height) + 20px);
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(145deg, var(--secondary), var(--primary));
  color: #fff; border: none;
  box-shadow: 6px 6px 16px rgba(79,70,229,.45), -4px -4px 10px rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center;
  max-width: calc(560px - 40px);
  margin: 0 auto;
}

/* ============================= FORM ============================= */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-muted); }
.form-control {
  width: 100%; border: none; outline: none;
  padding: 14px 16px; border-radius: var(--btn-radius);
  background: var(--bg); color: var(--text); font-size: 14px;
  box-shadow: inset 4px 4px 8px rgba(163,177,198,.5), inset -4px -4px 8px rgba(255,255,255,.9);
}
[data-theme="dark"] .form-control { box-shadow: inset 4px 4px 8px rgba(0,0,0,.5), inset -4px -4px 8px rgba(255,255,255,.03); }
.form-control:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-left: 44px; }
.input-icon-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.form-error { color: var(--danger); font-size: 12px; margin-top: 6px; display: none; }

/* ============================= BOTTOM NAVIGATION ============================= */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-width: 560px; margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 -6px 16px rgba(163,177,198,.4);
  display: flex; height: var(--nav-height);
  border-radius: 24px 24px 0 0;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  border-radius: 16px; margin: 0 3px;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--primary); background: var(--bg); box-shadow: inset 3px 3px 6px rgba(163,177,198,.5), inset -3px -3px 6px rgba(255,255,255,.9); }

/* ============================= PROGRESS BAR ============================= */
.progress-wrap { background: var(--bg); border-radius: 20px; height: 14px; box-shadow: inset 3px 3px 6px rgba(163,177,198,.5), inset -3px -3px 6px rgba(255,255,255,.9); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--secondary), var(--primary)); transition: width .4s ease; }

/* ============================= BADGE ============================= */
.badge { display: inline-block; padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-primary { background: rgba(79,70,229,.15); color: var(--primary); }

/* ============================= AVATAR ============================= */
.avatar { border-radius: 50%; object-fit: cover; box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm); background: var(--bg); }
.avatar-fallback { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); }

/* ============================= EKSKUL CARD ============================= */
.ekskul-card { display: flex; gap: 14px; align-items: center; }
.ekskul-thumb { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; flex-shrink: 0; box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm); }
.ekskul-info { flex: 1; min-width: 0; }
.ekskul-info h3 { margin: 0 0 4px; font-size: 15px; }
.ekskul-info p { margin: 0; font-size: 12px; color: var(--text-muted); }
.ekskul-checkbox {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm); color: transparent;
}
.ekskul-checkbox.checked { background: linear-gradient(145deg, var(--secondary), var(--primary)); color: #fff; box-shadow: none; }

/* ============================= MODAL ============================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--bg); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 30px rgba(0,0,0,.2);
  transform: translateY(30px); transition: transform .25s ease;
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-box h3 { margin-top: 0; }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 24px; max-width: 420px; }
}

/* ============================= TOAST ============================= */
#toast-container { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; width: calc(100% - 32px); max-width: 520px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg); border-radius: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-dark), var(--shadow-light);
  animation: toast-in .3s ease forwards; font-size: 13px; font-weight: 600;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
.toast.hide { animation: toast-out .3s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px); } }

/* ============================= LOADING SPINNER ============================= */
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(79,70,229,.15); border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-overlay { position: fixed; inset: 0; background: rgba(238,242,247,.7); display: flex; align-items: center; justify-content: center; z-index: 300; }
[data-theme="dark"] .spinner-overlay { background: rgba(27,31,39,.75); }

/* ============================= SKELETON ============================= */
.skeleton { border-radius: 14px; background: linear-gradient(90deg, rgba(163,177,198,.25) 25%, rgba(163,177,198,.4) 37%, rgba(163,177,198,.25) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ============================= EMPTY STATE ============================= */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 12px; opacity: .5; }
.empty-state p { margin: 0; font-size: 13px; }

/* ============================= SEARCH ============================= */
.search-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--btn-radius); margin-bottom: 16px; }
.search-bar input { border: none; background: transparent; outline: none; flex: 1; font-size: 14px; color: var(--text); }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

/* ============================= PULL TO REFRESH ============================= */
#ptr-indicator { position: fixed; top: var(--header-height); left: 50%; transform: translate(-50%,-100%); z-index: 45; transition: transform .2s ease; }
#ptr-indicator.visible { transform: translate(-50%, 10px); }

/* ============================= OFFLINE BANNER ============================= */
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  background: var(--danger); color: #fff; text-align: center; font-size: 12px; font-weight: 700;
  padding: 8px; transform: translateY(-100%); transition: transform .3s ease;
}
#offline-banner.show { transform: translateY(0); }

/* ============================= PAGINATION ============================= */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm); }
.pagination a.active { background: linear-gradient(145deg, var(--secondary), var(--primary)); color: #fff; box-shadow: none; }

/* ============================= FILTER CHIPS ============================= */
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 8px 16px; border-radius: 14px; font-size: 12px; font-weight: 600; box-shadow: var(--shadow-dark-sm), var(--shadow-light-sm); white-space: nowrap; color: var(--text-muted); }
.chip.active { background: linear-gradient(145deg, var(--secondary), var(--primary)); color: #fff; box-shadow: none; }

/* ============================= TABLE (desktop admin) ============================= */
.table-wrap { overflow-x: auto; border-radius: var(--card-radius); }
table.neu-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.neu-table th { text-align: left; padding: 12px 14px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
table.neu-table td { padding: 12px 14px; border-top: 1px solid rgba(163,177,198,.25); }
table.neu-table tr:hover td { background: rgba(79,70,229,.04); }

/* ============================= STAT CARD (admin dashboard) ============================= */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat-card { text-align: center; padding: 18px 10px; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============================= UTILITIES ============================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

@media (min-width: 900px) {
  .app-wrapper { max-width: 900px; }
  .bottom-nav, .fab, .modal-overlay { max-width: 900px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
