/*
 * سیستم طراحی بومی نئوپاستیلی ۲۰۲۶ - عطاری ترنج
 * مجهز به فونت وزیرمتن (اعداد فارسی هم عرض)، چیدمان دوگانه موبایل و لپ تاپ و استایل چاپ
 */

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
    /* پالت رنگی نئوپاستیلی اختصاصی عطاری ترنج */
    --bg-main: #F7F6F2;
    --bg-surface: #FFFFFF;
    --bg-subtle: #F0EFE9;
    --border-color: #E6E4DD;
    --border-focus: #3B6E5C;

    /* رنگ متون با کنتراست بالا برای خوانایی کامل در نور روز و غرفه */
    --ink-primary: #18221F;
    --ink-secondary: #4A5954;
    --ink-muted: #7C8B86;

    /* رنگ اصلی برند (سبز برگ ترنج) */
    --brand-primary: #3B6E5C;
    --brand-primary-hover: #2E594A;
    --brand-pastel: #E3F1EC;

    /* رنگ مکمل (نارنجی بهارنارنج) */
    --brand-accent: #E07A5F;
    --brand-accent-hover: #CC664B;
    --brand-accent-pastel: #FDECE6;

    /* رنگ های اختصاصی سه قلک مالی */
    --fund1-color: #5C6AC4;
    --fund1-pastel: #EEF0FF;
    --fund1-border: #D4D9FA;

    --fund2-color: #D97757;
    --fund2-pastel: #FDF0EB;
    --fund2-border: #F7D6C8;

    --fund3-color: #2A9D8F;
    --fund3-pastel: #E6F7F5;
    --fund3-border: #BFEBE6;

    /* وضعیت ها */
    --danger-color: #D64545;
    --danger-pastel: #FCEAEA;
    --warning-color: #D9822B;
    --warning-pastel: #FEF3E6;

    /* ابعاد و سایه ها */
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 4px 20px -2px rgba(24, 34, 31, 0.05), 0 1px 4px -1px rgba(24, 34, 31, 0.03);
    --shadow-float: 0 -6px 28px rgba(24, 34, 31, 0.11);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    direction: rtl;
    text-align: right;
    background-color: var(--bg-main);
    color: var(--ink-primary);
    font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
    font-feature-settings: "ss01", "tnum";
    font-variant-numeric: tabular-nums;
    line-height: 1.6;
    font-size: 15px;
    overflow-x: hidden;
}

input, select, textarea, button {
    font-family: inherit;
    font-feature-settings: "ss01", "tnum";
    font-variant-numeric: tabular-nums;
}

/* ==================== مدیریت تب ها و بخش ها ==================== */

.tab-section {
    display: none;
    animation: fadeIn 0.18s ease-out;
}

.tab-section.active {
    display: block;
}

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

/* ==================== ساختار کلی دوگانه (موبایل در برابر لپ تاپ) ==================== */

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.desktop-sidebar {
    display: none;
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: 68px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 95;
    padding: 0 6px;
    box-shadow: var(--shadow-float);
}

.mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 4px;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.mobile-nav-btn .nav-icon {
    font-size: 19px;
    line-height: 1;
}

.mobile-nav-btn.active {
    color: var(--brand-primary);
    background-color: var(--brand-pastel);
}

.nav-alert-dot {
    position: absolute;
    top: 5px;
    left: 22%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger-color);
}

.main-workspace {
    flex: 1;
    width: 100%;
    max-width: 100%;
    padding: 12px 12px 155px 12px;
}

/* هدر بالایی اپلیکیشن */
.top-header {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: var(--shadow-soft);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand-pastel);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    border: 1px solid rgba(59, 110, 92, 0.2);
    flex-shrink: 0;
}

.brand-title {
    font-size: 16.5px;
    font-weight: 900;
    color: var(--ink-primary);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11.5px;
    color: var(--ink-muted);
}

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

/* ==================== کارت های Bento و المان های عمومی ==================== */

.bento-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 14px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--bg-subtle);
}

.card-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--ink-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* دکمه های استاندارد با حداقل ارتفاع ۴۸ پیکسل برای راحتی انگشت شست */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 48px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 800;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-accent {
    background-color: var(--brand-accent-pastel);
    color: #B5482B;
    border-color: rgba(224, 122, 95, 0.4);
}
.btn-accent:hover:not(:disabled) {
    background-color: var(--brand-accent);
    color: #FFFFFF;
}

.btn-pastel {
    background-color: var(--brand-pastel);
    color: var(--brand-primary);
    border-color: rgba(59, 110, 92, 0.25);
}

.btn-outline {
    background-color: #FFFFFF;
    color: var(--ink-secondary);
    border-color: var(--border-color);
}
.btn-outline:hover:not(:disabled) {
    background-color: var(--bg-subtle);
}

.btn-danger {
    background-color: var(--danger-pastel);
    color: var(--danger-color);
    border-color: rgba(214, 69, 69, 0.25);
}

.btn-sm {
    min-height: 38px;
    padding: 4px 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

/* فرم ها و ورودی ها */
.form-group {
    margin-bottom: 14px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    background-color: #FFFFFF;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--ink-primary);
    font-size: 15px;
    font-weight: 700;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-pastel);
}

/* نمایش حروفی مبلغ به تومان در زیر کادرهای قیمت */
.amount-words-hint {
    margin-top: 5px;
    font-size: 12px;
    font-weight: 700;
    color: var(--brand-primary);
    min-height: 18px;
}

/* گارد محاسباتی زنده در شارژ انبار */
.guard-preview-box {
    background: var(--brand-pastel);
    border: 1.5px solid rgba(59, 110, 92, 0.3);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 14px;
    font-size: 13px;
}

.guard-preview-box.danger {
    background: var(--danger-pastel);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* ==================== میز فروش سریع (POS Grid & Collapsible Bottom Sheet) ==================== */

.pos-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.category-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 10px 2px;
    position: sticky;
    top: 0;
    background: var(--bg-main);
    z-index: 40;
    scrollbar-width: none;
}
.category-pills::-webkit-scrollbar {
    display: none;
}

.cat-pill {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    background: var(--bg-surface);
    color: var(--ink-secondary);
    border: 1.5px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cat-pill.active {
    background: var(--brand-primary);
    color: #FFFFFF;
    border-color: var(--brand-primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.product-card {
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    position: relative;
    transition: all 0.12s ease;
    min-height: 110px;
    user-select: none;
}

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

.product-card:active {
    transform: scale(0.97);
    background-color: var(--brand-pastel);
}

.product-card.in-cart {
    border-color: var(--brand-primary);
    background-color: #F2FAF6;
    box-shadow: 0 0 0 1px var(--brand-primary);
}

.product-name {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--ink-primary);
    line-height: 1.38;
}

.product-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.product-price {
    font-size: 14px;
    font-weight: 900;
    color: var(--brand-primary);
}

.stock-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--bg-subtle);
    color: var(--ink-secondary);
}

.stock-badge.low {
    background: var(--danger-pastel);
    color: var(--danger-color);
}

.cart-qty-indicator {
    position: absolute;
    top: -7px;
    left: -7px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--brand-accent);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(224, 122, 95, 0.45);
}

/* کشوی شیشه ای سبد خرید در موبایل (قابل باز و بسته شدن تا روی کالاها را نپوشاند) */
.pos-cart-panel {
    position: fixed;
    bottom: 68px;
    right: 0;
    left: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    border-top: 2px solid var(--brand-primary);
    border-radius: 20px 20px 0 0;
    padding: 10px 14px 12px 14px;
    z-index: 90;
    box-shadow: var(--shadow-float);
    transition: all 0.2s ease;
}

.cart-drawer-body {
    display: none;
    max-height: 48vh;
    overflow-y: auto;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bg-subtle);
}

.pos-cart-panel.expanded .cart-drawer-body {
    display: block;
}

.cart-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ==================== نمایش دوگانه انبار (کارت موبایل در برابر جدول لپ تاپ) ==================== */

.inventory-mobile-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.inventory-desktop-table {
    display: none;
}

/* ==================== کارت های سه قلک مالی ==================== */

.funds-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.fund-card {
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1.5px solid transparent;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

.fund-card.fund-1 {
    background-color: var(--fund1-pastel);
    border-color: var(--fund1-border);
}
.fund-card.fund-2 {
    background-color: var(--fund2-pastel);
    border-color: var(--fund2-border);
}
.fund-card.fund-3 {
    background-color: var(--fund3-pastel);
    border-color: var(--fund3-border);
}

.fund-value {
    font-size: 23px;
    font-weight: 900;
    color: var(--ink-primary);
}

/* ==================== کیبورد لمسی باشگاه مشتریان ==================== */

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    direction: ltr;
    max-width: 340px;
    margin: 0 auto;
}

.numpad-key {
    height: 60px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background: #FFFFFF;
    color: var(--ink-primary);
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    user-select: none;
}

.numpad-key:active {
    background: var(--brand-pastel);
    border-color: var(--brand-primary);
    transform: scale(0.96);
}

.phone-display-box {
    direction: ltr;
    text-align: center;
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 2px;
    padding: 14px;
    background: var(--bg-main);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    color: var(--ink-primary);
}

/* ==================== جداول، مودال ها و اعلان های شناور (Toast) ==================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th,
.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--bg-subtle);
    text-align: right;
}

.data-table th {
    font-weight: 800;
    color: var(--ink-secondary);
    background-color: var(--bg-main);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(24, 34, 31, 0.58);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 14px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 92%;
    max-width: 400px;
    pointer-events: none;
}

.toast-item {
    background: var(--ink-primary);
    color: #FFFFFF;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
    animation: fadeIn 0.2s ease;
}

.toast-item.success { background: var(--brand-primary); }
.toast-item.error   { background: var(--danger-color); }

/* ==================== صفحه ورود (Login Page) ==================== */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at top right, #E3F1EC 0%, #F7F6F2 45%, #FDECE6 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.96);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    box-shadow: 0 12px 36px rgba(24, 34, 31, 0.08);
}

/* ==================== چیدمان اختصاصی لپ تاپ و دسکتاپ (>= 1024px) ==================== */

@media (min-width: 1024px) {
    .mobile-bottom-nav {
        display: none !important;
    }

    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        width: 268px;
        min-height: 100vh;
        background: var(--bg-surface);
        border-left: 1px solid var(--border-color);
        padding: 22px 16px;
        position: sticky;
        top: 0;
        height: 100vh;
        flex-shrink: 0;
    }

    .sidebar-nav-list {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 20px;
        flex: 1;
    }

    .sidebar-nav-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px;
        border-radius: var(--radius-md);
        border: none;
        background: transparent;
        color: var(--ink-secondary);
        font-size: 14px;
        font-weight: 800;
        cursor: pointer;
        text-align: right;
        transition: all 0.15s ease;
    }

    .sidebar-nav-btn:hover {
        background: var(--bg-main);
    }

    .sidebar-nav-btn.active {
        background: var(--brand-pastel);
        color: var(--brand-primary);
    }

    .main-workspace {
        padding: 24px 30px;
        max-width: calc(100vw - 268px);
    }

    .form-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* میز فروش دو تکه در لپ تاپ (محصولات در راست + پنل ثابت سبد خرید همیشه باز در چپ) */
    .pos-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 22px;
    }

    .pos-products-area {
        flex: 1;
        min-width: 0;
    }

    .product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .pos-cart-panel {
        position: sticky;
        top: 24px;
        bottom: auto;
        width: 380px;
        border: 1.5px solid var(--border-color);
        border-radius: var(--radius-xl);
        padding: 18px;
        box-shadow: var(--shadow-soft);
        flex-shrink: 0;
    }

    .cart-drawer-body {
        display: block !important;
        max-height: 45vh;
    }

    .mobile-drawer-toggle {
        display: none !important;
    }

    /* نمایش جدول کامل انبار در لپ تاپ به جای کارت های موبایل */
    .inventory-mobile-list {
        display: none;
    }

    .inventory-desktop-table {
        display: block;
    }

    /* سه قلک کنار هم در لپ تاپ */
    .funds-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    /* شبکه ۲×۲ نمودارهای تحلیلی در لپ تاپ */
    .charts-bento-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

/* ==================== استایل اختصاصی چاپ پوستر QR و لیست خرید ==================== */

@media print {
    .desktop-sidebar,
    .mobile-bottom-nav,
    .top-header,
    .pos-cart-panel,
    .no-print {
        display: none !important;
    }
    body, .main-workspace, .bento-card {
        background: #FFFFFF !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        max-width: 100% !important;
    }
}