/* =====================================================
   Restaurant POS — Premium POS Terminal Stylesheet
   ===================================================== */

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

:root {
    /* Dark theme palette */
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #242836;
    --bg-hover: #2d3244;
    --bg-active: #363b50;

    --text-primary: #f0f2f5;
    --text-secondary: #9ca3b4;
    --text-muted: #6b7280;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);

    --success: #10b981;
    --success-hover: #34d399;
    --success-glow: rgba(16, 185, 129, 0.3);

    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #f87171;

    --border: #2d3244;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =====================================================
   POS LAYOUT
   ===================================================== */
.pos-container {
    display: flex;
    height: 100vh;
    gap: 0;
}

/* --- LEFT PANEL: Menu --- */
.pos-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

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

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

.pos-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.pos-brand h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.pos-brand span {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.pos-time {
    text-align: right;
    font-size: 13px;
    color: var(--text-secondary);
}

.pos-time .time {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* --- Search Bar --- */
.pos-search {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.pos-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

.pos-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.pos-search input::placeholder {
    color: var(--text-muted);
}

/* --- Category Tabs --- */
.pos-categories {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.pos-categories::-webkit-scrollbar {
    display: none;
}

.category-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    user-select: none;
}

.category-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.category-tab .cat-icon {
    font-size: 16px;
}

.category-tab .cat-count {
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
}

.category-tab.active .cat-count {
    background: rgba(255,255,255,0.25);
}

/* --- Product Grid --- */
.pos-products-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.pos-products-wrapper::-webkit-scrollbar {
    width: 6px;
}

.pos-products-wrapper::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

.pos-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.product-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-color, var(--accent));
    opacity: 0;
    transition: var(--transition);
}

.product-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.product-card:hover::before {
    opacity: 1;
}

.product-card:active {
    transform: translateY(0) scale(0.97);
}

.product-card .product-emoji {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}

.product-card .product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.product-card .product-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
}

.product-card .product-price small {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.product-card.unavailable {
    opacity: 0.4;
    pointer-events: none;
}

/* Add-to-cart animation */
.product-card.added {
    animation: addPulse 0.4s ease;
}

@keyframes addPulse {
    0% { box-shadow: 0 0 0 0 var(--success-glow); }
    50% { box-shadow: 0 0 0 8px var(--success-glow); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* --- RIGHT PANEL: Cart --- */
.pos-cart {
    width: 380px;
    min-width: 380px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
}

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

.cart-header h2 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-badge {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.cart-clear-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.cart-clear-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* Table Selector */
.cart-table-select {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.cart-table-select label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.cart-table-select select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
}

.cart-table-select select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Cart Items */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.cart-items::-webkit-scrollbar {
    width: 4px;
}

.cart-items::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 2px;
}

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

.cart-empty .empty-icon {
    font-size: 48px;
    opacity: 0.5;
}

.cart-empty p {
    font-size: 14px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    animation: slideIn 0.2s ease;
}

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

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

.qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.qty-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.qty-btn.minus:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.qty-value {
    font-size: 14px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.cart-item-total {
    font-size: 14px;
    font-weight: 700;
    color: var(--success);
    min-width: 60px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: var(--transition);
}

.cart-item-remove:hover {
    color: var(--danger);
}

/* Cart Footer / Totals */
.cart-footer {
    border-top: 1px solid var(--border);
    padding: 16px 20px;
    background: var(--bg-tertiary);
}

.cart-totals {
    margin-bottom: 16px;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.cart-total-row.grand-total {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    padding: 12px 0 4px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.cart-total-row.grand-total span:last-child {
    color: var(--success);
}

/* Payment Method */
.payment-methods {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.payment-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.payment-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.payment-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* Notes */
.cart-notes {
    margin-bottom: 12px;
}

.cart-notes textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: var(--transition);
    height: 50px;
}

.cart-notes textarea:focus {
    border-color: var(--accent);
}

.cart-notes textarea::placeholder {
    color: var(--text-muted);
}

/* Checkout Button */
.checkout-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--success), #059669);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.checkout-btn:hover {
    background: linear-gradient(135deg, var(--success-hover), #10b981);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--success-glow);
}

.checkout-btn:active {
    transform: translateY(0);
}

.checkout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.checkout-btn .btn-icon {
    font-size: 20px;
}

/* =====================================================
   RECEIPT MODAL
   ===================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.receipt-modal {
    background: white;
    color: #1a1a1a;
    border-radius: var(--radius-lg);
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.receipt-header {
    text-align: center;
    padding: 24px 24px 16px;
    border-bottom: 2px dashed #e5e7eb;
}

.receipt-header h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.receipt-header p {
    font-size: 12px;
    color: #6b7280;
}

.receipt-body {
    padding: 16px 24px;
}

.receipt-items {
    list-style: none;
    margin-bottom: 16px;
}

.receipt-items li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
}

.receipt-items li:last-child {
    border-bottom: none;
}

.receipt-items .item-qty {
    color: #6b7280;
    margin-right: 8px;
}

.receipt-total {
    border-top: 2px dashed #e5e7eb;
    padding-top: 12px;
    margin-top: 12px;
}

.receipt-total-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
}

.receipt-total-row.grand {
    font-size: 18px;
    font-weight: 800;
    padding: 8px 0;
}

.receipt-footer {
    text-align: center;
    padding: 16px 24px 24px;
    border-top: 2px dashed #e5e7eb;
}

.receipt-footer p {
    font-size: 12px;
    color: #6b7280;
}

.receipt-footer .receipt-id {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
}

.receipt-actions {
    display: flex;
    gap: 8px;
    padding: 0 24px 24px;
}

.receipt-actions button {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.receipt-print-btn {
    background: var(--accent);
    border: none;
    color: white;
}

.receipt-print-btn:hover {
    background: var(--accent-hover);
}

.receipt-close-btn {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #374151;
}

.receipt-close-btn:hover {
    background: #f3f4f6;
}

/* =====================================================
   SUCCESS ANIMATION
   ===================================================== */
.success-checkmark {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.success-checkmark.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.success-checkmark .check-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.success-checkmark p {
    font-size: 20px;
    font-weight: 700;
    color: white;
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
    body * {
        visibility: hidden;
    }
    .receipt-modal,
    .receipt-modal * {
        visibility: visible;
    }
    .receipt-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        box-shadow: none;
        border-radius: 0;
    }
    .receipt-actions {
        display: none !important;
    }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
    .pos-products {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
    .pos-cart {
        width: 340px;
        min-width: 340px;
    }
}

@media (max-width: 768px) {
    .pos-container {
        flex-direction: column;
        overflow-y: auto; /* Allow the whole page to scroll */
    }
    .pos-cart {
        width: 100%;
        min-width: auto;
        max-height: none; /* Allow cart to expand */
        flex: 1; /* Allow cart to grow */
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .cart-items {
        padding: 8px 12px;
        flex: 1;
        overflow-y: visible; /* Allow content to dictate height */
    }
    .cart-footer {
        padding: 10px 12px;
        position: sticky;
        bottom: 0;
        background: var(--bg-tertiary);
    }
}
