:root {
    /* Colors */
    --bg-main: #f3f4f6;
    --bg-panel: #ffffff;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    
    /* Typography */
    --font-family: 'Inter', sans-serif;
    
    /* Shadows & Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-main: #111827;
    --bg-panel: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border: #374151;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection in specific elements */
input, textarea, .receipt-details {
    -webkit-user-select: text;
    user-select: text;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .admin-btn {
    background: white;
    color: var(--primary);
}

.app-header .user-profile {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.app-header .logout-btn {
    color: #fca5a5;
}

.app-header .logout-btn:hover {
    color: #fecaca;
}

.app-header .search-bar input {
    background: white;
    color: #111827;
    border: none;
}

.app-footer {
    padding: 8px 24px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Catalog Section */
.catalog-section {
    flex: 1;
    min-width: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-btn {
    padding: 8px 16px;
    background: var(--text-main);
    color: var(--bg-main);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
    transition: background 0.2s;
}

.admin-btn:hover {
    background: #374151;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px;
}

.logout-btn:hover {
    text-decoration: underline;
}

.theme-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    color: var(--text-main);
}

.search-bar input {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    outline: none;
    width: 300px;
    font-size: 14px;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.categories {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
}

.category-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font-family);
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-btn.active, .category-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding-bottom: 24px;
}

.product-card {
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
}

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

.product-emoji {
    font-size: 48px;
    text-align: center;
    margin-bottom: 12px;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    padding: 20px 0;
}

.product-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 15px;
}

.product-price {
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 8px;
}

.product-stock {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: auto;
}

/* Sidebar Cart Section */
.cart-section {
    width: 400px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.cart-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-cart-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-main);
}

.cart-header h2 {
    font-size: 20px;
}

.order-id {
    color: var(--text-muted);
    font-size: 14px;
    background: var(--bg-main);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-cart-msg {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
    font-style: italic;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-main);
    padding: 12px;
    border-radius: var(--radius-sm);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
}

.item-price {
    color: var(--text-muted);
    font-size: 12px;
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--border);
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.qty-btn:hover {
    background: #d1d5db;
}

.item-qty {
    font-weight: 600;
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.cart-summary {
    padding: 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.summary-row.total {
    color: var(--text-main);
    font-weight: 700;
    font-size: 20px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

.checkout-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s, opacity 0.2s;
    font-family: var(--font-family);
}

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

.checkout-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content, .receipt-content {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 400px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content,
.modal-overlay.active .receipt-content {
    transform: translateY(0);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 24px;
}

.payment-amount {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--primary);
}

.payment-methods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.pay-method-btn {
    padding: 20px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.pay-method-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.cancel-btn, .done-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    font-family: var(--font-family);
}

.cancel-btn {
    background: var(--bg-main);
    color: var(--text-main);
}

.cancel-btn:hover {
    background: var(--border);
}

.done-btn {
    background: var(--success);
    color: white;
    margin-top: 24px;
}

.done-btn:hover {
    background: #059669;
}

.receipt-header {
    text-align: center;
    margin-bottom: 24px;
}

.receipt-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.receipt-details {
    font-family: monospace;
    font-size: 14px;
    background: var(--bg-main);
    padding: 16px;
    border-radius: var(--radius-sm);
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.receipt-divider {
    border-top: 1px dashed var(--border);
    margin: 12px 0;
}

/* Utilities & Auth specific */
.hidden {
    display: none !important;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--primary);
}

.error-msg {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    background: #fef2f2;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.scanner-indicator {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
    background: #ecfdf5;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #a7f3d0;
}

#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    background: var(--text-main);
    color: var(--bg-main);
    border-radius: var(--radius-md);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    transition: opacity 0.3s ease-out;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--danger);
    color: white;
}

.toast.fade-out {
    opacity: 0;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Inventory Table */
.inventory-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 14px;
}

.inventory-table th, .inventory-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.inventory-table th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-main);
}

.inventory-actions button {
    margin-right: 8px;
    padding: 4px 8px;
    font-size: 12px;
}

/* Reports & Admin Menu */
.admin-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}

.admin-menu-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
    color: var(--text-main);
}

.admin-menu-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.admin-menu-card h3 {
    font-size: 18px;
    margin-top: 12px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.report-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
}

.report-card h3 {
    font-size: 16px;
    color: var(--text-muted);
    font-weight: 500;
}

.report-card .revenue {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    margin: 12px 0 4px;
}

.report-card .orders {
    font-size: 14px;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
    .admin-menu-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.stats-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.stats-card h3 {
    font-size: 16px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 16px;
}

.best-sellers-list {
    list-style: none;
}

.best-sellers-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.best-sellers-list li:last-child {
    border-bottom: none;
}

.payment-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.payment-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Mobile Cart Button */
.mobile-cart-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 100;
    font-family: var(--font-family);
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .cart-section {
        width: 320px;
    }
}

@media (max-width: 768px) {
    .app-content {
        flex-direction: column;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-bar input {
        width: 100%;
    }

    .categories {
        padding-bottom: 8px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .mobile-cart-btn {
        display: block;
    }

    .cart-section {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 80vh;
        z-index: 200;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .cart-section.open {
        transform: translateY(0);
    }

    .close-cart-btn {
        display: block;
    }
}
