/*
 * Penyesuaian tampilan mobile untuk template Skydash.
 * Dimuat setelah skydash/css/style.css di semua layout.
 */

/* Angka nominal di baris "label ....... Rp x" tidak boleh terpotong ke baris baru */
.content-wrapper .d-flex.justify-content-between > .fw-bold:last-child {
    white-space: nowrap;
    padding-left: 0.75rem;
}

/* Sidebar mobile: latar gelap di belakang menu, tap untuk menutup */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10;
        background: rgba(0, 0, 0, 0.35);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-offcanvas {
        z-index: 11;
    }
}

@media (max-width: 767.98px) {
    /* ---------- Kerangka halaman ---------- */
    .content-wrapper {
        padding: 1rem 0.85rem;
    }

    .content-wrapper h2 {
        font-size: 1.35rem;
        line-height: 1.3;
    }

    .content-wrapper h3 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .footer {
        padding: 1rem;
        font-size: 0.75rem;
    }

    /* Nama user di navbar disembunyikan, cukup avatar */
    .navbar .nav-profile .nav-link > span {
        display: none;
    }

    .navbar .nav-profile img {
        width: 32px;
        height: 32px;
    }

    /* Judul halaman + tombol aksi: tombol turun ke bawah kalau tidak muat */
    .page-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 1rem !important;
    }

    .page-header h2 {
        margin-bottom: 0;
        flex: 1 1 12rem;
    }

    .page-header .btn {
        padding: 0.55rem 0.9rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .card .card-body {
        padding: 1rem;
    }

    .card .card-title {
        margin-bottom: 0.75rem;
    }

    /* ---------- Kartu angka (KPI) ---------- */
    .kpi-row {
        --bs-gutter-x: 0.75rem;
    }

    .kpi-row > [class*="col"] {
        margin-bottom: 0.75rem !important;
    }

    .kpi-row .card-body {
        padding: 0.9rem;
    }

    .kpi-row .card-body p.mb-4 {
        margin-bottom: 0.5rem !important;
        font-size: 0.78rem;
    }

    .kpi-row .fs-30 {
        font-size: 1.15rem;
        font-weight: 600;
        white-space: nowrap;
    }

    .kpi-row .card-body p:last-child {
        font-size: 0.7rem !important;
        margin-bottom: 0;
    }

    .kpi-row .card-body i[class^="ti-"] {
        font-size: 1.1rem !important;
    }

    /* ---------- Tabel jadi kartu bertumpuk ---------- */
    .table-stack thead {
        display: none;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tfoot,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack tr {
        background: #fff;
        border: 1px solid #e9ecef;
        border-radius: 12px;
        margin-bottom: 0.75rem;
        padding: 0.35rem 0.9rem;
    }

    .table-stack > :not(caption) > * > * {
        --bs-table-bg-type: transparent;
        --bs-table-bg-state: transparent;
        box-shadow: none;
        background: transparent;
    }

    .table-stack tfoot tr {
        background: #f4f5fb;
        border-color: #d9dbf0;
    }

    .table-stack tfoot td {
        color: #1f1f1f !important;
        font-weight: 700;
    }

    .table-stack td {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 0.4rem;
        padding: 0.45rem 0 !important;
        border: 0 !important;
        border-bottom: 1px dashed #eef0f3 !important;
        text-align: right !important;
        white-space: normal;
        color: inherit;
    }

    .table-stack td:last-child {
        border-bottom: 0 !important;
    }

    .table-stack td::before {
        content: attr(data-label);
        flex-shrink: 0;
        margin-right: auto;
        padding-right: 0.75rem;
        font-weight: 600;
        font-size: 0.8rem;
        color: #6c7383;
        text-align: left;
    }

    .table-stack td:not([data-label])::before {
        content: none;
    }

    .table-stack td:not([data-label]) {
        justify-content: center;
        text-align: center !important;
    }

    .table-stack td.stack-hide,
    .table-stack td:empty {
        display: none;
    }

    .table-stack td .btn {
        margin: 0.15rem 0;
    }

    .table-stack td > form.d-inline {
        display: inline-block !important;
    }

    /* Tabel matriks (tetap digeser ke samping) dibuat lebih rapat */
    .table.no-stack {
        font-size: 0.78rem;
    }

    .table.no-stack th,
    .table.no-stack td {
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }

    /* ---------- Laporan: angka ringkasan per hari jadi grid 2 kolom ---------- */
    .ringkasan-stats {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem 1rem !important;
        width: 100%;
        text-align: left !important;
    }

    .ringkasan-stats strong {
        white-space: nowrap;
    }

    /* ---------- Modal penuh lebar di HP ---------- */
    .modal-dialog {
        margin: 0.75rem;
    }

    /* ---------- Login ---------- */
    .auth .auth-form-light {
        padding: 2rem 1.25rem !important;
    }
}

/* ---------- POS kasir ---------- */
.pos-bottom-bar {
    display: none;
}

@media (max-width: 991.98px) {
    .pos-bottom-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid #e9ecef;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    }

    .pos-bottom-bar .total {
        font-size: 1.1rem;
        font-weight: 700;
        color: #4B49AC;
        line-height: 1.2;
    }

    body.has-pos-bar .main-panel {
        padding-bottom: 4.5rem;
    }

    .pos-cart-card.sticky-top {
        position: static;
    }
}

@media (max-width: 767.98px) {
    .pos-item-card .card-body {
        padding: 0.8rem;
    }

    .pos-item-card .card-title {
        font-size: 0.85rem;
        line-height: 1.3;
        margin-bottom: 0.35rem !important;
    }

    .pos-item-card .card-text {
        margin-bottom: 0.5rem !important;
    }

    .pos-item-card .price-row {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .pos-item-card .price-row .fs-5 {
        font-size: 0.95rem !important;
    }

    .pos-item-card .btn-add-item {
        width: 100%;
    }

    .pos-kategori-title {
        font-size: 0.95rem;
        margin-bottom: 0.6rem !important;
    }
}
