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

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

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

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

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

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

body.mrp-login-screen #bottom-nav,
body.mrp-login-screen #more-menu-panel,
body.mrp-login-screen #more-menu-backdrop,
body.mrp-login-screen #btn-header-more-menu {
    display: none !important;
}

/* Kartu */
body.mrp-theme main .bg-white,
body.mrp-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.mrp-theme [class*="bg-blue-"],
body.mrp-portal [class*="bg-blue-"] {
    --tw-bg-opacity: 1;
}

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

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

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

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

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

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

body.mrp-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;
}

/* Nav gerai: semua item tampil, ukuran & warna sama */
body.mrp-theme *:has(> #desktop-nav-icons) > :first-child {
    flex-shrink: 0 !important;
    position: relative;
    z-index: 2;
    padding-right: 0.75rem;
    margin-right: 0.15rem;
    background-color: #fff;
    white-space: nowrap;
}
body.mrp-theme #desktop-nav-icons {
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    min-width: 0 !important;
    overflow-x: auto;
    padding-left: 0.25rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
body.mrp-theme #desktop-nav-icons .desktop-nav-item {
    color: #6b7280 !important;
    background-color: transparent !important;
    box-shadow: none !important;
}
body.mrp-theme #desktop-nav-icons .desktop-nav-item:hover,
body.mrp-theme #desktop-nav-icons .desktop-nav-item.is-active {
    color: #15803d !important;
    background-color: #f0fdf4 !important;
}
.mrp-pair-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #86efac;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}
.mrp-pair-btn:hover {
    background: #dcfce7;
    color: #14532d;
}
.mrp-pair-btn i { font-size: 11px; }
body.mrp-theme #more-menu-items .mrp-pair-menu {
    background-color: #ecfdf5 !important;
    color: #166534 !important;
    border: 1px solid #bbf7d0;
}
body.mrp-theme #more-menu-items .nav-menu-item {
    display: flex !important;
    background-color: #f9fafb !important;
    color: #6b7280 !important;
    box-shadow: none !important;
}
body.mrp-theme #more-menu-items .nav-menu-item:hover,
body.mrp-theme #more-menu-items .nav-menu-item.is-active-page {
    display: flex !important;
    background-color: #f0fdf4 !important;
    color: #15803d !important;
}
body.mrp-theme #btn-more-menu {
    background-color: #16a34a !important;
    color: #fff !important;
}
body.mrp-theme #bottom-nav #bottom-nav-home,
body.mrp-theme #bottom-nav #bottom-nav-active {
    width: 4rem;
}
body.mrp-theme #bottom-nav i {
    font-size: 1.125rem;
}
body.mrp-theme #bottom-nav span {
    font-size: 0.65rem;
    font-weight: 600;
}

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

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

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

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

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

body.mrp-theme #desktop-nav-icons {
    max-width: none !important;
    flex: 1 1 0% !important;
    justify-content: flex-start !important;
    min-width: 0 !important;
}

/* Geser horizontal tanpa batang scrollbar (semua menu) */
.no-scrollbar,
body.mrp-theme #desktop-nav-icons,
body.mrp-theme .table-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar,
body.mrp-theme #desktop-nav-icons::-webkit-scrollbar,
body.mrp-theme .table-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

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

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

body.mrp-theme .mrp-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.mrp-theme #admin-section:not(.hidden) {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
        gap: 0.75rem;
        align-items: start;
    }

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

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

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

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

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

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

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

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

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

body.mrp-theme input[type="checkbox"],
body.mrp-theme input[type="radio"] {
    width: 1.05rem;
    height: 1.05rem;
    min-width: 1.05rem;
    min-height: 0 !important;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    accent-color: #16a34a;
    vertical-align: middle;
    align-self: center;
}

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

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

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

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

    body.mrp-theme main input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
    body.mrp-theme main select,
    body.mrp-theme main textarea {
        min-height: clamp(2rem, 1.6rem + 0.5vw, 2.75rem);
    }

    body.mrp-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.mrp-theme #desktop-nav-icons .desktop-nav-item i {
        font-size: clamp(0.95rem, 0.8rem + 0.25vw, 1.25rem);
    }

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

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

    body.mrp-theme > nav img.h-8,
    body.mrp-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.mrp-theme #bottom-nav .nav-menu-item i {
        font-size: clamp(1rem, 0.85rem + 0.3vw, 1.35rem);
    }

    body.mrp-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.mrp-theme main th,
    body.mrp-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.mrp-theme[class*="pb-"] {
        --mrp-main-fill: calc(100dvh - var(--mrp-nav-h) - 4.5rem);
    }
}

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

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

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

    body.mrp-theme #dashboard-section:not(.hidden) {
        min-height: 0 !important;
        flex: 0 0 auto !important;
    }

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

    body.mrp-theme #admin-section:not(.hidden) > div:first-child,
    body.mrp-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.mrp-theme #admin-section:not(.hidden) > div:first-child > .overflow-x-auto,
    body.mrp-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.mrp-theme #dashboard-section:not(.hidden) #history-section:not(.hidden) {
        flex: 0 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

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

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

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

    body.mrp-theme #laba-view > .bg-white.overflow-hidden,
    body.mrp-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.mrp-theme #laba-view .overflow-x-auto,
    body.mrp-theme #opr-view .overflow-x-auto {
        flex: 1 1 auto;
        overflow-y: auto !important;
        min-height: 0;
    }

    /* Gudang */
    body.mrp-theme main > #view-stok:not(.hidden),
    body.mrp-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.mrp-theme #view-stok > .bg-white,
    body.mrp-theme #view-riwayat > .bg-white,
    body.mrp-theme #view-riwayat > .print-area {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    body.mrp-theme #view-stok .overflow-y-auto,
    body.mrp-theme #view-riwayat .overflow-y-auto,
    body.mrp-theme #view-stok [class*="max-h-["],
    body.mrp-theme #view-riwayat [class*="max-h-["],
    body.mrp-theme .mrp-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.mrp-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.mrp-theme #rincian-container {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: clamp(240px, 40vh, calc(100dvh - 16rem));
    }

    /* Sales */
    body.mrp-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.mrp-theme #sales-input-section .table-scroll {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }

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

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

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

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

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

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

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