/* ===================================================
   style.css - Design system aplikasi Kas Keluarga
   Toska dominan, merah/hijau kontekstual, fix portrait
   =================================================== */

:root {
    --color-primary: #0F766E;
    --color-primary-light: #CCFBF1;
    --color-primary-dark: #0D5F58;
    --color-bg: #F8FAFC;
    --color-text: #1E293B;
    --color-text-muted: #64748B;
    --color-border: #E2E8F0;
    --color-pengeluaran: #DC2626;
    --color-pengeluaran-bg: #FEF2F2;
    --color-pemasukan: #16A34A;
    --color-pemasukan-bg: #F0FDF4;
    --color-pindah: #2563EB;
    --color-pindah-bg: #EFF6FF;
    --color-warning: #D97706;
    --color-warning-bg: #FFFBEB;
    --max-width: 480px;
    --radius: 14px;
    --radius-sm: 10px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #E2E8F0; /* area kiri-kanan di desktop */
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: var(--max-width);
    min-height: 100vh;
    background: var(--color-bg);
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { color: var(--color-primary); font-size: 20px; margin-bottom: 4px; }
.login-header p { color: var(--color-text-muted); font-size: 13px; }

.user-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.user-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-card:active { background: var(--color-primary-light); }

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
}

.user-name { font-size: 15px; font-weight: 600; color: var(--color-text); }

.pin-label { text-align: center; color: var(--color-text-muted); font-size: 14px; margin-bottom: 20px; }
.pin-label strong { color: var(--color-text); }

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 16px;
}

.pin-dots .dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    background: transparent;
}

.pin-dots .dot.filled { background: var(--color-primary); }

.pin-error {
    text-align: center;
    color: var(--color-pengeluaran);
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 16px;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}

.num-btn {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: white;
    font-size: 22px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
}

.num-btn:active { background: var(--color-primary-light); }
.num-btn-ghost { background: transparent; border: none; font-size: 18px; color: var(--color-text-muted); }
.num-btn.disabled { opacity: 0.3; pointer-events: none; }

.forgot-pin {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 24px;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width);
    background: white;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 11px;
    padding: 8px 16px;
    min-width: 48px;
    min-height: 48px;
    justify-content: center;
}

.nav-item .icon-emoji { font-size: 24px; line-height: 1; }
.nav-item.active { color: var(--color-primary); }
.nav-item svg { width: 22px; height: 22px; }

/* ===== GRID 2 KOLOM (kas cards, dll) ===== */
.kas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.kas-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.kas-card .icon { font-size: 18px; }
.kas-card .nama { font-weight: 600; font-size: 13px; margin-top: 4px; }
.kas-card .saldo { font-size: 14px; color: var(--color-primary); font-weight: 600; margin-top: 2px; }

/* ===== HORIZONTAL SCROLL (masih dipakai di tempat lain jika perlu) ===== */
.hscroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 16px 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.hscroll::-webkit-scrollbar { display: none; }

.hscroll-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 140px;
}

/* ===== GENERIC LAYOUT ===== */
.page-content {
    padding: 16px;
    padding-bottom: 90px; /* ruang untuk bottom nav */
}

.page-header {
    background: var(--color-primary);
    color: white;
    padding: 14px 16px;
}

.page-header h1 { font-size: 16px; font-weight: 600; }
.page-header p { font-size: 12px; opacity: 0.85; margin-top: 2px; }

.card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
}

.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--color-primary); color: white; }
.btn-pengeluaran { background: var(--color-pengeluaran); color: white; }
.btn-pemasukan { background: var(--color-pemasukan); color: white; }

.btn-pair { display: flex; gap: 12px; }
.btn-pair .btn { flex: 1; }

.amount-pengeluaran { color: var(--color-pengeluaran); font-weight: 600; }
.amount-pemasukan { color: var(--color-pemasukan); font-weight: 600; }

.text-muted { color: var(--color-text-muted); font-size: 13px; }

/* ===== TOMBOL TAMBAH DI NAV BAR (bagian dari flex row, bukan floating) ===== */
.nav-add-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 8px;
    color: var(--color-text-muted);
    font-size: 11px;
    font-family: inherit;
    min-height: 48px;
}

.nav-add-btn .add-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(15, 118, 110, 0.4);
    transition: transform 0.15s;
}

.fab-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    display: none;
}

.fab-menu {
    position: fixed;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
    width: 210px;
}

.fab-menu-item {
    display: block;
    text-align: center;
    padding: 13px;
    border-radius: 30px;
    color: white;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.fab-pengeluaran { background: var(--color-pengeluaran); }
.fab-pemasukan { background: var(--color-pemasukan); }
.fab-pindah { background: var(--color-pindah); }

/* ===== USER BUTTON DI HEADER (kanan atas) ===== */
.page-header { position: relative; }

.header-user-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown {
    position: absolute;
    top: 52px;
    right: 16px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    width: 170px;
    z-index: 300;
    display: none;
    overflow: hidden;
}

.user-dropdown a, .user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--color-text);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 1px solid var(--color-border);
}

.user-dropdown a:last-child, .user-dropdown button:last-child { border-bottom: none; }
.user-dropdown a:active, .user-dropdown button:active { background: var(--color-primary-light); }
.user-dropdown .logout-item { color: var(--color-pengeluaran); }
