/**
 * Toko Beddian — tema hijau (logo). Load SETELAH output.css.
 */
:root {
    --bdn-green: #16a34a;
    --bdn-green-dark: #15803d;
    --bdn-green-light: #dcfce7;
    --bdn-green-soft: #f0fdf4;
    --bdn-green-mint: #ecfdf5;
    --bdn-yellow: #eab308;
    --bdn-red: #dc2626;
    --bdn-border: #bbf7d0;
    /* Skala UI otomatis mengikuti lebar layar */
    --bdn-fluid-fs: clamp(15px, calc(12px + 0.45vw), 24px);
    --bdn-fluid-gap: clamp(0.5rem, 0.35rem + 0.35vw, 1.25rem);
    --bdn-fluid-radius: clamp(0.5rem, 0.35rem + 0.25vw, 1rem);
    --bdn-nav-h: clamp(3.5rem, 3rem + 0.8vw, 4.5rem);
    --bdn-main-fill: calc(100dvh - var(--bdn-nav-h) - 1.25rem);
}

/* Latar halaman */
body.bdn-theme {
    background: linear-gradient(165deg, #f0fdf4 0%, #ecfdf5 30%, #f8fafc 65%, #fffbeb 100%) !important;
    background-attachment: fixed;
}

body.bdn-portal {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 45%, #fef9c3 100%) !important;
}

/* Navbar & bottom nav */
body.bdn-theme > nav,
body.bdn-theme nav.sticky,
body.bdn-theme header.sticky {
    background: linear-gradient(180deg, #fff 0%, #f0fdf4 100%) !important;
    border-bottom-color: #bbf7d0 !important;
}

body.bdn-theme #bottom-nav {
    background: linear-gradient(0deg, #fff 0%, #f0fdf4 100%) !important;
    border-top-color: #bbf7d0 !important;
}

body.bdn-theme #more-menu-panel {
    background: linear-gradient(180deg, #fff 0%, #f0fdf4 100%) !important;
    border-top: 3px solid #16a34a;
}

/* Kartu */
body.bdn-theme main .bg-white,
body.bdn-theme section .bg-white {
    border: 1px solid #d1fae5;
    box-shadow: 0 1px 3px rgba(22, 163, 74, 0.08);
}

/* Safety net: jika masih ada sisa class biru lama */
body.bdn-theme [class*="bg-blue-"],
body.bdn-portal [class*="bg-blue-"] {
    --tw-bg-opacity: 1;
}

body.bdn-theme .bg-blue-600,
body.bdn-theme .bg-blue-500,
body.bdn-theme .bg-blue-700,
body.bdn-portal .bg-blue-600 {
    background-color: #16a34a !important;
}

body.bdn-theme .hover\:bg-blue-700:hover,
body.bdn-theme .hover\:bg-blue-600:hover {
    background-color: #15803d !important;
}

body.bdn-theme .text-blue-600,
body.bdn-theme .text-blue-500,
body.bdn-theme .text-blue-700 {
    color: #16a34a !important;
}

body.bdn-theme .border-blue-500,
body.bdn-theme .border-blue-200,
body.bdn-theme .border-blue-100 {
    border-color: #86efac !important;
}

body.bdn-theme .bg-blue-50,
body.bdn-theme .bg-blue-100 {
    background-color: #dcfce7 !important;
}

body.bdn-theme .loader {
    border-top-color: #16a34a !important;
}

body.bdn-theme .gradient-text {
    background: linear-gradient(135deg, #16a34a 0%, #eab308 55%, #dc2626 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@media (max-width: 767px) {
    body.bdn-theme .nav-menu-item.is-active-page { display: none !important; }
}

@media print {
    body.bdn-theme, body.bdn-portal { background: #fff !important; }
}

/* === Layout fluid — penuh lebar & tinggi layar === */
html {
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
}

body.bdn-theme {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

body.bdn-theme > nav > div,
body.bdn-theme > header > div,
body.bdn-theme nav.sticky > div {
    width: 100% !important;
    max-width: 100% !important;
}

body.bdn-theme > main,
body.bdn-theme main.flex-1,
body.bdn-theme main[class*="max-w-"],
body.bdn-theme main {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

body.bdn-theme #desktop-nav-icons {
    max-width: none !important;
    flex: 1 1 0% !important;
}

/* Tombol Kasir pin — selalu terlihat di header desktop/tablet */
body.bdn-theme #desktop-kasir-pin,
body.bdn-theme .desktop-kasir-pin {
    margin-right: 0.35rem;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.1;
}

@media (min-width: 1024px) {
    body.bdn-theme #desktop-kasir-pin,
    body.bdn-theme .desktop-kasir-pin {
        margin-right: 0.5rem;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
        font-size: 0.8rem;
    }
}

body.bdn-theme .bdn-shell {
    width: 100%;
    max-width: min(100%, 1920px);
    margin-left: auto;
    margin-right: auto;
}

/* Admin dashboard: tabel lebar + panel samping di layar besar */
@media (min-width: 1280px) {
    body.bdn-theme #admin-section:not(.hidden) {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
        gap: 0.75rem;
        align-items: start;
    }

    body.bdn-theme #admin-section:not(.hidden) > div:first-child {
        grid-column: 1;
        grid-row: 1 / span 3;
    }

    body.bdn-theme #admin-section:not(.hidden) > div:nth-child(2),
    body.bdn-theme #admin-section:not(.hidden) > div:nth-child(3) {
        grid-column: 2;
    }

    body.bdn-theme #admin-section:not(.hidden) > div:nth-child(2) {
        margin-top: 0 !important;
    }

    body.bdn-theme #admin-section:not(.hidden) > div:nth-child(3) {
        margin-top: 0 !important;
    }
}

@media (min-width: 1024px) {
    body.bdn-theme #dashboard-section:not(.hidden) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        align-items: start;
    }

    body.bdn-theme #dashboard-section:not(.hidden) > .bg-white:first-child,
    body.bdn-theme #dashboard-section:not(.hidden) > #karyawan-honor-panel,
    body.bdn-theme #dashboard-section:not(.hidden) > #sales-welcome-panel {
        grid-column: 1 / -1;
    }
}

/* === Tipografi & kotak fluid — otomatis besar di layar lebar === */
html {
    font-size: var(--bdn-fluid-fs);
}

/* Teks arbitrary px (Tailwind text-[Npx]) ikut membesar di layar lebar */
@media (min-width: 1024px) {
    body.bdn-theme [class*="text-[8px]"],
    body.bdn-theme [class*="text-[9px]"],
    body.bdn-theme [class*="text-[10px]"],
    body.bdn-theme [class*="text-[11px]"] {
        font-size: clamp(0.65rem, 0.5rem + 0.35vw, 0.95rem) !important;
    }
}

/* Kartu & panel — padding & sudut ikut skala */
body.bdn-theme main .bg-white.rounded-lg,
body.bdn-theme main section .bg-white.rounded-lg,
body.bdn-theme main .bg-white.rounded-xl,
body.bdn-theme main section .bg-white.rounded-xl {
    border-radius: var(--bdn-fluid-radius);
}

@media (min-width: 1280px) {
    body.bdn-theme main .bg-white.rounded-lg.p-3,
    body.bdn-theme main section .bg-white.rounded-lg.p-3 {
        padding: clamp(0.875rem, 0.65rem + 0.45vw, 1.5rem) !important;
    }

    body.bdn-theme main .bg-white.rounded-lg.p-4,
    body.bdn-theme main section .bg-white.rounded-lg.p-4 {
        padding: clamp(1rem, 0.75rem + 0.55vw, 1.75rem) !important;
    }

    body.bdn-theme main table,
    body.bdn-theme main table.text-xs {
        font-size: clamp(0.8rem, 0.65rem + 0.25vw, 1rem) !important;
    }

    body.bdn-theme main input,
    body.bdn-theme main select,
    body.bdn-theme main textarea,
    body.bdn-theme main button:not(.nav-menu-item):not(.desktop-nav-item) {
        font-size: clamp(0.8rem, 0.65rem + 0.2vw, 1rem);
    }

    body.bdn-theme main input,
    body.bdn-theme main select,
    body.bdn-theme main textarea {
        min-height: clamp(2rem, 1.6rem + 0.5vw, 2.75rem);
    }

    body.bdn-theme #desktop-nav-icons .desktop-nav-item {
        min-width: clamp(3rem, 2.5rem + 1.2vw, 4.5rem);
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    body.bdn-theme #desktop-nav-icons .desktop-nav-item i {
        font-size: clamp(0.95rem, 0.8rem + 0.25vw, 1.25rem);
    }

    body.bdn-theme #desktop-nav-icons .desktop-nav-item span {
        font-size: clamp(0.6rem, 0.5rem + 0.2vw, 0.85rem) !important;
    }

    body.bdn-theme > nav .h-14,
    body.bdn-theme nav.sticky .h-14 {
        height: clamp(3.5rem, 3rem + 0.8vw, 4.5rem);
    }

    body.bdn-theme > nav img.h-8,
    body.bdn-theme nav.sticky img.h-8 {
        height: clamp(2rem, 1.75rem + 0.5vw, 2.75rem);
        width: clamp(2rem, 1.75rem + 0.5vw, 2.75rem);
    }

    body.bdn-theme #bottom-nav .nav-menu-item i {
        font-size: clamp(1rem, 0.85rem + 0.3vw, 1.35rem);
    }

    body.bdn-theme #bottom-nav .nav-menu-item span {
        font-size: clamp(0.65rem, 0.55rem + 0.2vw, 0.85rem) !important;
    }
}

@media (min-width: 1536px) {
    html {
        font-size: clamp(16px, calc(13px + 0.5vw), 26px);
    }

    body.bdn-theme main th,
    body.bdn-theme main td {
        padding: clamp(0.35rem, 0.25rem + 0.15vw, 0.65rem) clamp(0.5rem, 0.35rem + 0.2vw, 0.85rem) !important;
    }
}

/* === Tinggi fluid — kotak isi sisa layar vertikal === */
@media (max-width: 1023px) {
    body.bdn-theme[class*="pb-"] {
        --bdn-main-fill: calc(100dvh - var(--bdn-nav-h) - 4.5rem);
    }
}

@media (min-width: 1024px) {
    body.bdn-theme > main,
    body.bdn-theme main.flex-1 {
        display: flex !important;
        flex-direction: column !important;
        min-height: var(--bdn-main-fill) !important;
    }

    body.bdn-theme main > section:not(.hidden),
    body.bdn-theme main > .tab-content:not(.hidden) {
        flex: 1 1 auto;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0;
        gap: var(--bdn-fluid-gap);
    }

    /* Index — absensi & rekap */
    body.bdn-theme #admin-section:not(.hidden),
    body.bdn-theme #summary-section:not(.hidden),
    body.bdn-theme #dashboard-section:not(.hidden) {
        min-height: var(--bdn-main-fill);
    }

    body.bdn-theme #admin-section:not(.hidden) {
        align-items: stretch;
    }

    body.bdn-theme #admin-section:not(.hidden) > div:first-child,
    body.bdn-theme #summary-section:not(.hidden) > .bg-white:first-child {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        max-height: calc(100dvh - 7rem);
    }

    body.bdn-theme #admin-section:not(.hidden) > div:first-child > .overflow-x-auto,
    body.bdn-theme #summary-section:not(.hidden) > .bg-white .overflow-x-auto {
        flex: 1 1 auto;
        overflow-y: auto !important;
        min-height: clamp(260px, 50vh, calc(100dvh - 12rem));
    }

    body.bdn-theme #dashboard-section:not(.hidden) #history-section {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: clamp(280px, 42vh, calc(100dvh - 16rem));
    }

    body.bdn-theme #dashboard-section:not(.hidden) #history-container {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }

    /* Daftar / list */
    body.bdn-theme main > #hutang-list,
    body.bdn-theme main > #tagihan-list,
    body.bdn-theme main > #display-list,
    body.bdn-theme #member-list,
    body.bdn-theme #list-rak {
        flex: 1 1 auto;
        min-height: clamp(280px, calc(100dvh - 18rem), calc(100dvh - 11rem));
        overflow-y: auto;
        align-content: start;
    }

    body.bdn-theme main > #laba-view:not(.hidden),
    body.bdn-theme main > #opr-view:not(.hidden) {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        gap: var(--bdn-fluid-gap);
    }

    body.bdn-theme #laba-view > .bg-white.overflow-hidden,
    body.bdn-theme #opr-view > .bg-white.rounded-xl {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: clamp(300px, calc(100dvh - 22rem), calc(100dvh - 14rem));
    }

    body.bdn-theme #laba-view .overflow-x-auto,
    body.bdn-theme #opr-view .overflow-x-auto {
        flex: 1 1 auto;
        overflow-y: auto !important;
        min-height: 0;
    }

    /* Gudang */
    body.bdn-theme main > #view-stok:not(.hidden),
    body.bdn-theme main > #view-riwayat:not(.hidden) {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: clamp(320px, calc(100dvh - 14rem), calc(100dvh - 9rem));
    }

    body.bdn-theme #view-stok > .bg-white,
    body.bdn-theme #view-riwayat > .bg-white,
    body.bdn-theme #view-riwayat > .print-area {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    body.bdn-theme #view-stok .overflow-y-auto,
    body.bdn-theme #view-riwayat .overflow-y-auto,
    body.bdn-theme #view-stok [class*="max-h-["],
    body.bdn-theme #view-riwayat [class*="max-h-["],
    body.bdn-theme .bdn-table-scroll {
        flex: 1 1 auto !important;
        max-height: none !important;
        min-height: clamp(280px, calc(100dvh - 20rem), calc(100dvh - 13rem)) !important;
        overflow-y: auto !important;
    }

    /* Laporan — hanya area cetak di dalam main (bukan overlay label_rak) */
    body.bdn-theme main #print-area {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: clamp(400px, calc(100dvh - 12rem), calc(100dvh - 8rem));
        max-height: calc(100dvh - 8rem);
    }

    body.bdn-theme #rincian-container {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: clamp(240px, 40vh, calc(100dvh - 16rem));
    }

    /* Sales */
    body.bdn-theme #sales-input-section {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: clamp(350px, calc(100dvh - 22rem), calc(100dvh - 13rem));
        max-height: calc(100dvh - 9rem);
    }

    body.bdn-theme #sales-input-section .table-scroll {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }

    /* Kasir */
    body.bdn-theme main > .lg\:flex {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        align-items: stretch !important;
    }

    body.bdn-theme main > .lg\:flex > .lg\:flex-1 {
        display: flex;
        flex-direction: column;
        min-height: calc(100dvh - var(--bdn-nav-h) - 2rem);
    }

    body.bdn-theme main .min-h-\[400px\].flex.flex-col {
        flex: 1 1 auto;
        min-height: clamp(400px, calc(100dvh - 18rem), calc(100dvh - 11rem)) !important;
    }

    body.bdn-theme #riwayat-list {
        min-height: clamp(300px, calc(100dvh - 16rem), calc(100dvh - 10rem));
    }

    /* Grafik */
    body.bdn-theme main > .tab-content:not(.hidden),
    body.bdn-theme main > section.tab-content:not(.hidden) {
        min-height: clamp(400px, calc(100dvh - 12rem), calc(100dvh - 8rem));
    }

    body.bdn-theme .chart-card {
        min-height: clamp(320px, 32vh, calc(100dvh - 14rem));
    }

    body.bdn-theme .chart-card [id$="-chart"],
    body.bdn-theme .chart-card [id$="-bar"],
    body.bdn-theme .chart-card [id$="-trend"],
    body.bdn-theme .chart-card [id$="-treemap-chart"],
    body.bdn-theme .chart-card [id$="-radial-chart"] {
        min-height: clamp(300px, 38vh, calc(100dvh - 16rem)) !important;
    }
}
