﻿/* ===== POS SYSTEM STYLES - RTL Arabic ===== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0f1117;
    --bg-panel: #1a1d27;
    --bg-card: #22263a;
    --bg-hover: #2c3050;
    --accent: #3b82f6;
    --accent-h: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #2e3348;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    direction: rtl;
}

/* ===== WRAPPER ===== */
.pos-wrapper {
    height: 100%; /* ← يرث الارتفاع من الـ parent */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
.pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #1a1d27 100%);
    border-bottom: 2px solid var(--accent);
    padding: 8px 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(59,130,246,0.3);
}

.store-name {
    font-size: 1.2rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.5px;
}

.order-no {
    font-size: 0.8rem;
    color: var(--warning);
    margin-right: 16px;
    background: rgba(245,158,11,0.1);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(245,158,11,0.3);
}

.header-center {
    text-align: center;
}

.clock {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

.date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cashier {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== BODY LAYOUT ===== */
.pos-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ===== CART PANEL ===== */
.cart-panel {
    width: 420px;
    min-width: 380px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden; /* ← غيّر من overflow-y: auto إلى hidden */
}

/* الجزء الوحيد الذي يتمدد — جدول العناصر */
.cart-table-wrap {
    flex: 1;
    min-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ===== الأجزاء الثابتة في لوحة الفاتورة ===== */
.customer-row {
    flex-shrink: 0;
    padding: 10px 14px 6px;
}

.totals-section {
    flex-shrink: 0;
    padding: 10px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.payment-section {
    flex-shrink: 0;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

/* ===== action-buttons ===== */
.action-buttons {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    /* ← احذف position: sticky و bottom: 0 و z-index كلها */
}

    .action-buttons button {
        flex: 1;
        padding: 10px;
        border: none;
        border-radius: var(--radius);
        font-family: 'Cairo', sans-serif;
        font-size: 0.82rem;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s;
    }

/* ===== INPUT ===== */
.input-field {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    font-size: 0.85rem;
    padding: 7px 12px;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
}

    .input-field:focus {
        border-color: var(--accent);
    }

/* ===== CART TABLE ===== */
.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    gap: 8px;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.4;
}

.hint {
    font-size: 0.75rem;
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

    .cart-table thead th {
        background: var(--bg-card);
        color: var(--text-muted);
        padding: 7px 6px;
        text-align: center;
        font-weight: 600;
        font-size: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 2;
        border-bottom: 1px solid var(--border);
    }

.cart-row {
    border-bottom: 1px solid rgba(46,51,72,0.5);
    cursor: pointer;
    transition: background 0.15s;
}

    .cart-row:hover {
        background: var(--bg-hover);
    }

    .cart-row.selected-row {
        background: rgba(59,130,246,0.12);
    }

    .cart-row td {
        padding: 6px;
        text-align: center;
        vertical-align: middle;
    }

.row-num {
    color: var(--text-muted);
    font-size: 0.72rem;
    width: 24px;
}

.product-name-cell {
    text-align: right !important;
    max-width: 120px;
    font-size: 0.8rem;
    line-height: 1.3;
}

.qty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.qty-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 22px;
    height: 22px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    transition: all 0.15s;
}

    .qty-btn:hover {
        background: var(--accent);
        border-color: var(--accent);
    }

.qty-val {
    min-width: 24px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.price-cell {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.total-cell {
    color: var(--success);
    font-weight: 700;
    font-size: 0.82rem;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background 0.15s;
}

    .delete-btn:hover {
        background: rgba(239,68,68,0.15);
    }

/* ===== TOTALS ===== */
.total-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

    .total-row.grand-total {
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px dashed var(--border);
        font-size: 1rem;
        color: var(--text-main);
    }

.amount {
    font-weight: 600;
}

.grand {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--success);
}

/* ===== PAYMENT ===== */
.payment-methods {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.pay-method-btn {
    flex: 1;
    padding: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

    .pay-method-btn:hover {
        border-color: var(--accent);
    }

    .pay-method-btn.active {
        background: var(--accent);
        border-color: var(--accent);
        font-weight: 700;
    }

.amount-paid-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

    .amount-paid-row label {
        font-size: 0.82rem;
        color: var(--text-muted);
        white-space: nowrap;
    }

.paid-input {
    flex: 1;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 5px 10px;
    text-align: center;
    outline: none;
    direction: ltr;
}

.change-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.change-amount {
    font-weight: 700;
    color: var(--text-muted);
}

    .change-amount.positive {
        color: var(--success);
    }

/* ===== أنماط أزرار الإجراءات ===== */
.btn-clear {
    background: var(--bg-card) !important;
    color: var(--danger) !important;
    border: 1px solid var(--danger) !important;
}

    .btn-clear:hover {
        background: rgba(239,68,68,0.15) !important;
    }

.btn-print {
    background: var(--bg-card) !important;
    color: var(--warning) !important;
    border: 1px solid var(--warning) !important;
}

    .btn-print:hover {
        background: rgba(245,158,11,0.15) !important;
    }

.btn-pay {
    flex: 2 !important;
    background: linear-gradient(135deg, var(--success), #059669) !important;
    color: #fff !important;
    font-size: 1rem !important;
    box-shadow: 0 4px 12px rgba(16,185,129,0.4);
}

    .btn-pay:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(16,185,129,0.5);
    }

    .btn-pay:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }

/* ===== PRODUCT PANEL ===== */
.product-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-dark);
}

/* ===== SEARCH ===== */
.search-bar {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.search-input, .barcode-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    padding: 8px 14px;
    outline: none;
    transition: border-color 0.2s;
    direction: rtl;
}

.search-input {
    flex: 1;
}

.barcode-input {
    width: 180px;
    direction: ltr;
}

    .search-input:focus, .barcode-input:focus {
        border-color: var(--accent);
    }

/* ===== CATEGORY TABS ===== */
.category-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
}

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

.cat-tab {
    padding: 5px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-family: 'Cairo', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

    .cat-tab:hover {
        border-color: var(--accent);
        color: var(--text-main);
    }

    .cat-tab.active {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
    }

/* ===== PRODUCT GRID ===== */
.product-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    user-select: none;
}

    .product-card:hover {
        border-color: var(--accent);
        background: var(--bg-hover);
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(59,130,246,0.25);
    }

    .product-card:active {
        transform: scale(0.97);
    }

.product-emoji {
    font-size: 1.6rem;
}

.product-card-name {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-main);
    max-height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card-price {
    font-size: 0.88rem;
    font-weight: 900;
    color: var(--success);
    direction: ltr;
}

.product-card-unit {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: rgba(148,163,184,0.1);
    padding: 1px 6px;
    border-radius: 10px;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow);
    animation: pop 0.25s ease;
}

@keyframes pop {
    from {
        transform: scale(0.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.modal-box h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.modal-box p {
    color: var(--text-muted);
    margin-bottom: 6px;
}

.btn-close-modal {
    margin-top: 20px;
    padding: 10px 32px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

    .btn-close-modal:hover {
        background: var(--accent-h);
    }

/* ===== RECEIPT ===== */
.receipt-box {
    background: #fff;
    color: #111;
    border-radius: 10px;
    padding: 24px 20px;
    width: 300px;
    font-family: 'Courier New', monospace;
    direction: rtl;
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
}

.receipt-header {
    text-align: center;
    margin-bottom: 12px;
}

    .receipt-header h3 {
        font-size: 1.1rem;
        margin-bottom: 4px;
    }

    .receipt-header p {
        font-size: 0.75rem;
        color: #555;
    }

hr.dashed {
    border: none;
    border-top: 1px dashed #999;
    margin: 8px 0;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    padding: 2px 0;
    gap: 8px;
}

.receipt-item-name {
    flex: 1;
}

.receipt-item-qty {
    color: #555;
    direction: ltr;
}

.receipt-item-total {
    font-weight: 700;
    direction: ltr;
}

.receipt-total-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 2px 0;
}

    .receipt-total-line.bold {
        font-weight: 700;
        font-size: 0.95rem;
    }

.receipt-footer {
    text-align: center;
    font-size: 0.8rem;
    color: #555;
    margin-top: 10px;
}

    .receipt-footer + .btn-close-modal {
        width: 100%;
        margin-top: 12px;
    }

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
