/* ==========================================================
   TOKEN DESAIN — Portal Digital Pesantren
   Palet hijau pesantren + emas hangat, tipografi Fraunces
   (judul) & Plus Jakarta Sans (isi), nuansa hangat & terpercaya
   ========================================================== */
:root {
    --bg: #FBF7EE;
    --surface: #FFFFFF;
    --surface-soft: #F3EFE2;
    --green-900: #123822;
    --green-700: #176B3B;
    --green-600: #1E8449;
    --green-500: #27AE60;
    --green-100: #E4F1E6;
    --gold-700: #A87A1E;
    --gold-500: #C7962C;
    --gold-100: #F4E7C8;
    --ink: #22281F;
    --muted: #6E7B6E;
    --border: #E2DAC4;
    --border-green: #CFE3D3;
    --danger: #B23A2E;
    --shadow-sm: 0 2px 8px rgba(18, 56, 34, 0.08);
    --shadow-md: 0 10px 30px rgba(18, 56, 34, 0.12);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 8% 0%, rgba(39, 174, 96, 0.08), transparent 40%),
        radial-gradient(circle at 100% 12%, rgba(199, 150, 44, 0.10), transparent 45%);
    background-attachment: fixed;
    color: var(--ink);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 3px solid var(--gold-500);
    outline-offset: 2px;
}

/* ---------- Tombol hamburger sidebar ---------- */
.sidebar-toggle {
    position: fixed;
    top: 18px;
    left: 18px;
    background: var(--green-900);
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.15s ease, background 0.2s ease;
}

.sidebar-toggle:hover { background: var(--green-700); }
.sidebar-toggle:active { transform: scale(0.94); }

.hamburger-bar {
    width: 20px;
    height: 2px;
    background: var(--gold-100);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.sidebar-toggle.is-open .hamburger-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.is-open .hamburger-bar:nth-child(2) { opacity: 0; }
.sidebar-toggle.is-open .hamburger-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Sidebar ---------- */
.sidebar {
    height: 100%;
    width: 270px;
    position: fixed;
    z-index: 1002;
    top: 0;
    left: -270px;
    background: linear-gradient(175deg, var(--green-900) 0%, #0C2818 100%);
    overflow-x: hidden;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: 10px;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.28);
}

.sidebar.active { left: 0; }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px 16px 20px;
    border-bottom: 1px solid rgba(244, 231, 200, 0.15);
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; }

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold-500);
}

.sidebar-header h3 {
    color: var(--gold-100);
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
}

.close-btn {
    background: none;
    border: none;
    color: var(--gold-100);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 8px;
}

.tab-btn {
    background: rgba(244, 231, 200, 0.06);
    color: #E9F3EA;
    border: 1px solid rgba(244, 231, 200, 0.12);
    padding: 13px 15px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-body);
    border-radius: 10px;
    transition: background 0.18s ease, border-color 0.18s ease;
    text-align: left;
    font-size: 0.94rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tab-icon { font-size: 1.05rem; }

.tab-btn:hover { background: rgba(244, 231, 200, 0.12); transform: translateX(2px); }

.tab-btn.active {
    background: var(--gold-500);
    color: var(--green-900);
    border-color: var(--gold-500);
    box-shadow: 0 4px 12px rgba(199, 150, 44, 0.3);
}

/* ---------- Overlay ---------- */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 24, 16, 0.45);
    backdrop-filter: blur(1px);
    z-index: 1000;
}

.overlay.active { display: block; }

/* ---------- Lapisan balon ---------- */
#balloon-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
    overflow: hidden;
}

.balloon {
    position: absolute;
    bottom: -60px;
    font-size: 34px;
    opacity: 0;
    will-change: transform, opacity;
    animation-name: float-up;
    animation-timing-function: cubic-bezier(0.33, 0.1, 0.4, 0.9);
    animation-fill-mode: forwards;
}

@keyframes float-up {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
    8% { opacity: 1; }
    50% { transform: translate(var(--drift), -55vh) rotate(var(--spin)); }
    92% { opacity: 1; }
    100% { transform: translate(calc(var(--drift) * 1.6), -115vh) rotate(calc(var(--spin) * 1.6)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .balloon { animation: none; display: none; }
}

/* ---------- Konten utama ---------- */
.container {
    max-width: 620px;
    margin: 44px auto;
    background: var(--surface);
    padding: 30px 28px 34px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-green);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--green-700), var(--gold-500), var(--green-700));
    background-size: 200% 100%;
    animation: shimmer 6s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* ---------- Tampil/sembunyi konten tab ---------- */
/* !important sengaja dipasang sebagai jaring pengaman ekstra:
   walau ada CSS lama/cache yang tertinggal, tab non-aktif TETAP tersembunyi. */
.tab-content { display: none !important; }
.tab-content.active { display: block !important; animation: tab-in 0.22s ease-out; }

@keyframes tab-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3 {
    color: var(--green-900);
    font-family: var(--font-display);
    font-weight: 600;
}

h2 {
    text-align: center;
    font-size: 1.4rem;
    margin: 4px 0 22px;
}

h3 { font-size: 1.1rem; margin: 0 0 14px; }

/* ---------- Header: judul kiri, logo kanan ---------- */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.title-wrapper { display: flex; flex-direction: column; }

.eyebrow {
    margin: 0 0 4px;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    color: var(--gold-700);
    font-weight: 700;
}

.header-container h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
    max-width: 32ch;
}

.app-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold-500);
    box-shadow: 0 6px 16px rgba(199, 150, 44, 0.35), 0 2px 4px rgba(0, 0, 0, 0.10);
    flex-shrink: 0;
}

/* ---------- Lencana pengganti kalau logo.png belum ditemukan ---------- */
.logo-fallback {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(155deg, var(--gold-500), var(--gold-700));
    color: var(--green-900);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    border: 3px solid var(--green-900);
    box-shadow: 0 6px 16px rgba(199, 150, 44, 0.35), 0 2px 4px rgba(0, 0, 0, 0.10);
}

.logo-fallback-sm {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
    border: 2px solid var(--gold-500);
    background: linear-gradient(155deg, var(--gold-500), var(--gold-700));
    color: var(--green-900);
}

.header-divider {
    height: 10px;
    margin: 20px 0 22px;
    background-image: radial-gradient(circle, var(--border-green) 1.6px, transparent 1.6px);
    background-size: 14px 10px;
    background-position: center;
    opacity: 0.9;
}

/* ---------- Form & input ---------- */
.form-group { margin-bottom: 15px; }

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--green-700);
}

.hint-text {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0 0 10px;
}

input, select {
    width: 100%;
    padding: 11px 12px;
    margin-bottom: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font-body);
    box-sizing: border-box;
    background-color: #FCFBF7;
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
    border-color: var(--green-500);
    outline: none;
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.14);
}

button.btn-primary {
    width: 100%;
    background: var(--green-700);
    color: #fff;
    border: none;
    padding: 13px;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-body);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.16s ease, transform 0.06s ease;
}

button.btn-primary:hover { background: var(--green-600); box-shadow: 0 4px 14px rgba(23, 107, 59, 0.28); }
button.btn-primary:active { transform: scale(0.98); }

.btn-logout {
    background: transparent;
    color: var(--danger);
    border: 1.5px solid rgba(178, 58, 46, 0.35);
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 16px;
    width: 100%;
    font-weight: 600;
    font-family: var(--font-body);
    transition: background 0.15s ease;
}

.btn-logout:hover { background: rgba(178, 58, 46, 0.08); }

.result-msg {
    margin-top: 15px;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
    font-size: 0.94rem;
}

/* ---------- Kartu status santri (hero saldo) ---------- */
.stat-card {
    background: linear-gradient(165deg, var(--green-900) 0%, #16472A 100%);
    border-radius: var(--radius-md);
    padding: 18px 20px 16px;
    margin-bottom: 16px;
    color: #EAF4EC;
    box-shadow: var(--shadow-sm);
    animation: card-in 0.22s ease-out;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stat-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
}

.stat-badge {
    background: rgba(199, 150, 44, 0.22);
    color: var(--gold-100);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 100px;
    border: 1px solid rgba(199, 150, 44, 0.4);
}

.stat-hero {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 14px;
}

.stat-hero-label {
    font-size: 0.78rem;
    color: rgba(234, 244, 236, 0.7);
}

.stat-hero-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.01em;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-cell {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-cell-accent {
    background: rgba(199, 150, 44, 0.16);
    border: 1px solid rgba(199, 150, 44, 0.35);
}

.stat-cell-label {
    font-size: 0.72rem;
    color: rgba(234, 244, 236, 0.72);
}

.stat-cell-value {
    font-weight: 700;
    font-size: 0.98rem;
    color: #fff;
}

.limit-bar {
    height: 7px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.limit-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-500), #E4B84C);
    border-radius: 100px;
    transition: width 0.35s ease;
}

.limit-caption {
    margin: 7px 0 0;
    font-size: 0.75rem;
    color: rgba(234, 244, 236, 0.68);
    text-align: right;
}

/* ---------- Sub-tabs Bendahara ---------- */
.sub-tabs {
    display: flex;
    margin-bottom: 16px;
    gap: 6px;
    background: var(--surface-soft);
    padding: 5px;
    border-radius: 10px;
}

.sub-tab-btn {
    background: transparent;
    border: none;
    padding: 9px;
    cursor: pointer;
    flex: 1;
    font-size: 0.8rem;
    font-family: var(--font-body);
    border-radius: 7px;
    color: var(--green-900);
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}

.sub-tab-btn.active {
    background: var(--green-700);
    color: #fff;
}

/* ---------- Dashboard pemasukan ---------- */
.metrics-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.card-metric {
    background: var(--green-100);
    border: 1px solid var(--border-green);
    padding: 16px;
    border-radius: var(--radius-md);
    flex: 1;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-metric:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.card-metric h4 {
    margin: 0;
    font-size: 0.78rem;
    color: var(--green-700);
    font-weight: 600;
}

.card-metric p {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--green-900);
    margin: 6px 0 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.83rem;
}

table, th, td { border: 1px solid var(--border-green); }

th, td { padding: 9px 8px; text-align: left; }

th {
    background-color: var(--green-100);
    color: var(--green-900);
    font-weight: 700;
}

tbody tr:nth-child(even) { background: #FAFBF6; }
tbody tr:hover { background: var(--green-100); }
td { transition: background 0.12s ease; }

/* ---------- Popup transaksi berhasil ---------- */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 14, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.25s ease;
    padding: 20px;
}

.popup-card {
    background: var(--surface);
    padding: 30px 26px;
    border-radius: 18px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: popUpScale 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-top: 4px solid var(--gold-500);
}

.popup-icon {
    font-size: 46px;
    margin-bottom: 8px;
    display: inline-block;
    animation: popup-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

@keyframes popup-bounce {
    0% { transform: scale(0.4) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(6deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); }
}

.popup-card h3 {
    color: var(--green-800, var(--green-700));
    margin-bottom: 14px;
    font-size: 1.25rem;
    text-align: center;
}

.popup-details {
    text-align: left;
    background: var(--surface-soft);
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 18px;
    border-left: 4px solid var(--green-500);
    color: var(--ink);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes popUpScale {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---------- Responsif mobile ---------- */
@media (max-width: 600px) {
    .container {
        margin: 16px 12px;
        padding: 22px 18px 26px;
    }
    .header-container {
        flex-direction: row-reverse;
    }
    .app-logo { width: 56px; height: 56px; }
    .header-container h1 { font-size: 1.35rem; }
    .stat-hero-value { font-size: 1.7rem; }
}
