/* ==========================================================
   CEMARA - TAMPILAN DESKTOP & TABLET
   Hanya aktif di layar lebar. Tampilan HP tidak berubah.
   ========================================================== */

#side-brand { display: none; }

/* ---------- TABLET (768px+) ---------- */
@media (min-width: 768px) {
    body { background: #e9efec; }
    #app-shell { max-width: 720px !important; box-shadow: 0 10px 40px rgba(20,35,31,.12) !important; }
    #app-nav { max-width: 720px !important; border-radius: 1.4rem 1.4rem 0 0; box-shadow: 0 -6px 24px rgba(20,35,31,.08); }
    #fab-btn { right: calc(50% - 340px) !important; }
    #fab-menu { right: calc(50% - 340px) !important; }
}

/* ---------- DESKTOP (1024px+) ---------- */
@media (min-width: 1024px) {
    html { font-size: 15px; }
    body { background: #e9efec; padding-bottom: 0 !important; }

    /* kerangka: sidebar kiri + area konten */
    #app-shell {
        max-width: none !important; width: auto !important; margin: 0 !important;
        margin-left: 264px !important; min-height: 100vh;
        background: #f1f5f3 !important; box-shadow: none !important; overflow: visible !important;
    }

    /* sidebar */
    #side-brand {
        display: flex; align-items: center; gap: .85rem; position: fixed; z-index: 60;
        top: 0; left: 0; width: 264px; padding: 1.6rem 1.4rem 1rem; background: #1f4d43; color: #fff;
    }
    #side-brand .sb-logo { width: 2.8rem; height: 2.8rem; border-radius: .95rem; background: rgba(255,255,255,.14);
        border: 1px solid rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem; }
    #side-brand b { display: block; font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
    #side-brand small { display: block; font-size: .75rem; color: rgba(255,255,255,.65); font-weight: 500; }

    #app-nav {
        top: 0 !important; bottom: 0 !important; left: 0 !important; right: auto !important;
        width: 264px !important; max-width: none !important; margin: 0 !important;
        flex-direction: column !important; justify-content: flex-start !important; align-items: stretch !important;
        gap: .35rem; padding: 6.2rem 1rem 1.5rem !important; background: #1f4d43 !important;
        border: 0 !important; border-radius: 0 !important; box-shadow: none !important; z-index: 55 !important;
    }
    #app-nav .nav-item {
        flex-direction: row; justify-content: flex-start; gap: .9rem; width: 100%;
        padding: .85rem 1rem; font-size: .95rem; font-weight: 600; color: rgba(255,255,255,.72);
        border-radius: 1rem;
    }
    #app-nav .nav-item .ic { width: 1.35rem; height: 1.35rem; }
    #app-nav .nav-item:hover { background: rgba(255,255,255,.09); color: #fff; }
    #app-nav .nav-item.nav-active { background: #fff; color: #1f4d43; }
    #app-nav .nav-item.nav-active .ic { animation: none; }
    #app-nav::after {
        content: "Versi desktop"; margin-top: auto; padding: .8rem 1rem; font-size: .72rem; color: rgba(255,255,255,.4);
    }

    /* halaman: isi dipusatkan, tidak melebar tanpa batas */
    .page-view { min-height: 100vh !important; background: transparent !important; }
    .page-view > div:first-child { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 2rem; }
    .page-view > footer { display: none !important; }

    /* header halaman: tetap menempel, latar menyatu */
    .page-view header { background: rgba(241,245,243,.92) !important; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
        border-bottom: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }
    .page-view header .ic { cursor: pointer; }
    section.px-5, div.px-5, div.p-5 { padding-left: 0 !important; padding-right: 0 !important; }
    div.p-5 { padding-top: 1rem !important; }
    .pb-24, .pb-28 { padding-bottom: 3rem !important; }

    /* ---- BERANDA: dua kolom ---- */
    #main-dashboard > div:first-child {
        display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.25rem 1.5rem; align-content: start;
    }
    #main-dashboard > div:first-child > header { grid-column: 1 / -1; }
    #main-dashboard > div:first-child > section { margin: 0 !important; min-width: 0; }
    /* urutan: sapaan+cuaca | menu | agenda | jatuh tempo | kekayaan | saldo | in-out | transaksi */
    #main-dashboard > div:first-child > section:nth-of-type(1) { grid-column: 1 / span 7; }
    #main-dashboard > div:first-child > section:nth-of-type(2) { grid-column: 8 / span 5; }
    #main-dashboard > div:first-child > section:nth-of-type(3) { grid-column: 1 / span 7; }
    #main-dashboard > div:first-child > section:nth-of-type(4) { grid-column: 8 / span 5; }
    #main-dashboard > div:first-child > section:nth-of-type(5) { grid-column: 1 / span 6; }
    #main-dashboard > div:first-child > section:nth-of-type(6) { grid-column: 7 / span 6; }
    #main-dashboard > div:first-child > section:nth-of-type(7) { grid-column: 1 / -1; }
    #main-dashboard > div:first-child > section:nth-of-type(8) { grid-column: 1 / -1; }
    #main-dashboard > div:first-child > section:nth-of-type(1) > div { min-height: 14rem; }
    #main-dashboard > div:first-child > section:nth-of-type(2) .grid { gap: 1.1rem .5rem; }
    #main-dashboard #dash-recent-transactions > div { max-width: 760px; }

    /* ---- KEUANGAN & halaman sejenis: grid dua kolom bila ada banyak kartu ---- */
    #finance-page > div:first-child { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.25rem 1.5rem; align-content: start; }
    #finance-page > div:first-child > header { grid-column: 1 / -1; }
    #finance-page > div:first-child > section { margin: 0 !important; min-width: 0; }
    #finance-page > div:first-child > section:nth-of-type(1) { grid-column: 1 / span 7; }
    #finance-page > div:first-child > section:nth-of-type(2) { grid-column: 8 / span 5; }
    #finance-page > div:first-child > section:nth-of-type(3) { grid-column: 1 / -1; }
    #finance-page > div:first-child > section:nth-of-type(4) { grid-column: 1 / -1; }
    #finance-page > div:first-child > .px-5 { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
    #finance-page > div:first-child > .px-5 > #finance-form { grid-column: 1; }
    #finance-page > div:first-child > .px-5 > div { grid-column: 2; }
    #finance-page > div:first-child > .px-5 > div:last-child { grid-row: 1 / span 2; }
    #finance-page #transaction-list { max-height: 60vh !important; }

    /* ---- Halaman isi (konten di dalam .px-5 pb-6): batasi lebar agar tidak terlalu lebar ---- */
    #budget-page .px-5.pb-6, #debt-page .px-5.pb-6, #goal-page .px-5.pb-6,
    #asset-page .px-5.pb-6, #report-page .px-5.pb-6, #wallet-page .px-5.pb-6,
    #alloc-page .px-5.pb-6, #transfer-history-page .px-5.pb-6, #budget-edit-page .px-5.pb-6 {
        max-width: 860px; margin-left: auto; margin-right: auto; width: 100%;
    }
    #routine-page section.px-5, #add-asset-page section.px-5 { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }

    /* daftar kartu jadi grid */
    #goal-list { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    #bud-cards.grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    #wal-cards { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    #asset-list, #debt-list, #rt-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    #asset-list > *, #debt-list > *, #rt-list > * { margin: 0 !important; }
    #th-list, #jr-list, #lnk-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    #lv-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

    /* ---- Kalender: grid di kiri, agenda di kanan ---- */
    #calendar-page > div:first-child > div.p-5 {
        display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.25rem 1.5rem; align-items: start; max-width: 1180px;
    }
    #calendar-page > div:first-child > div.p-5 > :nth-child(1) { grid-column: 1; }
    #calendar-page > div:first-child > div.p-5 > :nth-child(2) { grid-column: 1; grid-row: 2; }
    #calendar-page > div:first-child > div.p-5 > :nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
    #calendar-page > div:first-child > div.p-5 > :nth-child(4) { grid-column: 2; grid-row: 3; }
    #calendar-page > div:first-child > div.p-5 > :nth-child(5) { grid-column: 1; grid-row: 3; }
    #calendar-grid > button { height: 3.4rem !important; }

    /* Maintenance, Jurnal, Conversation, dll: dua kolom form + daftar */
    #maintenance-page > div:first-child > div.p-5,
    #journal-page > div:first-child > div.p-5 {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.25rem 1.5rem; align-items: start;
    }
    #conv-page > div:first-child > div.p-5, #berdua-page > div:first-child > div.p-5,
    #love-page > div:first-child > div.p-5, #reflect-page > div:first-child > div.p-5,
    #links-page > div:first-child > div.p-5, #idea-page > div:first-child > div.p-5,
    #profile-page > div:first-child > div.p-5, #settings-page > div:first-child > div.p-5,
    #about-page > div:first-child > div.p-5, #help-page > div:first-child > div.p-5 {
        max-width: 760px; margin-left: auto; margin-right: auto;
    }
    #more-page > div:first-child > div.p-5 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; max-width: 960px; margin: 0 auto; }
    #more-page .more-row { margin: 0; }
    #more-page .more-row:hover, .menu-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(20,35,31,.1); }
    .more-row { transition: transform .2s, box-shadow .2s; }

    /* ---- tombol + (FAB) di pojok kanan bawah layar ---- */
    #fab-btn { right: 2rem !important; bottom: 2rem !important; }
    #fab-menu { right: 2rem !important; bottom: 6.5rem !important; }

    /* ---- Pop-up: jadi dialog di tengah, bukan lembar dari bawah ---- */
    #pos-overlay, #quick-overlay, #calc-overlay, .pk-ov, .sheet-ov { align-items: center !important; padding: 1.5rem; }
    #pos-overlay > div, #quick-overlay > div, #calc-overlay > div, .pk-sheet, .sheet {
        border-radius: 1.75rem !important; max-width: 460px !important; box-shadow: 0 24px 60px rgba(20,35,31,.3) !important;
    }
    @keyframes dlgCenter { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
    #pos-overlay:not(.hidden) > div, #quick-overlay:not(.hidden) > div, #calc-overlay:not(.hidden) > div,
    .pk-sheet, .sheet { animation: dlgCenter .28s cubic-bezier(.22, 1, .36, 1) both !important; }
    .pk-grip { display: none; }
    .pk-ov.out .pk-sheet { animation: fadeOut .2s ease both !important; }

    /* ---- Layar login: kartu di tengah ---- */
    .gate-page { margin: 2rem auto; min-height: 0; max-width: 460px; border-radius: 1.75rem; overflow: hidden; box-shadow: 0 16px 50px rgba(20,35,31,.18); }

    /* kontrol pointer: hover & fokus lebih jelas */
    button { cursor: pointer; }
    .pf-in:focus, .bd-ta:focus { border-color: #1f4d43; box-shadow: 0 0 0 3px rgba(31,77,67,.14); }
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-thumb { background: #c2d1ca; border-radius: 999px; border: 2px solid #e9efec; }
    ::-webkit-scrollbar-thumb:hover { background: #a3b8af; }
    .no-scrollbar::-webkit-scrollbar { display: none; }
}

/* ---------- DESKTOP LEBAR (1440px+) ---------- */
@media (min-width: 1440px) {
    #app-shell { margin-left: 288px !important; }
    #side-brand, #app-nav { width: 288px !important; }
    .page-view > div:first-child { max-width: 1320px; }
    #goal-list, #bud-cards.grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}

/* ---------- CETAK: kembali polos ---------- */
@media print {
    #side-brand { display: none !important; }
    #app-shell { margin-left: 0 !important; }
}
