@import "tailwindcss";

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 360px;
    --pos-bg: var(--gray-100);
    --pos-surface: #ffffff;
    --pos-surface-hover: var(--gray-50);
    --pos-border: var(--gray-200);
    --pos-text: var(--gray-900);
    --pos-text-secondary: var(--gray-500);
}

[data-theme="dark"] {
    --pos-bg: #0f172a;
    --pos-surface: #1e293b;
    --pos-surface-hover: #334155;
    --pos-border: #334155;
    --pos-text: #f1f5f9;
    --pos-text-secondary: #94a3b8;
    --gray-50: #1e293b;
    --gray-100: #0f172a;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #94a3b8;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: inherit;
    direction: rtl;
    background-color: var(--pos-bg);
    color: var(--pos-text);
    -webkit-tap-highlight-color: transparent;
}

/* Scrollbar styling - thin for tablet */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* POS specific styles */
.pos-grid {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: 0;
    height: 100vh;
}

.pos-sidebar {
    background: var(--pos-surface);
    border-right: 1px solid var(--pos-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.pos-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Product grid - Normal size */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

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

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

.product-card {
    background: var(--pos-surface);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;
    -webkit-user-select: none;
    user-select: none;
}

.product-grid.compact .product-card {
    border-radius: 8px;
    padding: 8px;
}

.product-grid.small .product-card {
    border-radius: 6px;
    padding: 6px;
}

.product-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.product-card.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.product-card-added {
    animation: product-pulse 0.4s ease-out;
}

@keyframes product-pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* ── Animations & Micro-interactions ── */

/* Cart item slide-in */
.cart-item-enter {
    animation: cart-slide-in 0.25s ease-out;
}

@keyframes cart-slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Cart item slide-out */
.cart-item-exit {
    animation: cart-slide-out 0.2s ease-in forwards;
}

@keyframes cart-slide-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-30px); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* Modal scale-in */
.modal-enter {
    animation: modal-scale-in 0.2s ease-out;
}

@keyframes modal-scale-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* Payment success checkmark */
.payment-success {
    animation: payment-checkmark 0.5s ease-out;
}

@keyframes payment-checkmark {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* KDS urgent order pulsing border */
.kds-urgent {
    animation: kds-pulse-border 1.5s ease-in-out infinite;
}

@keyframes kds-pulse-border {
    0%, 100% { border-color: rgba(239, 68, 68, 0.7); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { border-color: rgba(239, 68, 68, 1); box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.25); }
}

/* KDS bump confirmation */
.kds-bumped {
    animation: kds-bump-confirm 0.3s ease-out;
}

@keyframes kds-bump-confirm {
    0% { transform: scale(1); }
    50% { transform: scale(0.97); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Category tabs */
.category-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

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

.category-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 18px;
    background: white;
    border: 1px solid var(--gray-200);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.category-tab:hover {
    background: var(--gray-50);
}

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

/* Cart item */
.cart-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: var(--gray-50);
    border-radius: 8px;
    margin-bottom: 6px;
}

.cart-item:last-child {
    margin-bottom: 0;
}

/* Order status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
}

/* Table card */
.table-card {
    background: white;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid var(--gray-200);
}

.table-card:hover {
    border-color: var(--primary);
}

.table-card.available {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.table-card.occupied {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.table-card.reserved {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    -webkit-user-select: none;
    user-select: none;
}

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

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

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

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

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

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

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

/* Input styles */
.input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.15s ease;
    font-family: inherit;
}

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

.input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: white;
    border-radius: 14px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.numpad-btn {
    aspect-ratio: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    background: var(--gray-100);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.numpad-btn:hover {
    background: var(--gray-200);
}

.numpad-btn:active {
    background: var(--gray-300);
}

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

.animate-fade-in {
    animation: fadeIn 0.2s ease;
}

.animate-slide-up {
    animation: slideUp 0.3s ease;
}

/* ========== Large Tablet (≤1280px) - 10" tablets in landscape ========== */
@media (max-width: 1280px) {
    :root {
        --sidebar-width: 300px;
    }

    .pos-main header {
        padding: 4px 10px;
    }

    .pos-main header + div {
        padding: 4px 10px;
    }

    .pos-main header + div input {
        padding-top: 5px;
        padding-bottom: 5px;
        font-size: 12px;
    }

    .category-tabs {
        gap: 5px;
        padding: 5px 0;
    }

    .category-tab {
        padding: 5px 10px;
        font-size: 12px;
        border-radius: 14px;
    }

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

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

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

    .product-card {
        padding: 8px;
        border-radius: 8px;
    }

    .product-grid.compact .product-card {
        padding: 6px;
        border-radius: 6px;
    }

    .pos-sidebar .p-4,
    .pos-sidebar .p-3 {
        padding: 8px;
    }

    .cart-item {
        padding: 8px;
        gap: 8px;
        margin-bottom: 4px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 12px;
        gap: 5px;
    }

    .input {
        padding: 6px 10px;
        font-size: 12px;
    }

    .table-card {
        padding: 10px;
        border-radius: 8px;
    }

    .numpad-btn {
        font-size: 18px;
    }
}

/* ========== Tablet (≤1024px) - smaller tablets ========== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }

    .pos-main header {
        padding: 4px 8px;
    }

    .pos-main header + div {
        padding: 4px 8px;
    }

    .pos-main header + div input {
        padding-top: 4px;
        padding-bottom: 4px;
        font-size: 11px;
    }

    .category-tabs {
        gap: 4px;
        padding: 4px 0;
    }

    .category-tab {
        padding: 4px 8px;
        font-size: 11px;
        border-radius: 12px;
    }

    .pos-main .flex-1.overflow-y-auto {
        padding: 6px;
    }

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

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

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

    .product-card {
        padding: 6px;
        border-radius: 6px;
    }

    .product-grid.compact .product-card {
        padding: 5px;
        border-radius: 5px;
    }

    .pos-sidebar .p-4,
    .pos-sidebar .p-3 {
        padding: 6px;
    }

    .pos-sidebar .mb-4 {
        margin-bottom: 6px;
    }

    .cart-item {
        padding: 6px;
        gap: 6px;
        margin-bottom: 3px;
    }

    .btn {
        padding: 7px 10px;
        font-size: 11px;
        gap: 4px;
        border-radius: 6px;
    }

    .input {
        padding: 5px 8px;
        font-size: 11px;
    }

    .table-card {
        padding: 8px;
    }

    .numpad-btn {
        font-size: 16px;
    }
}

/* ========== Small Tablet (≤850px) ========== */
@media (max-width: 850px) {
    :root {
        --sidebar-width: 230px;
    }

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

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

    .product-card {
        padding: 5px;
        border-radius: 5px;
    }

    .cart-item {
        padding: 5px;
        gap: 5px;
    }

    .btn {
        padding: 6px 8px;
        font-size: 11px;
    }

    .category-tab {
        padding: 3px 7px;
        font-size: 10px;
    }
}

/* ========== Very Small Tablet / Large Phone (≤768px) ========== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 210px;
    }

    .pos-main header {
        padding: 3px 6px;
    }

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

    .product-card {
        padding: 4px;
    }

    .category-tab {
        padding: 3px 6px;
        font-size: 10px;
    }

    .pos-sidebar .p-4,
    .pos-sidebar .p-3 {
        padding: 5px;
    }

    .btn {
        padding: 5px 8px;
        font-size: 10px;
        border-radius: 5px;
    }

    .input {
        padding: 4px 7px;
        font-size: 10px;
    }
}
