/**
 * Stylesheet: KRS Public Restaurant Products & Menu Catalog Modal
 * Expansive Touch UI & Soft UI modal for restaurant table reservations.
 * Follows AGENTS.md: zero inline styles, Soft UI, Touch targets >= 44px, official palette.
 * @package KUADSystem
 */

/* ===== MODAL BACKDROP & DIALOG ===== */
#krs-modal-public-catalog,
.krs-catalog-backdrop {
    position: fixed; inset: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.72); display: none; align-items: center; justify-content: center;
    z-index: 999999; padding: 20px; box-sizing: border-box; opacity: 0; transition: opacity 0.25s ease;
}
#krs-modal-public-catalog.active,
.krs-catalog-backdrop.active { display: flex; opacity: 1; }
body.krs-modal-open { overflow: hidden !important; touch-action: none; }
.krs-catalog-modal-content {
    background: #ffffff; border-radius: 20px; width: 100%; max-width: 960px;
    max-height: 90vh; height: 90vh; display: flex; flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(45, 26, 104, 0.28); overflow: hidden; position: relative;
    box-sizing: border-box; animation: krsModalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes krsModalSlideUp { from { transform: translateY(20px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* Modal Header */
.krs-walkin-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; background: #ffffff; border-bottom: 1.5px solid #f1f5f9; flex-shrink: 0;
}
.krs-walkin-modal-title-wrap { display: flex; align-items: center; gap: 12px; }
.krs-catalog-header-icon {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; color: #2D1A68; flex-shrink: 0;
}
.krs-walkin-modal-title { margin: 0; font-size: 19px; font-weight: 800; color: #2D1A68; }
.krs-catalog-close-btn {
    background: none; border: none; font-size: 28px; line-height: 1; color: #64748b;
    cursor: pointer; width: 44px; height: 44px; display: flex; align-items: center;
    justify-content: center; border-radius: 12px; transition: background 0.15s ease, color 0.15s ease; flex-shrink: 0;
}
.krs-catalog-close-btn:hover { background: #f1f5f9; color: #0f172a; }

/* Modal Body */
.krs-catalog-modal-body {
    flex: 1; overflow-y: auto; padding: 18px 24px; background: #f8fafc;
    -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 16px; box-sizing: border-box;
}

/* ===== SEARCH BAR ===== */
#krs-modal-public-catalog .krs-catalog-search-bar,
.krs-restaurant-catalog-search-bar {
    width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 26px !important;
    box-shadow: 0 2px 8px rgba(45, 26, 104, 0.05) !important;
    padding: 0 16px 0 18px !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-shrink: 0 !important;
    position: relative !important;
    gap: 0 !important;
    margin: 0 !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}
#krs-modal-public-catalog .krs-catalog-search-bar:focus-within,
.krs-restaurant-catalog-search-bar:focus-within {
    border-color: #2D1A68 !important;
    box-shadow: 0 0 0 3px rgba(45, 26, 104, 0.12), 0 4px 14px rgba(45, 26, 104, 0.08) !important;
}

#krs-modal-public-catalog .krs-catalog-search-icon,
.krs-restaurant-catalog-search-bar .krs-catalog-search-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    width: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
    height: 20px !important;
    min-height: 20px !important;
    max-height: 20px !important;
    color: #64748b !important;
    flex-shrink: 0 !important;
    margin: 0 12px 0 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
}
#krs-modal-public-catalog .krs-catalog-search-icon svg,
.krs-restaurant-catalog-search-bar .krs-catalog-search-icon svg {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    stroke: #64748b !important;
    fill: none !important;
    stroke-width: 2.2 !important;
    transition: stroke 0.2s ease !important;
    margin: 0 auto !important;
    padding: 0 !important;
    vertical-align: middle !important;
}
#krs-modal-public-catalog .krs-catalog-search-bar:focus-within .krs-catalog-search-icon svg,
.krs-restaurant-catalog-search-bar:focus-within .krs-catalog-search-icon svg {
    stroke: #2D1A68 !important;
}

#krs-modal-public-catalog .krs-catalog-search-bar input.krs-catalog-search-input,
.krs-restaurant-catalog-search-bar input.krs-catalog-search-input {
    flex: 1 1 auto !important;
    width: auto !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #1e293b !important;
    line-height: normal !important;
    align-self: center !important;
    box-sizing: border-box !important;
}
#krs-modal-public-catalog .krs-catalog-search-bar input.krs-catalog-search-input::placeholder,
.krs-restaurant-catalog-search-bar input.krs-catalog-search-input::placeholder {
    color: #94a3b8 !important;
    font-weight: 500 !important;
    opacity: 1 !important;
}
#krs-modal-public-catalog .krs-catalog-search-bar input.krs-catalog-search-input:focus,
.krs-restaurant-catalog-search-bar input.krs-catalog-search-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

#krs-modal-public-catalog .krs-catalog-search-clear,
.krs-restaurant-catalog-search-bar .krs-catalog-search-clear {
    display: none;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    width: 26px !important;
    min-width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: #f1f5f9 !important;
    color: #64748b !important;
    font-size: 17px !important;
    line-height: 1 !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 0 0 8px !important;
    flex-shrink: 0 !important;
    transition: background 0.15s, color 0.15s !important;
}
#krs-modal-public-catalog .krs-catalog-search-clear.active,
.krs-restaurant-catalog-search-bar .krs-catalog-search-clear.active {
    display: inline-flex !important;
}
#krs-modal-public-catalog .krs-catalog-search-clear:hover,
.krs-restaurant-catalog-search-bar .krs-catalog-search-clear:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

/* ===== FILTER CONTROLS (CATEGORIES & BRANDS) ===== */
.krs-catalog-filters-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 14px rgba(45, 26, 104, 0.04);
    flex-shrink: 0;
}
.krs-catalog-filter-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.krs-catalog-filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
}

.krs-catalog-chips-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    padding: 2px 2px 6px 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.krs-catalog-chips-bar::-webkit-scrollbar { height: 4px; }
.krs-catalog-chips-bar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.krs-catalog-chips-bar .tui-cat-chip {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    min-height: 36px;
    height: 36px;
    border-radius: 18px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}
.krs-catalog-chips-bar .tui-cat-chip:hover { background: #e2e8f0; color: #0f172a; }
.krs-catalog-chips-bar .tui-cat-chip.active {
    background: #2D1A68;
    color: #ffffff;
    border-color: #2D1A68;
    box-shadow: 0 4px 10px rgba(45, 26, 104, 0.25);
}

/* ===== PRODUCTS GRID & CENTERED LOADER ===== */
.krs-catalog-grid-wrap {
    flex: 1; display: flex; flex-direction: column; min-height: 320px;
    width: 100%; box-sizing: border-box; position: relative;
}
.krs-catalog-loader {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 60px 20px; gap: 16px; width: 100%; min-height: 280px; box-sizing: border-box;
}
.krs-catalog-spinner-ring {
    width: 48px; height: 48px; border: 4px solid #e2e8f0; border-top-color: #2D1A68;
    border-right-color: #1BA59D; border-radius: 50%;
    animation: krsCatalogSpin 0.85s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
    box-sizing: border-box; flex-shrink: 0;
}
@keyframes krsCatalogSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.krs-catalog-loader-text {
    margin: 0; font-size: 15px; font-weight: 600; color: #64748b;
    text-align: center; line-height: 1.4; letter-spacing: 0.2px;
}
.krs-catalog-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 60px 20px; color: #64748b; min-height: 200px; box-sizing: border-box;
}
.krs-catalog-empty-text { margin: 0; font-size: 15px; font-weight: 600; color: #64748b; }
.krs-catalog-products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; width: 100%; }
.krs-catalog-card {
    background: #ffffff; border: 1.5px solid #e2e8f0; border-radius: 16px; padding: 12px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
    box-shadow: 0 4px 12px rgba(45, 26, 104, 0.04); transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-sizing: border-box; overflow: hidden; position: relative; min-width: 0;
}
.krs-catalog-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(45, 26, 104, 0.09); border-color: #cbd5e1; }
.krs-catalog-card.in-cart { border-color: #1BA59D; background: #f8fdfc; box-shadow: 0 0 0 1.5px #1BA59D, 0 6px 18px rgba(27, 165, 157, 0.12); }

.krs-catalog-card-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.krs-catalog-thumb-wrap {
    width: 100%;
    height: 120px;
    border-radius: 10px;
    overflow: hidden;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}
.krs-catalog-thumb { width: 100%; height: 100%; object-fit: cover; }
.krs-catalog-thumb-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }

.krs-catalog-badges { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; }
.krs-catalog-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: #f1f5f9;
    color: #475569;
    padding: 2px 7px;
    border-radius: 6px;
}
.krs-catalog-badge.brand-badge { background: #fdf2f8; color: #C05A86; }

.krs-catalog-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
}

/* Card Bottom & Actions */
.krs-catalog-card-bottom {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    margin-top: auto;
    box-sizing: border-box;
    width: 100%;
}
.krs-catalog-price-row { display: flex; align-items: baseline; justify-content: space-between; width: 100%; }
.krs-catalog-price { font-size: 16px; font-weight: 800; color: #2D1A68; }

.krs-catalog-action-wrap { width: 100%; display: flex; align-items: center; box-sizing: border-box; }
.krs-catalog-add-btn {
    width: 100%;
    min-height: 38px;
    height: 38px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
    background: #403A60;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(64, 58, 96, 0.18);
}
.krs-catalog-add-btn:hover {
    background: #2D1A68;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(45, 26, 104, 0.25);
}
.krs-catalog-btn-plus { font-size: 16px; font-weight: 800; line-height: 1; }

/* Stepper Component (Catalog Modal & Attached Items) */
.krs-catalog-stepper,
#krs-modal-public-catalog .krs-catalog-stepper,
.krs-product-row-actions .krs-catalog-stepper {
    width: 100% !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 1.5px solid #1BA59D !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 6px rgba(27, 165, 157, 0.15) !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: default !important;
}

.krs-product-row-actions .krs-catalog-stepper {
    width: 105px !important;
    min-width: 105px !important;
    max-width: 105px !important;
    flex-shrink: 0 !important;
}

button.krs-catalog-step-btn,
.krs-catalog-step-btn,
#krs-modal-public-catalog .krs-catalog-step-btn,
.krs-product-row-actions .krs-catalog-step-btn {
    width: 38px !important;
    min-width: 36px !important;
    max-width: 38px !important;
    height: 100% !important;
    min-height: 36px !important;
    max-height: 38px !important;
    background: #1BA59D !important;
    background-color: #1BA59D !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s ease, transform 0.1s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

button.krs-catalog-step-btn:hover,
.krs-catalog-step-btn:hover,
#krs-modal-public-catalog .krs-catalog-step-btn:hover,
.krs-product-row-actions .krs-catalog-step-btn:hover {
    background: #158079 !important;
    background-color: #158079 !important;
    color: #ffffff !important;
}

button.krs-catalog-step-btn:active,
.krs-catalog-step-btn:active {
    transform: scale(0.92) !important;
}

.krs-catalog-step-val,
#krs-modal-public-catalog .krs-catalog-step-val,
.krs-product-row-actions .krs-catalog-step-val {
    flex: 1 1 auto !important;
    text-align: center !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    padding: 0 4px !important;
    user-select: none !important;
    line-height: 38px !important;
    height: 100% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    background: transparent !important;
}

/* Modal Footer */
.krs-catalog-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 16px;
    flex-shrink: 0;
}
.krs-catalog-footer-summary { display: flex; align-items: center; gap: 8px; font-size: 15px; color: #334155; }
.krs-catalog-summary-count { color: #1BA59D; font-size: 17px; font-weight: 800; }
.krs-catalog-summary-total { color: #2D1A68; font-size: 18px; font-weight: 800; }
.krs-catalog-btn-done {
    min-height: 48px;
    height: 48px;
    padding: 0 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ===== RESPONSIVE BREAKPOINTS (TABLETS & PHONES) ===== */
@media (max-width: 900px) {
    .krs-catalog-modal-content { max-width: 95vw; max-height: 92vh; }
    .krs-catalog-products-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
}

@media (max-width: 768px) {
    #krs-modal-public-catalog,
    .krs-catalog-backdrop { padding: 0 !important; align-items: stretch !important; justify-content: stretch !important; }
    .krs-catalog-modal-content {
        width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .krs-walkin-modal-header {
        padding: 12px 16px !important;
        position: sticky;
        top: 0;
        z-index: 20;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }
    .krs-walkin-modal-title { font-size: 16px !important; }
    .krs-catalog-modal-body { padding: 12px !important; flex: 1 !important; -webkit-overflow-scrolling: touch; gap: 12px !important; }
    .krs-catalog-filters-wrap { padding: 10px 12px !important; margin-bottom: 0 !important; gap: 10px !important; }
    #krs-modal-public-catalog .krs-catalog-search-bar,
    .krs-restaurant-catalog-search-bar {
        height: 46px !important;
        min-height: 46px !important;
        max-height: 46px !important;
        border-radius: 23px !important;
        padding: 0 12px 0 14px !important;
    }
    #krs-modal-public-catalog .krs-catalog-search-icon,
    .krs-restaurant-catalog-search-bar .krs-catalog-search-icon {
        width: 18px !important;
        min-width: 18px !important;
        max-width: 18px !important;
        height: 18px !important;
        min-height: 18px !important;
        max-height: 18px !important;
        margin: 0 10px 0 0 !important;
    }
    #krs-modal-public-catalog .krs-catalog-search-icon svg,
    .krs-restaurant-catalog-search-bar .krs-catalog-search-icon svg {
        width: 18px !important;
        height: 18px !important;
    }
    #krs-modal-public-catalog .krs-catalog-search-bar input.krs-catalog-search-input,
    .krs-restaurant-catalog-search-bar input.krs-catalog-search-input {
        font-size: 14px !important;
        height: 100% !important;
        line-height: normal !important;
        padding: 0 !important;
    }
    .krs-catalog-products-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .krs-catalog-card { padding: 10px !important; border-radius: 14px !important; gap: 8px !important; }
    .krs-catalog-thumb-wrap { height: 105px !important; border-radius: 10px !important; }
    .krs-catalog-title { font-size: 13px !important; min-height: 2.6em !important; }
    .krs-catalog-price { font-size: 15px !important; }
    .krs-catalog-add-btn,
    #krs-modal-public-catalog .krs-catalog-stepper { height: 38px !important; min-height: 38px !important; font-size: 13px !important; }
    #krs-modal-public-catalog .krs-catalog-step-btn { width: 38px !important; font-size: 16px !important; }
    #krs-modal-public-catalog .krs-catalog-step-val { font-size: 14px !important; }
    .krs-catalog-modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 20;
        padding: 12px 16px !important;
        flex-direction: column !important;
        gap: 10px !important;
        background: #ffffff;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    }
    .krs-catalog-footer-summary { width: 100% !important; justify-content: space-between !important; font-size: 14px !important; }
    .krs-catalog-btn-done { width: 100% !important; height: 46px !important; min-height: 46px !important; font-size: 15px !important; justify-content: center !important; }
}

@media (max-width: 360px) {
    .krs-catalog-products-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
}
