/*! ພັດທະນາໂດຍ ບໍລິສັດຮ່ວມພັດທະນາ Atphosting24 ຈຳກັດ ແລະ ICOM */
/* Responsive application shell. Keep financial tables readable inside their own scroll areas. */
:root {
    --mobile-nav-height: 0px;
    --pwa-bottom-offset: 16px;
}
html { -webkit-text-size-adjust: 100%; }
icom-staff-app, icom-platform-app, icom-guest-app { display: block; min-width: 0; }
.workspace, .main, .page, .panel, .modal-body, .platform-title-group { min-width: 0; }
.table-wrap { max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.drawer-close, .mobile-app-nav, .mobile-cart-shortcut { display: none; }
.modal { min-width: 0; }
.modal-body { min-height: 0; }
.modal h2, .page-title, .page-heading h2, .platform-detail-hero h2 { overflow-wrap: anywhere; }
.modal .table-wrap { margin-left: 0; margin-right: 0; }
#basket, #pos-basket, #guest-menu { scroll-margin-top: 150px; }

@media (pointer: coarse) {
    .icon-btn, .modal-close, .close-modal, .btn-small, .quantity-control button, .quantity button,
    .add, .category, .category-tab, .category-chip, .tab, .language-toggle, .language,
    .password-toggle, .login-locale button { min-width: 44px; min-height: 44px; }
    .nav-link { min-height: 44px; }
    input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }
    .btn:hover, .product-card:hover, .dish:hover, .table-tile:hover { transform: none; }
}

@media (min-width: 901px) and (max-width: 1199px) {
    .main { padding: 20px; }
    .pos-layout { grid-template-columns: minmax(0, 1fr) minmax(285px, 320px); }
    .kitchen-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kitchen-board > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    icom-guest-app .page { grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; }
    icom-guest-app .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    icom-guest-app .browse-only .products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    body:has(icom-staff-app), body:has(icom-platform-app), body:has(icom-guest-app) {
        --mobile-nav-height: calc(70px + env(safe-area-inset-bottom, 0px));
        --pwa-bottom-offset: 86px;
        padding-bottom: var(--mobile-nav-height);
    }
    body:has(icom-guest-app .tracking) { --mobile-nav-height: 0px; --pwa-bottom-offset: 16px; }
    body.nav-open, body:has(.modal-backdrop), body:has(.modal-overlay) { overflow: hidden; }
    icom-staff-app, icom-platform-app { min-height: 100dvh; }
    .workspace { min-height: calc(100dvh - var(--mobile-nav-height)); }
    .sidebar {
        width: min(320px, calc(100vw - 48px));
        max-height: 100dvh;
        padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
        overscroll-behavior: contain;
        z-index: 70;
    }
    .sidebar .brand { padding-right: 38px; }
    .drawer-close { display: inline-flex; position: sticky; top: 0; align-self: flex-end; flex-shrink: 0; margin-bottom: -44px; background: #eff7f3; z-index: 3; }
    .sidebar-footer { margin-top: 20px; }
    .sidebar-footer .icon-btn { width: 44px; height: 44px; }
    .mobile-overlay { z-index: 65; }
    .nav-link { min-height: 48px; font-size: 14px; }
    .workspace > .topbar {
        position: sticky;
        top: 0;
        height: auto;
        min-height: 74px;
        padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
        border-bottom: 1px solid var(--line);
        box-shadow: 0 3px 16px #143c3405;
        z-index: 25;
    }
    .topbar-title, .platform-title-group { flex: 1; }
    .page-title { font-size: clamp(20px, 3.3vw, 27px); line-height: 1.4; }
    .topbar .top-actions { flex-shrink: 0; gap: 10px; }
    .topbar .avatar, .topbar-title > .menu-toggle, .icon-btn, .modal-close, .close-modal {
        width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    }
    .btn, .btn-small, .quantity-control button, .quantity button, .add, .category, .tab,
    .language-toggle, .language, .password-toggle, .login-locale button { min-height: 44px; }
    .quantity-control button, .quantity button, .add { min-width: 44px; }
    .quantity-control span { min-width: 28px; }
    .btn { white-space: normal; text-align: center; }
    input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }
    .main { padding: 20px max(16px, env(safe-area-inset-right, 0px)) 30px max(16px, env(safe-area-inset-left, 0px)); }
    .branch-selector select { min-height: 44px; }
    .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
    .dashboard-grid > .panel .table-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .kitchen-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kitchen-board > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .table-wrap table { min-width: 580px; }
    .table-wrap .platform-table { min-width: 740px; }
    .table-wrap { margin-left: 14px; margin-right: 14px; }
    .table-wrap th, .table-wrap td { padding: 12px; }
    .row-actions, .table-actions { gap: 7px; }
    .toolbar, .panel-head { gap: 12px; flex-wrap: wrap; }
    .toolbar .search-field { min-width: 0; }
    .toolbar input, .toolbar select { max-width: 100%; }
    .modal-backdrop, .modal-overlay { padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
    .modal, .modal.wide, .modal-lg { max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
    .modal > header, .modal-header, .modal-head { padding: 14px 18px; }
    .modal > header h2, .modal-header h2, .modal-head h2 { font-size: 20px; }
    .modal-body { padding: 18px; }
    .modal-footer, .form-actions { flex-wrap: wrap; }
    .modal-footer .btn, .form-actions .btn { flex: 1 1 auto; }
    .mobile-app-nav {
        position: fixed;
        display: flex;
        justify-content: space-evenly;
        align-items: stretch;
        left: 0; right: 0; bottom: 0;
        height: var(--mobile-nav-height);
        padding: 6px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
        background: #fff;
        border-top: 1px solid #dce9e2;
        box-shadow: 0 -4px 24px #183f320b;
        z-index: 45;
    }
    .mobile-app-nav > a, .mobile-app-nav > button {
        display: flex; flex: 1 1 0; flex-direction: column;
        justify-content: center; align-items: center; gap: 4px;
        min-width: 0; min-height: 54px; margin: 0 2px; padding: 5px 3px;
        color: #637c70; background: transparent; border: 0; border-radius: 12px;
        font: inherit; font-size: 11px; line-height: 1.35; text-decoration: none; text-align: center;
    }
    .mobile-app-nav > .active { background: #e5f4eb; color: #006b5b; font-weight: 650; }
    .mobile-app-nav svg { width: 23px; height: 23px; }
    .mobile-app-nav span { max-width: 100%; overflow-wrap: anywhere; }
    .angular-toast, #toast, #platform-toast, icom-guest-app .toast {
        bottom: calc(var(--mobile-nav-height) + 16px) !important;
        max-width: calc(100vw - 32px); white-space: normal; overflow-wrap: anywhere; text-align: center;
    }
    icom-guest-app > .topbar {
        position: sticky; top: 0; z-index: 25; background: #fafcf9f5;
        padding: calc(12px + env(safe-area-inset-top, 0px)) max(4%, env(safe-area-inset-right, 0px)) 12px max(4%, env(safe-area-inset-left, 0px));
        border-bottom: 1px solid #e4ede7; margin-bottom: 16px;
    }
    icom-guest-app .page { display: block; }
    icom-guest-app .products { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
    icom-guest-app .browse-only .products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    icom-guest-app .basket { position: static; margin-top: 28px; }
    icom-guest-app .basket form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
    icom-guest-app .basket form .wide { grid-column: 1 / -1; }
    icom-guest-app .dish-image { height: 175px; }
    icom-guest-app .dish-bottom { flex-wrap: wrap; }
    icom-guest-app .dish h3 { overflow-wrap: anywhere; }
    icom-guest-app .bag-link { min-height: 44px; }
    icom-guest-app .guest-mobile-nav { gap: 10px; }
    .guest-mobile-nav > a { flex: 0 1 110px; }
    .guest-mobile-nav > .guest-cart-link {
        flex: 1 1 auto; flex-direction: row; justify-content: flex-start; gap: 9px; margin: 2px 0 6px;
        padding: 8px 14px; min-height: 50px; background: #1e6852; color: #fff;
    }
    .guest-cart-link > strong { margin-left: auto; font-size: 13px; white-space: nowrap; }
    .guest-cart-link small { display: inline-block; border-radius: 8px; background: #ffffff26; min-width: 22px; padding: 2px 5px; margin-left: 3px; }
    icom-guest-app .footer { padding-bottom: 28px; }
    .login-form-side { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
    .login-copyright { max-width: calc(100% - 40px); text-align: center; }
    .platform-pagination .flex { flex-wrap: wrap; }
}

@media (max-width: 720px) {
    body:has(icom-pos) { --pwa-bottom-offset: 154px; }
    icom-pos { display: block; padding-bottom: 74px; }
    .mobile-cart-shortcut {
        display: flex; align-items: center; gap: 10px; position: fixed;
        left: max(14px, env(safe-area-inset-left, 0px)); right: max(14px, env(safe-area-inset-right, 0px));
        bottom: calc(var(--mobile-nav-height) + 10px); min-height: 56px; padding: 10px 16px;
        color: #fff; background: #006b5b; border-radius: 15px; box-shadow: 0 6px 24px #004a3630;
        font: inherit; text-align: left; z-index: 44;
    }
    .mobile-cart-shortcut > span { flex: 1; font-weight: 600; font-size: 13px; }
    .mobile-cart-shortcut small { display: block; color: #d0e9de; font-size: 11px; font-weight: 400; }
    .mobile-cart-shortcut > strong { font-size: 14px; white-space: nowrap; }
    body:has(icom-pos) .angular-toast, body:has(icom-pos) #toast { bottom: calc(var(--mobile-nav-height) + 80px) !important; }
    .topbar:has(.branch-selector) .topbar-title { width: 100%; }
    .topbar:has(.branch-selector) .top-actions { width: 100%; justify-content: space-between; }
    .branch-selector { max-width: calc(100vw - 168px); }
    .branch-selector > span { display: none; }
    .branch-selector select { width: 100%; min-width: 130px; }
    .pos-layout { gap: 24px; }
    .pos-layout .cart-panel { position: static; }
    .draft-banner { flex-wrap: wrap; }
    .kitchen-board { grid-template-columns: minmax(0, 1fr); }
    .dashboard-grid > .panel .table-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    icom-guest-app .products, icom-guest-app .browse-only .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    icom-guest-app .section-top { flex-direction: column; align-items: stretch; }
    icom-guest-app .search { max-width: none; }
    icom-guest-app .hero { min-height: 280px; padding: 28px; }
    icom-guest-app .hero h1 { font-size: 30px; }
    .platform-title-group { align-items: center; }
    .platform-title-group > div { min-width: 0; }
    .platform-top-subtitle { display: none; }
    .platform-filters > * { width: 100%; }
    .platform-filters select { max-width: none; }
    .platform-event header { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .main { padding-top: 16px; }
    .workspace > .topbar { gap: 8px; }
    .topbar .top-actions { gap: 6px; }
    .page-title { font-size: 21px; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid .full { grid-column: auto; }
    .cart-options { grid-template-columns: minmax(0, 1fr); }
    .cart-options > .field:last-child { grid-column: auto; }
    .cart-line { grid-template-columns: minmax(0, 1fr); }
    .cart-line > .quantity-control { justify-self: end; }
    .item-note { max-width: 100%; }
    .grand-total { flex-wrap: wrap; }
    .page-heading > .flex, .toolbar-actions, .platform-actions { max-width: 100%; }
    .panel-head h2 { font-size: 18px; }
    .modal-backdrop, .modal-overlay { align-items: flex-end; padding: env(safe-area-inset-top, 0px) 0 0; }
    .modal, .modal.wide, .modal-lg { width: 100%; max-height: calc(100dvh - env(safe-area-inset-top, 0px)); border-radius: 18px 18px 0 0; }
    .modal-body { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
    .modal > header h2, .modal-header h2, .modal-head h2 { font-size: 18px; }
    icom-guest-app .basket form { display: block; }
    icom-guest-app .dish-image { height: 155px; }
    icom-guest-app .dish-body { padding: 12px; }
    icom-guest-app .hero { min-height: 310px; padding: 25px; }
    icom-guest-app .hero-art { bottom: -35px; }
    icom-guest-app .tracking { margin-left: 4%; margin-right: 4%; padding: 23px; }
    icom-guest-app .cart-line-main { flex-wrap: wrap; }
    .guest-mobile-nav > a { flex-basis: 76px; }
    .guest-mobile-nav > .guest-cart-link { padding-left: 10px; padding-right: 10px; gap: 6px; }
    .guest-cart-link > strong { font-size: 12px; }
    .mobile-app-nav > a, .mobile-app-nav > button { font-size: 10px; }
    .platform-title-group { gap: 8px; }
    icom-platform-app .page-title { font-size: 18px; }
    .platform-hero { padding: 20px; }
}

@media (max-width: 360px) {
    .mobile-app-nav > a, .mobile-app-nav > button { margin: 0; font-size: 9px; }
    icom-guest-app .topbar .brand { gap: 7px; }
    icom-guest-app .topbar .top-actions { gap: 6px; }
    icom-guest-app .brand img { width: 32px; height: 32px; }
    .guest-cart-link > svg { display: none; }
    .metric { padding-left: 13px; padding-right: 13px; }
    .metric strong { font-size: 26px; }
}

@media (max-height: 520px) and (max-width: 900px) {
    .workspace > .topbar { position: relative; }
    .modal-backdrop, .modal-overlay { align-items: center; }
    .modal, .modal.wide, .modal-lg { max-height: calc(100dvh - 12px); }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .sidebar, .mobile-app-nav, .btn, .dish, .product-card, .table-tile { transition: none; }
}

@media print {
    .mobile-app-nav, .mobile-cart-shortcut, .drawer-close { display: none !important; }
    body:has(icom-staff-app), body:has(icom-platform-app), body:has(icom-guest-app) { padding-bottom: 0; }
}
