/* =========================================
   MARKET POS SYSTEM - COMPLETE REDESIGN V2
   Theme: Modern Retail (Clean, High Contrast, Touch-First)
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
    /* --- Color Palette --- */
    --primary: #2563eb;
    /* Royal Blue */
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;

    --secondary: #64748b;
    /* Slate */

    --accent: #f59e0b;
    /* Amber/Orange for highlights */

    --danger: #ef4444;
    --success: #10b981;

    --bg-body: #f1f5f9;
    /* Light Gray Background */
    --bg-card: #ffffff;
    --bg-panel: #ffffff;

    --text-head: #0f172a;
    /* Nearly Black */
    --text-body: #334155;
    /* Dark Slate */
    --text-muted: #94a3b8;

    --border: #e2e8f0;

    /* --- Dimensions --- */
    --cart-width: 420px;
    --header-height: 70px;
    --radius: 1rem;

    /* --- Shadows --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* --- Transitions --- */
    --trans-fast: 0.15s ease;
    --trans-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Manrope', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    user-select: none;
    /* Kiosk Mode */
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}


/* =========================================
   LAYOUT ARCHITECTURE (CSS GRID)
   ========================================= */

.app-layout {
    display: grid;
    grid-template-columns: 1fr var(--cart-width);
    /* Main Content | Cart */
    grid-template-rows: 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* --- LEFT PANEL: PRODUCTS & NAV --- */
.main-stage {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 1.5rem;
    position: relative;
}

/* Header/Top Bar */
.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-head);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    background: var(--primary);
    color: white;
    border-radius: 0.75rem;
    padding: 0.5rem;
    display: flex;
    box-shadow: var(--shadow-md);
}

/* Category Filter Rail */
.category-rail {
    display: flex;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    flex-shrink: 0;
}

.cat-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-body);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--trans-fast);
    box-shadow: var(--shadow-sm);
    scroll-snap-align: start;
}

.cat-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cat-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Products Grid */
.products-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    padding-bottom: 4rem;
    /* Bottom spacing */
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1.25rem;
}

/* Product Card */
.prod-card {
    background: var(--bg-card);
    border-radius: 1.25rem;
    padding: 1rem;
    border: 2px solid transparent;
    /* Prepare for border transition */
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: var(--trans-normal);
    position: relative;
    overflow: hidden;
}

.prod-card:active {
    transform: scale(0.96);
}

.prod-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.prod-img-box {
    width: 100%;
    height: 120px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prod-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
    transition: transform 0.3s;
}

.prod-card:hover .prod-img {
    transform: scale(1.1);
}

.prod-info {
    width: 100%;
}

.prod-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-head);
    line-height: 1.35;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.7em;
}

.prod-price {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    display: inline-block;
}

/* --- RIGHT PANEL: CART --- */
.cart-sidebar {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.03);
    z-index: 50;
}

.cart-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.cart-head-title {
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
}

.empty-cart-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.7;
}

/* Cart Item */
.cart-item {
    background: white;
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    transition: var(--trans-fast);
    border: 1px solid transparent;
}

.cart-item:hover {
    transform: translateX(-2px);
    border-color: var(--border);
}

.cart-item-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cart-item-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-head);
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.cart-item-name:hover {
    text-decoration: underline;
    color: var(--primary);
}

.cart-item-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cart-item-qty-ui {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: 0.75rem;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    border: none;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 700;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.qty-btn:active {
    background: #e2e8f0;
}

.qty-display {
    width: 28px;
    text-align: center;
    font-weight: 700;
}

/* Cart Bottom */
.cart-footer {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.03);
}

/* Smart Search Bar */
.smart-search {
    position: relative;
    margin-bottom: 1.25rem;
}

.search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border-radius: 1rem;
    border: 2px solid var(--bg-body);
    background: var(--bg-body);
    font-size: 1rem;
    font-weight: 600;
    transition: var(--trans-fast);
}

.search-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 1rem;
    color: var(--text-muted);
}

/* Search Dropdown Results */
.search-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    margin-bottom: 0.5rem;
}

.search-dropdown.active {
    display: block;
    animation: fadeIn 0.15s ease;
}

.search-result-item {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--bg-body);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.1s;
    font-size: 0.95rem;
}

.search-result-item:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.search-result-item:last-child {
    border-bottom: none;
}

.price-summary {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.25rem;
}

.summary-label {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.summary-total {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-head);
    letter-spacing: -1px;
}

.pay-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn-pay {
    height: 60px;
    border-radius: 1rem;
    border: none;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--trans-fast);
    color: white;
}

.btn-pay:active {
    transform: scale(0.97);
}

.btn-pay.cash {
    background: var(--success);
    box-shadow: 0 8px 15px -4px rgba(16, 185, 129, 0.4);
}

.btn-pay.all {
    background: var(--text-head);
    box-shadow: 0 8px 15px -4px rgba(15, 23, 42, 0.4);
}

/* Dark button for general Pay */


/* =========================================
   MANAGEMENT PAGES (Table, Card Layouts)
   ========================================= */

.management-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 2rem;
    max-width: 1440px;
    margin: 0 auto;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-heading {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-head);
}

.content-card {
    background: white;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

/* Modern Data Table */
.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th {
    background: #f8fafc;
    text-align: left;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modern-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--bg-body);
    vertical-align: middle;
}

.modern-table tr:hover {
    background: #fdfdfd;
}


/* =========================================
   COMPONENTS
   ========================================= */

/* Admin FAB */
.admin-fab {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 1000;
}

.fab-toggle {
    width: 60px;
    height: 60px;
    border-radius: 20px;
    /* Squircle */
    background: var(--text-head);
    color: white;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: var(--trans-normal);
    border: none;
}

.fab-toggle:hover {
    transform: rotate(90deg) scale(1.1);
}

.fab-menu {
    position: absolute;
    bottom: 80px;
    left: 0;
    background: white;
    padding: 0.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: none;
    width: 200px;
    animation: slideUp 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fab-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    text-decoration: none;
    color: var(--text-body);
    font-weight: 600;
    transition: 0.1s;
}

.fab-link:hover {
    background: var(--bg-body);
    color: var(--primary);
}

/* Badges */
.badge {
    padding: 0.35rem 0.85rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.b-success {
    background: #dcfce7;
    color: #15803d;
}

.b-warn {
    background: #fef3c7;
    color: #b45309;
}

.b-danger {
    background: #fee2e2;
    color: #b91c1c;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.open {
    display: flex;
    animation: fadeIn 0.2s;
}

.modal-box {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

/* Toast */
.toast-msg {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: var(--text-head);
    color: white;
    padding: 1rem 2rem;
    border-radius: 100px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transition: 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-msg.visible {
    transform: translateX(-50%) translateY(0);
}

/* Buttons General */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: var(--trans-fast);
}

.btn-pri {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-pri:hover {
    background: var(--primary-dark);
}

.btn-sec {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-body);
}

.btn-sec:hover {
    background: var(--bg-body);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
}

@media print {

    .cart-sidebar,
    .admin-fab,
    .stage-header {
        display: none !important;
    }

    .app-layout {
        display: block;
        height: auto;
    }
}