/* ============================================
   Cafe POS - نسخه 7.1
   ارتفاع ثابت 850px - اسکرول داخلی - چیدمان گروهی
   ============================================ */

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

@font-face {
    font-family: 'Abar';
    src: url('fonts/Abar-VF.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --font: 'Abar', Tahoma, sans-serif;
    --bg: #f2ede4;
    --white: #ffffff;
    --border: #ddd6cb;
    --text: #2c1810;
    --text-light: #6b5a4e;
    --text-muted: #a89880;
    --accent: #7b4b2a;
    --success: #3d6b4a;
    --success-hover: #2d553a;
    --danger: #c0392b;
    --radius: 10px;
    --radius-sm: 6px;
}

html, body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    direction: rtl;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

/* ===== کانتینر اصلی - ارتفاع ثابت 850px ===== */
#cafe-pos-app {
    width: 100%;
    max-width: 1400px;
    height: 850px;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}

.pos-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
    border-radius: 16px;
}

/* ===== پنل منو (راست) ===== */
.pos-menu-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f9f6f0;
    overflow: hidden;
    height: 850px;
    border-radius: 0 16px 16px 0;
}

/* ===== گرید محصولات با گروه‌بندی ===== */
.menu-items-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

.category-group {
    margin-bottom: 20px;
}

.category-header {
    font-weight: 700;
    font-size: 16px;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-right: 4px solid;
    background: #fff6ed;
    border-radius: 8px;
    color: var(--text);
}

.category-title {
    display: inline-block;
}

.category-items-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.category-divider {
    margin: 15px 0 5px;
    border-bottom: 2px dashed #e8e0d4;
}

/* ===== کارت محصول ===== */
.menu-item-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    border: 1.5px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    user-select: none;
    min-height: 80px;
    justify-content: center;
}

.menu-item-card:hover {
    border-color: var(--accent);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

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

.menu-item-card .item-name {
    font-weight: 700;
    font-size: 13px;
    line-height: 1.3;
}

.menu-item-card .item-price {
    font-weight: 600;
    font-size: 12px;
    color: var(--accent);
}


/* ===== پنل سبد خرید (چپ) ===== */
.pos-cart-panel {
    width: 430px;
    min-width: 380px;
    max-width: 430px;
    background: var(--white);
    border-right: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.06);
    z-index: 10;
    height: 850px;
    overflow: hidden;
    border-radius: 16px 0 0 16px;
}

.cart-sticky {
    display: flex;
    flex-direction: column;
    height: 850px;
    overflow: hidden;
}

.cart-logo {
    text-align: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #f0ebe0;
    flex-shrink: 0;
    background: var(--white);
    max-height: 65px;
}


.cart-logo img {
    max-height: 32px;
    width: auto;
    object-fit: contain;
}

.cart-customer-info {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    flex-shrink: 0;
    background: var(--white);
}

.cart-input {
    flex: 1;
    padding: 9px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
    background: #faf8f4;
}

.cart-input:focus {
    border-color: var(--accent);
    background: #fff;
}

.cart-table-header {
    display: flex;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-light);
    border-bottom: 2px solid #e8e0d4;
    text-transform: uppercase;
    flex-shrink: 0;
    background: #fdfcf9;
}

.cart-table-header .col-name { flex: 3; }
.cart-table-header .col-qty { flex: 2; text-align: center; }
.cart-table-header .col-price { flex: 2; text-align: center; }

.cart-items-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    background: var(--white);
}

.cart-item-row {
    display: flex;
    align-items: center;
    padding: 7px 16px;
    border-bottom: 1px solid #f5f0e8;
    font-size: 13px;
}

.cart-item-row .col-name {
    flex: 3;
    font-weight: 600;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-row .col-qty { flex: 2; text-align: center; }
.cart-item-row .col-price { flex: 2; text-align: center; font-weight: 700; color: var(--accent); }

.qty-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #faf8f4;
    border-radius: 16px;
    padding: 1px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #d4c5b2;
    background: #fff;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.qty-num {
    font-weight: 700;
    font-size: 13px;
    min-width: 20px;
    text-align: center;
}

.cart-empty-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* ===== فوتر - همیشه پایین ===== */
.cart-footer {
    border-top: 2px solid #e8e0d4;
    padding: 12px 16px 16px;
    flex-shrink: 0;
    background: var(--white);
}

.cart-total-box {
    background: #faf8f4;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 10px;
}

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

.cart-total-divider {
    border: none;
    border-top: 1px dashed #d4c5b2;
    margin: 6px 0;
}

.cart-total-final {
    display: flex;
    justify-content: space-between;
    padding-top: 6px;
}

.cart-total-final span:first-child {
    font-weight: 700;
    font-size: 15px;
}

.cart-total-final span:last-child {
    font-weight: 900;
    font-size: 22px;
    color: var(--accent);
}

/* ===== دکمه‌ها - ردیفی ===== */
.cart-buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.btn-checkout {
    flex: 1;
    padding: 14px;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-checkout:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
}

.btn-clear {
    width: 50px;
    padding: 14px 0;
    background: #fff;
    color: var(--danger);
    border: 1.5px solid #e8d0d0;
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ===== استایل چاپ (بدون تغییر) ===== */
@media print {
    @page { size: 80mm auto; margin: 0; }
    html, body { width: 80mm; margin: 0; padding: 0; background: #fff; }
    body * { visibility: hidden; }
    body { visibility: visible; }
    #print-receipt {
        visibility: visible;
        position: absolute;
        right: 0;
        top: 0;
        width: 80mm;
        padding: 5mm;
        font-family: 'Abar', Tahoma, sans-serif;
        font-size: 12px;
        background: #fff;
        color: #000;
    }
    #print-receipt * { visibility: visible; }
}

/* ===== رسپانسیو ===== */
@media (max-width: 1100px) {
    #cafe-pos-app { height: 750px; }
    .pos-menu-panel { height: 750px; }
    .pos-cart-panel { width: 380px; height: 750px; }
    .cart-sticky { height: 750px; }
}

@media (max-width: 768px) {
    body { padding: 0; }
    #cafe-pos-app { height: 100vh; border-radius: 0; }
    .pos-layout { flex-direction: column; }
    .pos-cart-panel {
        width: 100%;
        height: 45vh;
        order: -1;
        border-radius: 0;
    }
    .cart-sticky { height: 45vh; }
    .pos-menu-panel { height: 55vh; border-radius: 0; }
    .category-items-grid { grid-template-columns: repeat(2, 1fr); }
}