/* CSS Variables */
:root {
    --color-primary: #5b3d2e;
    --color-primary-light: #8b6b5a;
    --color-primary-dark: #3d2a1f;
    --color-accent: #d4a574;
    --color-success: #4caf50;
    --color-warning: #ff9800;
    --color-error: #f44336;
    --color-bg: #f7f2ea;
    --color-surface: #ffffff;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-border: #e0d5c7;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.online {
    background: var(--color-success);
    color: white;
}

.status-badge.offline {
    background: var(--color-warning);
    color: white;
}

/* Main Layout */
.main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Menu Section */
.menu-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
}

.category-tabs {
    display: flex;
    gap: 8px;
    padding-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-light);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.category-tab:hover {
    background: var(--color-border);
}

.category-tab.active {
    background: var(--color-primary);
    color: white;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Menu Item Card */
.menu-item {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 120px;
}

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

.menu-item:active {
    transform: scale(0.98);
}

.menu-item-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.menu-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    line-height: 1.2;
}

.menu-item-price {
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1rem;
}

.menu-item.out-of-stock {
    opacity: 0.5;
    pointer-events: none;
}

/* Cart Section */
.cart-section {
    width: 320px;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

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

.cart-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.cart-empty {
    text-align: center;
    color: var(--color-text-light);
    padding: 40px 20px;
    font-size: 0.9rem;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.cart-item-price {
    color: var(--color-text-light);
    font-size: 0.85rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.qty-value {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
}

.cart-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-large {
    padding: 16px 24px;
    font-size: 1.1rem;
}

.btn-text {
    border: none;
    background: none;
    color: var(--color-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
}

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

.btn-icon {
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

/* FAB */
.fab {
    position: fixed;
    bottom: 24px;
    right: 344px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 90;
}

.fab:hover {
    transform: scale(1.05);
    background: var(--color-primary-dark);
}

.fab #queue-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-error);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Order Queue Panel */
.order-queue-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 320px;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 80px 20px 20px;
}

.order-queue-panel.hidden {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.order-queue {
    background: var(--color-surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 70vh;
    overflow-y: auto;
    min-width: 400px;
}

.order-card {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.order-card:last-child {
    border-bottom: none;
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.order-id {
    font-weight: 700;
}

.order-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.order-status.new {
    background: #e3f2fd;
    color: #1976d2;
}

.order-status.progress {
    background: #fff3e0;
    color: #f57c00;
}

.order-status.complete {
    background: #e8f5e9;
    color: #388e3c;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--color-surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.modal-icon.success {
    background: #e8f5e9;
    color: var(--color-success);
}

.modal-content h2 {
    margin-bottom: 12px;
    color: var(--color-primary);
}

.modal-content p {
    color: var(--color-text-light);
    margin-bottom: 8px;
}

.modal-content .btn-primary {
    margin-top: 20px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 24px;
    background: var(--color-text);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--color-warning);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 150;
    display: none;
}

body.offline .offline-banner {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .main {
        flex-direction: column;
    }

    .cart-section {
        width: 100%;
        height: 40vh;
        order: 2;
    }

    .menu-section {
        order: 1;
        flex: 1;
    }

    .fab {
        right: 24px;
        bottom: calc(40vh + 24px);
    }

    .order-queue-panel {
        right: 0;
    }

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

@media (max-width: 480px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .menu-item {
        padding: 12px;
        min-height: 100px;
    }

    .cart-section {
        height: 50vh;
    }
}

/* ============================================
   STAFF INTERFACE STYLES
   ============================================ */

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--color-primary) 0%, #3d2a1f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-card {
    background: white;
    padding: 48px 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.auth-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.auth-card h2 {
    color: var(--color-primary);
    margin-bottom: 12px;
    font-size: 1.5rem;
}

.auth-card p {
    color: #666;
    margin-bottom: 32px;
    font-size: 0.95rem;
}

#google-signin-button {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-error {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 16px;
}

/* Staff Badge */
.staff-badge {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.2);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Staff Main Layout */
.staff-main {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
}

.order-queue-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

.queue-header {
    padding: 20px;
    background: white;
    border-bottom: 2px solid #e0e0e0;
}

.queue-header h2 {
    margin-bottom: 16px;
    font-size: 1.3rem;
    color: var(--color-primary);
}

.queue-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: #f5f5f5;
    color: #333;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #e0e0e0;
}

.filter-btn.active {
    background: var(--color-primary);
    color: white;
}

.order-queue-staff {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    align-content: start;
}

.queue-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.queue-empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* Staff Order Card */
.staff-order-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 4px solid var(--color-primary);
    transition: all 0.2s;
}

.staff-order-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.staff-order-card[data-status="pending"] {
    border-left-color: #2196f3;
}

.staff-order-card[data-status="preparing"] {
    border-left-color: #ff9800;
}

.staff-order-card[data-status="ready"] {
    border-left-color: #4caf50;
}

.staff-order-card[data-status="completed"] {
    border-left-color: #9e9e9e;
    opacity: 0.7;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.order-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.source-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.source-badge.source-qr-order {
    background: #e3f2fd;
    color: #1565c0;
}

.source-badge.source-pos {
    background: #f3e5f5;
    color: #6a1b9a;
}

.table-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #fff3e0;
    color: #e65100;
}

.status-badge-staff {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge-staff.status-pending {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge-staff.status-preparing {
    background: #fff3e0;
    color: #e65100;
}

.status-badge-staff.status-ready {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge-staff.status-completed {
    background: #e0e0e0;
    color: #616161;
}

.order-items-display {
    margin: 12px 0;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 12px;
}

.order-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
}

.order-time {
    font-size: 0.8rem;
    color: #999;
}

.order-actions {
    display: flex;
    gap: 8px;
}

.status-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.status-btn.btn-primary {
    background: #2196f3;
    color: white;
}

.status-btn.btn-primary:hover {
    background: #1976d2;
}

.status-btn.btn-success {
    background: #4caf50;
    color: white;
}

.status-btn.btn-success:hover {
    background: #388e3c;
}

.status-btn.btn-complete {
    background: #9e9e9e;
    color: white;
}

.status-btn.btn-complete:hover {
    background: #757575;
}

.order-complete-badge {
    color: #4caf50;
    font-weight: 600;
}

/* Staff Mobile Responsive */
@media (max-width: 768px) {
    .order-queue-staff {
        grid-template-columns: 1fr;
    }

    .order-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .order-actions {
        width: 100%;
    }

    .status-btn {
        flex: 1;
    }
}

/* ============================================
   CUSTOMER MODE STYLES
   ============================================ */

/* Body class for customer mode */
body.customer-mode .cart-section {
    display: none;
}

body.customer-mode .main {
    width: 100%;
}

body.customer-mode .menu-section {
    width: 100%;
    padding-bottom: 120px; /* Space for cart FAB and sheet */
}

body.sheet-open {
    overflow: hidden; /* Prevent background scroll when sheet expanded */
}

/* Table Banner */
.table-banner {
    background: linear-gradient(135deg, var(--color-accent) 0%, #c9956a 100%);
    color: var(--color-primary-dark);
    padding: 10px 20px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 95;
}

.table-banner.hidden {
    display: none;
}

/* Cart FAB (Floating Action Button) */
.cart-fab {
    position: fixed;
    bottom: 100px; /* Above bottom sheet peek */
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 90;
}

.cart-fab:hover {
    transform: scale(1.1);
    background: var(--color-primary-dark);
}

.cart-fab:active {
    transform: scale(0.95);
}

.cart-fab.hidden {
    display: none;
}

.cart-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-error);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Bottom Sheet Cart */
.cart-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    pointer-events: none;
}

.cart-sheet.hidden {
    display: none;
}

.cart-sheet.expanded {
    pointer-events: auto;
}

/* Sheet Overlay */
.sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.cart-sheet.expanded .sheet-overlay {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* Sheet Container */
.sheet-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    transform: translateY(calc(100% - 80px)); /* Peek state: show 80px */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.cart-sheet.expanded .sheet-container {
    transform: translateY(0);
}

/* Drag Handle */
.sheet-handle {
    padding: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.handle-bar {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    transition: background 0.2s ease;
}

.sheet-handle:hover .handle-bar {
    background: var(--color-text-light);
}

/* Sheet Header */
.cart-sheet .cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.cart-sheet .cart-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Sheet Items */
.cart-sheet .cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    min-height: 100px;
    max-height: 50vh;
}

/* Sheet Footer */
.cart-sheet .cart-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)); /* iPhone notch support */
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}

.cart-sheet .cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Payment Instruction */
.payment-instruction {
    background: var(--color-accent);
    color: var(--color-primary-dark);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    margin-top: 16px;
    font-size: 0.95rem;
    text-align: center;
}

.payment-instruction.hidden {
    display: none;
}

/* Customer Mode Touch Enhancements */
body.customer-mode .qty-btn {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
}

body.customer-mode .menu-item {
    min-height: 140px;
    padding: 20px 16px;
}

body.customer-mode .menu-item-icon {
    font-size: 2.5rem;
}

body.customer-mode .btn-primary {
    min-height: 48px; /* Minimum touch target */
}

/* Customer Mode Mobile Responsive */
@media (max-width: 768px) {
    .cart-fab {
        bottom: 90px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .sheet-container {
        transform: translateY(calc(100% - 70px));
    }
}

/* Desktop Customer Mode */
@media (min-width: 769px) {
    body.customer-mode .main {
        max-width: 900px;
        margin: 0 auto;
    }

    .sheet-container {
        left: 50%;
        transform: translateX(-50%) translateY(calc(100% - 80px));
        max-width: 500px;
        border-radius: 20px;
    }

    .cart-sheet.expanded .sheet-container {
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   MOBILE CSS POLISH ENHANCEMENTS
   ============================================ */

/* 1. STAFF MODE CONDITIONAL STYLING */
body.staff-mode .cart-sheet,
body.staff-mode .cart-fab,
body.staff-mode .table-banner {
    display: none !important;
}

body.staff-mode .menu-section {
    display: none; /* Staff sees order queue, not menu */
}

body.staff-mode .staff-main {
    display: flex;
}

/* 2. COMPREHENSIVE SAFE-AREA SUPPORT */
@supports (padding: max(0px)) {
    /* Header - account for notch at top */
    .header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    /* Cart FAB - position above home indicator */
    .cart-fab {
        bottom: max(100px, calc(100px + env(safe-area-inset-bottom)));
        right: max(24px, calc(24px + env(safe-area-inset-right)));
    }

    /* Toast container - keep above home indicator */
    .toast-container {
        bottom: max(24px, calc(24px + env(safe-area-inset-bottom)));
        left: max(20px, env(safe-area-inset-left));
        right: max(20px, env(safe-area-inset-right));
    }

    /* Menu section - respect edge-to-edge displays */
    .menu-section {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    /* Cart items - horizontal safe areas */
    .cart-items,
    .cart-sheet .cart-items {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    /* Bottom sheet - account for home indicator in peek state */
    .sheet-container {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    }
}

/* 3. ENHANCED TOUCH TARGETS (44px minimum per Apple HIG) */
.category-tab {
    min-height: 44px;
    display: flex;
    align-items: center;
}

.filter-btn {
    min-height: 44px;
}

.btn-icon {
    min-width: 44px;
    min-height: 44px;
}

.btn-text {
    min-height: 44px;
}

body.staff-mode .status-btn {
    min-height: 44px;
    padding: 12px 16px;
}

/* Customer mode - even larger targets */
body.customer-mode .category-tab {
    padding: 14px 24px;
    min-height: 48px;
}

body.customer-mode .filter-btn {
    padding: 14px 20px;
    min-height: 48px;
}

/* 4. TOUCH FEEDBACK FOR INTERACTIVE ELEMENTS */
.menu-item:active,
.category-tab:active,
.filter-btn:active,
.status-btn:active {
    transform: scale(0.96);
    transition: transform 0.1s ease-out;
}

.cart-fab:active {
    transform: scale(0.92);
}

.sheet-handle:active .handle-bar {
    background: var(--color-primary);
    opacity: 0.8;
}

.qty-btn:active {
    transform: scale(0.92);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

body.customer-mode .btn-primary:active {
    transform: scale(0.97);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}

/* 5. UNIFIED TRANSITION TIMING */
:root {
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Apply consistent transitions */
.menu-item,
.cart-item,
.category-tab,
.qty-btn,
.btn-primary,
.btn-text,
.filter-btn,
.status-btn {
    transition: all var(--transition-base);
}

/* 6. BOTTOM SHEET PERFORMANCE */
.sheet-container {
    will-change: transform; /* GPU acceleration hint */
    max-height: min(85vh, calc(100vh - env(safe-area-inset-top) - 40px));
}

.cart-sheet.expanded {
    overscroll-behavior: contain; /* Prevent body scroll */
}

/* 7. SMOOTH SCROLLING */
.menu-grid,
.cart-items,
.cart-sheet .cart-items,
.order-queue-staff {
    -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
    scroll-behavior: smooth;
}

.cart-sheet .cart-items {
    overscroll-behavior-y: contain;
}

/* 8. ACCESSIBILITY - FOCUS STATES */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* 9. ACCESSIBILITY - REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 10. MOBILE BREAKPOINT REFINEMENTS */
@media (max-width: 768px) {
    /* Ensure adequate touch targets on mobile */
    .menu-item {
        min-height: 130px;
        padding: 18px 14px;
    }

    .qty-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    /* Better spacing */
    .category-tabs {
        padding-bottom: 12px;
        gap: 6px;
    }

    /* Bottom sheet peek adjustments */
    .sheet-container {
        border-radius: 24px 24px 0 0;
    }
}

@media (max-width: 480px) {
    /* Small devices - more compact */
    .menu-grid {
        gap: 10px;
    }

    .menu-item {
        padding: 14px;
        min-height: 110px;
    }

    .menu-item-icon {
        font-size: 2.2rem;
    }

    .cart-item {
        padding: 10px;
    }

    .cart-item-name {
        font-size: 0.85rem;
    }
}

/* 11. LANDSCAPE ORIENTATION HANDLING */
@media (max-height: 600px) and (orientation: landscape) {
    .sheet-container {
        max-height: 90vh;
        transform: translateY(calc(100% - 60px)); /* Smaller peek */
    }

    .cart-sheet .cart-items {
        max-height: 40vh;
    }

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

    .header {
        padding: 8px 20px; /* Reduced vertical padding */
    }
}

/* 12. DESKTOP CUSTOMER MODE REFINEMENTS */
@media (min-width: 769px) {
    body.customer-mode .menu-item:hover {
        transform: translateY(-4px) scale(1.02);
    }

    .sheet-container {
        box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
    }
}

/* ============================================
   QR CODES MODAL
   ============================================ */

.qr-modal-content {
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.qr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.qr-modal-header h2 {
    margin: 0;
    color: var(--color-primary);
    font-size: 1.4rem;
}

.qr-modal-header .btn-icon {
    color: var(--color-text-light);
}

.qr-modal-header .btn-icon:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.qr-modal-subtitle {
    color: var(--color-text-light);
    margin-bottom: 24px;
    text-align: left;
}

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

.qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    transition: var(--transition);
}

.qr-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.qr-item img {
    width: 140px;
    height: 140px;
    margin-bottom: 12px;
}

.qr-item-label {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-primary);
}

.qr-item-url {
    font-size: 0.7rem;
    color: var(--color-text-light);
    margin-top: 4px;
    word-break: break-all;
    text-align: center;
}

#qr-print-btn {
    margin-top: 8px;
}

/* QR Modal Responsive */
@media (max-width: 600px) {
    .qr-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .qr-item {
        padding: 12px;
    }

    .qr-item img {
        width: 100px;
        height: 100px;
    }

    .qr-modal-content {
        padding: 16px;
    }
}

/* Print Styles for QR Codes */
@media print {
    body * {
        visibility: hidden;
    }

    #qr-modal,
    #qr-modal * {
        visibility: visible;
    }

    #qr-modal {
        position: absolute;
        left: 0;
        top: 0;
        background: white;
    }

    .qr-modal-content {
        box-shadow: none;
        max-width: 100%;
        width: 100%;
        max-height: none;
    }

    .qr-modal-header .btn-icon,
    #qr-print-btn {
        display: none;
    }

    .qr-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }

    .qr-item {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .qr-item img {
        width: 120px;
        height: 120px;
    }
}

/* ============================================
   QR ZOOM OVERLAY
   ============================================ */

.qr-zoom {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
    animation: fadeIn 0.2s ease-out;
}

.qr-zoom.hidden {
    display: none;
}

.qr-zoom-content {
    text-align: center;
    animation: zoomIn 0.2s ease-out;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.qr-zoom-content img {
    width: 300px;
    height: 300px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.qr-zoom-label {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-top: 16px;
}

.qr-zoom-url {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
}

@media (min-width: 600px) {
    .qr-zoom-content img {
        width: 400px;
        height: 400px;
    }
}

/* Make QR items clickable */
.qr-item {
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.qr-item:active {
    transform: scale(0.97);
}
