/**
 * Responsive scaling for common laptop sizes:
 * - 1366×768 (compact)
 * - 1920×1080 (comfortable)
 */

/* ========== Global admin/content density ========== */
@media (max-width: 1400px) {
    :root {
        --sidebar-width-expanded: 220px;
    }

    .sidebar-expanded {
        max-width: 220px !important;
    }

    #mainContent > main {
        padding: 1rem 1.25rem !important;
    }

    .modern-card,
    .dashboard-card {
        transform: none !important;
    }

    .modern-card:hover {
        transform: none !important;
    }

    table th,
    table td {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        font-size: 0.875rem !important;
    }
}

@media (max-height: 820px) {
    #mainContent > main {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .sidebar .h-20 {
        height: 3.5rem !important;
    }

    .sidebar-link {
        padding-top: 0.45rem !important;
        padding-bottom: 0.45rem !important;
    }

    #mainContent header,
    #mainContent .h-20 {
        min-height: 3.5rem !important;
        height: auto !important;
        padding-top: 0.4rem !important;
        padding-bottom: 0.4rem !important;
    }
}

/* ========== POS page ========== */
.pos-page {
    overflow: hidden;
}

.pos-page .pos-header-inner {
    min-height: 3.5rem;
}

/* Compact laptop width (~1366) */
@media (max-width: 1400px) {
    .pos-page header .pos-brand-text {
        font-size: 0.95rem !important;
    }

    /* Hide button labels only — keep theme icons visible */
    .pos-page header .pos-header-actions > a > span,
    .pos-page header .pos-header-actions > button > span:not(.theme-icon-moon):not(.theme-icon-sun) {
        display: none !important;
    }

    .pos-page header .pos-header-actions .theme-icon-moon,
    .pos-page header .pos-header-actions .theme-icon-sun {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    html[data-theme="dark"] .pos-page header .pos-header-actions .theme-icon-moon {
        display: none !important;
    }

    html:not([data-theme="dark"]) .pos-page header .pos-header-actions .theme-icon-sun {
        display: none !important;
    }

    .pos-page header .pos-header-actions a,
    .pos-page header .pos-header-actions button {
        padding-left: 0.55rem !important;
        padding-right: 0.55rem !important;
    }

    .pos-page #product-grid-wrapper {
        padding: 0.65rem 0.65rem 0 !important;
    }

    .pos-page #categories-wrapper {
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.25rem !important;
    }

    .pos-page .category-btn {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    .pos-page .category-btn i {
        width: 1rem !important;
        height: 1rem !important;
        margin-right: 0.35rem !important;
    }

    .pos-page aside.pos-cart {
        width: 340px !important;
        min-width: 300px !important;
    }

    .pos-page aside.pos-cart .p-4 {
        padding: 0.65rem !important;
    }

    .pos-page aside.pos-cart .space-y-4 {
        gap: 0.65rem !important;
    }

    .pos-page #bottom-total {
        font-size: 1.5rem !important;
    }

    .pos-page aside.pos-cart .grid button {
        padding: 0.65rem 0.5rem !important;
    }

    .pos-page aside.pos-cart .grid button span {
        font-size: 0.75rem !important;
    }

    .pos-page aside.pos-cart .grid #create-quotation-btn span,
    .pos-page aside.pos-cart .grid #open-checkout-modal-btn span {
        font-size: 0.9rem !important;
    }

    .pos-page .product-card img {
        height: 5.5rem !important;
    }

    .pos-page .product-card h3 {
        font-size: 0.75rem !important;
    }

    .pos-page .product-card .product-price {
        font-size: 0.8rem !important;
        margin-top: 0.15rem !important;
    }

    .pos-page .product-card .p-3 {
        padding: 0.45rem !important;
    }

    .pos-page .product-card .p-2 {
        padding: 0.35rem !important;
    }

    .pos-page .stock-badge {
        font-size: 8px !important;
        padding: 2px 5px !important;
        top: 4px !important;
        right: 4px !important;
    }
}

/* Short screens (768 height) — critical for checkout modal */
@media (max-height: 820px) {
    .pos-page header .pos-header-inner,
    .pos-page header .h-16 {
        height: 3rem !important;
        min-height: 3rem !important;
    }

    .pos-page #checkout-modal > div {
        max-height: 92vh !important;
        max-width: min(640px, 96vw) !important;
        padding: 0.75rem 1rem !important;
        margin: 0.5rem !important;
    }

    .pos-page #checkout-modal h2 {
        font-size: 1rem !important;
        margin-bottom: 0.35rem !important;
    }

    .pos-page #checkout-modal .space-y-3 > * + *,
    .pos-page #checkout-modal .space-y-4 > * + * {
        margin-top: 0.45rem !important;
    }

    .pos-page #checkout-modal .text-2xl {
        font-size: 1.25rem !important;
    }

    .pos-page #checkout-modal .text-xl {
        font-size: 1.05rem !important;
    }

    .pos-page #checkout-modal input,
    .pos-page #checkout-modal textarea,
    .pos-page #checkout-modal select {
        padding-top: 0.4rem !important;
        padding-bottom: 0.4rem !important;
        font-size: 0.875rem !important;
    }

    .pos-page #checkout-modal .cash-btn {
        padding: 0.35rem 0.4rem !important;
        font-size: 0.7rem !important;
    }

    .pos-page #checkout-modal .payment-method-btn {
        padding-top: 0.35rem !important;
        padding-bottom: 0.35rem !important;
        font-size: 0.8rem !important;
    }

    .pos-page #parked-bills-modal > div,
    .pos-page #unit-select-modal > div,
    .pos-page #add-customer-modal > div {
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .pos-page aside.pos-cart .grid button {
        padding: 0.5rem !important;
    }

    .pos-page #bottom-total {
        font-size: 1.35rem !important;
    }
}

/* Comfortable large screens */
@media (min-width: 1800px) and (min-height: 980px) {
    .pos-page aside.pos-cart {
        width: 440px !important;
    }

    .pos-page .product-card img {
        height: 8.5rem !important;
    }
}

/* Prevent horizontal page scroll on cramped layouts */
@media (max-width: 1400px) {
    body.pos-page,
    .pos-page .flex.flex-col.h-screen {
        max-width: 100vw;
        overflow-x: hidden;
    }
}
