:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --secondary: #3b82f6;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sidebar-width: 400px;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
}

/* POS specific body state */
body.pos-active {
    overflow: hidden;
    height: 100vh;
}

.view {
    display: none;
    min-height: 100vh;
}

.view.active {
    display: block;
}

#view-pos.active {
    display: flex;
    height: 100vh;
}

/* Products Section */
.products-section {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100%;
}

@media (max-width: 768px) {
    .products-section {
        padding: 1rem;
    }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

.category-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab, .cat-tab {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: white;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tab.active, .cat-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 4), 1fr);
    gap: 1.5rem;
}

.product-card {
    background: white;
    padding: 0.4rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    aspect-ratio: 1 / 1;
    justify-content: center;
    align-items: center;
    container-type: inline-size; /* Enable container queries */
}

.product-grid.no-icons .product-card {
    text-align: center;
    padding: 1.5rem 1rem;
}

.product-grid.no-icons .product-name {
    margin-top: 0;
    font-size: 1rem;
}

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

.product-image {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f1f5f9;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.product-name {
    font-weight: 700;
    font-size: clamp(0.85rem, 10cqw, 1.125rem); /* Increased size */
    color: var(--text-main);
    margin-bottom: 0.125rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.1;
}

.product-price {
    color: var(--primary);
    font-weight: 800;
    font-size: clamp(0.7rem, 7cqw, 0.9375rem); /* Increased price size */
}

/* Sidebar Section */
.cart-sidebar {
    width: var(--sidebar-width);
    background: white;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out, opacity 0.2s;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

.sidebar-view.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
    position: relative; /* Take up space when active */
}

/* Specific view adjustments */
#cart-view { transform: translateX(0); opacity: 1; pointer-events: all; }
#cart-view.inactive { transform: translateX(-100%); opacity: 0; pointer-events: none; position: absolute; }

#payment-view { transform: translateX(100%); }
#payment-view.active { transform: translateX(0); }

.cart-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-info h4 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.item-info p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.item-qty {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cart-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.summary-row.total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    font-size: 1.25rem;
    font-weight: 800;
}

.btn-checkout {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 1rem;
}

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

.btn-print {
    width: 100%;
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.product-image {
    font-size: clamp(1.2rem, 30cqw, 3rem); /* Dynamic emoji size */
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.125rem;
    background: none;
    border: none;
    box-shadow: none;
}

/* Mobile & Tablet Responsive */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 350px;
    }
    .settings-grid {
        grid-template-columns: 250px 1fr;
    }
}

@media (max-width: 768px) {
    #view-pos.active {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }
    
    .products-section {
        height: auto;
        overflow-y: visible;
        padding-bottom: 2rem;
    }

    .cart-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        height: auto;
        position: static;
    }

    .sidebar-view {
        position: relative;
        height: auto;
        min-height: 400px;
        transform: none !important;
        opacity: 1 !important;
        pointer-events: all !important;
        display: none;
    }
    
    .sidebar-view.active {
        display: flex;
    }

    .category-tabs {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .cat-tab {
        flex-shrink: 0;
    }

    /* Settings Responsive */
    .settings-container {
        height: auto;
        overflow-y: auto;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
    .settings-nav {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    .nav-item {
        margin-bottom: 0;
        white-space: nowrap;
        padding: 0.75rem 1rem;
    }
    .settings-content {
        height: auto;
    }

    .header-main {
        padding: 0.75rem 1rem;
    }
    .user-profile {
        display: none; /* Hide on mobile to save space */
    }
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
}

.btn-icon {
    background: white;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-save {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr 350px;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .cart-sidebar {
        display: none; /* Mobile cart logic would need a drawer */
    }
}

/* Switch Component */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }
