:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --radius: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Vazirmatn', sans-serif; background-color: var(--bg-color); color: var(--text-main); line-height: 1.5; }
a { text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; padding-bottom: 70px; /* فضای منوی پایین در موبایل */ }
.main-content { flex: 1; padding: 20px; max-width: 1000px; margin: 0 auto; width: 100%; }

/* Mobile Header */
.mobile-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: var(--surface); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100; }
.mobile-header .brand { display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: bold; font-size: 1.2rem; }
.icon-btn { background: transparent; color: var(--text-muted); padding: 8px; border-radius: 8px; }

/* Navigation */
.sidebar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); box-shadow: 0 -2px 10px rgba(0,0,0,0.05); z-index: 100; }
.desktop-only { display: none; }
.nav-menu { display: flex; justify-content: space-around; list-style: none; padding: 10px 5px; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 12px; color: var(--text-muted); font-size: 0.75rem; border-radius: 12px; transition: all 0.3s; cursor: pointer; }
.nav-item.active { color: var(--primary); background: var(--primary-light); font-weight: bold; }

/* Tabs */
.tab-pane { display: none; animation: fadeIn 0.3s ease; }
.tab-pane.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Overview Components */
.welcome-banner { background: linear-gradient(135deg, var(--primary), #1e40af); color: white; padding: 24px; border-radius: var(--radius); margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; box-shadow: var(--shadow-md); }
.welcome-banner h1 { font-size: 1.25rem; margin-bottom: 8px; }

.status-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; }
.status-badge.pending { background: var(--warning-bg); color: var(--warning); }
.status-badge.approved { background: var(--success-bg); color: var(--success); }
.status-badge.rejected { background: var(--danger-bg); color: var(--danger); }

.stats-grid { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 20px; }
.stat-card { background: var(--surface); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 15px; border: 1px solid var(--border); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--primary); background: var(--primary-light); }
.stat-info h3 { font-size: 0.85rem; color: var(--text-muted); font-weight: normal; margin-bottom: 4px; }
.amount { font-size: 1.25rem; font-weight: bold; color: var(--text-main); font-feature-settings: "tnum"; }
.amount span { font-size: 0.8rem; color: var(--text-muted); font-weight: normal; }

.expert-card { background: var(--surface); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; align-items: center; gap: 15px; }
.expert-avatar { width: 50px; height: 50px; border-radius: 50%; background: #f1f5f9; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.expert-details h4 { font-size: 0.85rem; color: var(--text-muted); font-weight: normal; margin-bottom: 4px; }
.expert-details p { font-weight: bold; margin-bottom: 8px; }
.expert-call-btn { display: inline-block; padding: 6px 16px; background: var(--primary-light); color: var(--primary); border-radius: 8px; font-size: 0.85rem; font-weight: bold; transition: background 0.3s; }
.expert-call-btn:hover { background: #dbeafe; }

/* Lists (Orders & Wallet) */
.section-title { font-size: 1.2rem; margin-bottom: 15px; color: var(--text-main); }
.data-list { display: flex; flex-direction: column; gap: 12px; }
.list-card { background: var(--surface); padding: 16px; border-radius: 12px; border: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-sm); }
.list-card-right { display: flex; flex-direction: column; gap: 6px; }
.list-card-title { font-weight: bold; font-size: 0.95rem; }
.list-card-date { font-size: 0.8rem; color: var(--text-muted); }
.list-card-left { text-align: left; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.text-success { color: var(--success); font-weight: bold; }
.text-danger { color: var(--danger); font-weight: bold; }

/* Profile Card */
.profile-card { background: var(--surface); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); display: grid; grid-template-columns: 1fr; gap: 20px; }
.info-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.info-group p { font-size: 0.95rem; font-weight: 500; }
.address-box { background: #f8fafc; padding: 12px; border-radius: 8px; border: 1px solid var(--border); line-height: 1.6; }

.loading-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 800px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 1.1rem; color: var(--text-main); }
.close-btn { background: #f1f5f9; color: var(--text-muted); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; transition: all 0.2s; }
.close-btn:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 20px; overflow-y: auto; }
.modal-info-summary { background: var(--bg-color); padding: 15px; border-radius: 12px; margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 20px; border: 1px solid var(--border); }
.modal-info-summary div { flex: 1; min-width: 150px; }
.modal-info-summary span { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.modal-info-summary strong { font-size: 0.95rem; }

.table-container { overflow-x: auto; margin-bottom: 20px; }
.details-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.details-table th { text-align: right; padding: 12px; font-size: 0.85rem; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.details-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.modal-totals { 
    background: #f8fafc; 
    padding: 20px 25px; 
    border-radius: 16px; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    border: 1px solid var(--border);
    margin-top: 20px;
}
.modal-totals > div { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    width: 100%; 
    font-size: 0.9rem;
}
.modal-totals span { color: var(--text-muted); }
.modal-totals strong { color: var(--text-main); font-size: 1.1rem; }
.modal-totals .final-amount {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid var(--border);
}
.modal-totals .final-amount strong {
    color: var(--primary);
    font-size: 1.3rem;
}

.modal-footer { padding: 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.modal-footer button { flex-shrink: 0; }
.modal-footer #print-invoice-colleague-btn { width: 100%; }
.btn-cancel { padding: 10px 24px; background: var(--danger-bg); color: var(--danger); border-radius: 8px; font-weight: bold; transition: all 0.3s; }
.btn-cancel:hover { background: var(--danger); color: white; }

.profile-input { width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); font-family: inherit; font-size: 0.95rem; transition: all 0.3s; background: var(--surface); }
.profile-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-light); }
.profile-input:disabled { background: #f8fafc; border-color: #f1f5f9; cursor: not-allowed; color: var(--text-muted); }

/* Toasts */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: var(--surface); padding: 12px 24px; border-radius: 50px; box-shadow: var(--shadow-md); font-size: 0.9rem; animation: slideDown 0.3s forwards; }

/* Responsive Desktop */
@media (min-width: 768px) {
    .app-layout { padding-bottom: 0; padding-right: 250px; /* فضای سایدبار */ }
    .mobile-header { display: none; }
    .desktop-only { display: block; }
    
    .sidebar { bottom: 0; top: 0; right: 0; left: auto; width: 250px; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
    .sidebar-header { padding: 24px 20px; border-bottom: 1px solid var(--border); }
    .sidebar-header .brand { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: bold; font-size: 1.4rem; }
    
    .nav-menu { flex-direction: column; padding: 15px 10px; gap: 2px; }
    .nav-item { flex-direction: row; padding: 10px 16px; font-size: 0.95rem; justify-content: flex-start; gap: 12px; }
    
    .sidebar-footer { padding: 20px; border-top: 1px solid var(--border); }
    .logout-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: var(--danger-bg); color: var(--danger); border-radius: 8px; font-weight: bold; transition: opacity 0.3s; }
    .logout-btn:hover { opacity: 0.8; }
    
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .profile-card { grid-template-columns: 1fr 1fr; }
    .info-group.full-width { grid-column: 1 / -1; }
    .main-content { padding: 40px; }
}

/* Wallet Actions Styles */
.wallet-actions-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.wallet-action-box {
    background: var(--surface);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.wallet-action-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

.charge-box label { color: var(--primary); display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: bold; }
.withdraw-box label { color: #ea580c; display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: bold; }

.action-input-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.action-input-group-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.charge-btn { flex-shrink: 0; padding: 0 24px; }
.withdraw-btn { background: #ea580c; border-color: #ea580c; width: 100%; margin-top: 4px; color: white; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; transition: all 0.3s; }
.withdraw-btn:hover { background: #c2410c; }

.action-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }

.shaba-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.shaba-prefix {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.95rem;
    direction: ltr;
}
.shaba-input-wrapper input {
    padding-left: 40px;
    direction: ltr;
    text-align: left;
    font-family: monospace;
    font-size: 1rem;
}

/* Responsive adjustments for wallet */
@media (max-width: 1024px) {
    .wallet-actions-card { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .wallet-actions-card { display: flex; flex-direction: column; gap: 20px; }
    .action-input-group { flex-direction: column; }
    .charge-btn { width: 100%; padding: 12px; }
}

/* Notifications Styles */
.notif-badge {
    position: absolute;
    left: 16px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.notif-card {
    display: block;
    padding: 18px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.2s;
    margin-bottom: 12px;
    text-align: right;
}

.notif-card.unread {
    background: #f0f9ff;
    border-right: 4px solid var(--primary);
}

.notif-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notif-header-row {
    display: flex;
    justify-content: flex-start;
}

.notif-icon-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
}

.notif-title {
    margin: 0;
    font-size: 1rem;
    color: var(--text-main);
    font-weight: bold;
}

.notif-message {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.notif-divider {
    height: 1px;
    background: var(--border);
    border: none;
    margin: 5px 0;
}

.notif-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notif-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mark-read-btn {
    background: var(--primary-light);
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: bold;
    transition: background 0.3s;
}
.mark-read-btn:hover {
    background: #dbeafe;
}

/* Infinite Scroll Sentinel */
.scroll-sentinel {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.scroll-sentinel.hidden {
    display: none;
}

/* Ticketing Styles */
.tickets-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 500px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.tickets-list-sidebar {
    border-left: 1px solid var(--border);
    background: #f8fafc;
    overflow-y: auto;
    padding: 15px;
}

.ticket-chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--surface);
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    background: var(--surface);
}

.chat-header h3 { margin: 0; font-size: 1.1rem; color: var(--text-main); }

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f1f5f9;
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
}

.chat-bubble.me {
    align-self: flex-start;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-bubble.other {
    align-self: flex-end;
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

.chat-meta {
    font-size: 0.7rem;
    margin-top: 5px;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
}

/* ===== Chat Action Buttons (Reply / Delete) ===== */
/* ردیف دکمه‌های اکشن (ریپلای و حذف) */
.chat-actions-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}
.chat-bubble:hover .chat-actions-row {
    opacity: 1;
}

/* استایل پایه دکمه‌های اکشن */
.chat-action-btn {
    background: none !important;
    border: none !important;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
}

/* دکمه‌ها روی پیام‌های "me" (پس‌زمینه آبی) - رنگ سفید */
.chat-bubble.me .chat-action-btn {
    color: rgba(255, 255, 255, 0.85) !important;
}
.chat-bubble.me .chat-action-btn:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.2) !important;
}

/* دکمه‌ها روی پیام‌های "other" (پس‌زمینه سفید) - رنگ تیره */
.chat-bubble.other .chat-action-btn {
    color: #64748b !important;
}
.chat-bubble.other .chat-action-btn:hover {
    color: #1e293b !important;
    background: #f1f5f9 !important;
}

/* دکمه ریپلای: hover سبز */
.chat-action-reply:hover {
    color: #10b981 !important;
    background: rgba(16, 185, 129, 0.15) !important;
}

/* دکمه حذف: hover قرمز */
.chat-action-delete:hover {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.15) !important;
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: white;
    display: flex;
    gap: 10px;
}

.chat-input-area textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    font-family: inherit;
    resize: none;
    height: 45px;
}
.chat-input-area textarea:focus { outline: none; border-color: var(--primary); }

.mobile-only { display: none; }

/* Responsive adjustments for wallet and notif */
@media (max-width: 1024px) {
    .wallet-actions-card { grid-template-columns: 1fr; }
    .tickets-layout { grid-template-columns: 280px 1fr; }
}

@media (max-width: 768px) {
    .wallet-actions-card { display: flex; flex-direction: column; gap: 20px; }
    .action-input-group { flex-direction: column; }
    .charge-btn { width: 100%; padding: 12px; }
    
    .notif-card { flex-direction: column; }
    .notif-meta { flex-direction: row; border-right: none; padding-right: 0; border-top: 1px dashed var(--border); padding-top: 15px; margin-top: 10px; width: 100%; align-items: center; }

    #quick-notif-modal .modal-card { margin: 20px; width: calc(100% - 40px); }

    .tickets-layout { grid-template-columns: 1fr; position: relative; height: calc(100vh - 200px); min-height: 400px; }
    .ticket-chat-area { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; transform: translateX(100%); transition: transform 0.3s ease; }
    .ticket-chat-area.active { transform: translateX(0); }
    .mobile-only { display: flex; align-items: center; justify-content: center; }

    /* Responsive touch targets and spacing */
    .welcome-banner { padding: 16px; }
    .welcome-banner h1 { font-size: 1.1rem; }
    .icon-btn { padding: 10px; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
    .close-btn { width: 36px; height: 36px; }
    .expert-call-btn { padding: 8px 16px; }
    .mark-read-btn { padding: 6px 12px; }
    .mini-products-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .mini-prod-img { height: 100px; }
    .modal-info-summary div { min-width: 120px; }
    .modal-card { max-width: calc(100vw - 30px); }
    .chat-sidebar-card { max-width: 100%; }
    .section-title { font-size: 1.1rem; }
    .nav-item { padding: 6px 10px; }
}

/* Dashboard v2 New Components */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.q-action-card {
    background: var(--surface);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.q-action-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.q-action-card span { font-size: 0.85rem; font-weight: bold; color: var(--text-main); }
.q-icon { width: 50px; height: 50px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }

.overview-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.overview-col { display: flex; flex-direction: column; gap: 20px; }

.modern-stat {
    justify-content: space-between;
    padding: 25px;
    border-radius: 24px;
    background: linear-gradient(to left, var(--surface), #f8fafc);
}
.stat-icon-circle { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.wallet-bg { background: #dcfce7; color: #16a34a; }

.credit-widget {
    background: var(--surface);
    padding: 25px;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.progress-bar-bg { height: 10px; background: #f1f5f9; border-radius: 10px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(to left, var(--primary), #60a5fa); border-radius: 10px; transition: width 1s ease-in-out; }

.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
    background: var(--surface);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.act-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.mini-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.mini-prod-card {
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border);
    padding: 15px;
    transition: all 0.3s;
}
.mini-prod-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.mini-prod-img { width: 100%; height: 120px; object-fit: contain; border-radius: 12px; margin-bottom: 12px; background: #f8fafc; }
.mini-prod-name { font-size: 0.85rem; font-weight: bold; margin-bottom: 8px; height: 40px; overflow: hidden; }
.mini-prod-price { color: var(--primary); font-weight: bold; font-size: 0.95rem; }

@media (max-width: 900px) {
    .overview-main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Order Chat Sidebar & Floating UI --- */
.chat-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2500;
    display: none;
    justify-content: flex-end;
    backdrop-filter: blur(2px);
}
.chat-sidebar-overlay.open { display: flex; }

.chat-sidebar-card {
    width: 100%;
    max-width: 450px;
    height: 100%;
    background: var(--surface);
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    animation: slideInChat 0.3s ease-out;
}

@keyframes slideInChat {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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

#open-order-chat-btn-floating {
    position: fixed;
    left: 0;
    top: 40%;
    background: #0ea5e9;
    color: white;
    padding: 15px 8px;
    border-radius: 0 12px 12px 0;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1100;
    cursor: pointer;
    box-shadow: 4px 0 15px rgba(14, 165, 233, 0.3);
    transition: all 0.3s;
}

#open-order-chat-btn-floating.has-new-messages {
    background: #ef4444;
    animation: pulseChatBtn 2s infinite;
}

@keyframes pulseChatBtn {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#open-order-chat-btn-floating:hover {
    padding-left: 15px;
}

#open-order-chat-btn-floating span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.9rem;
    font-weight: bold;
}


.chat-unread-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    background-color: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4);
    z-index: 10;
}

/* === Blinking indicator برای پیام‌های نخوانده === */
/* نشانگر چشمک‌زن: وقتی پیام نخوانده باشد، badge چشمک می‌زند.
   وقتی کاربر پیام‌ها را ببیند یا پیام نخوانده نباشد، badge حذف می‌شود. */
.chat-unread-badge.blinking {
    animation: chat-blink 1s ease-in-out infinite;
    /* رنگ قرمز روشن‌تر برای جلب توجه */
    background-color: #ef4444;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #ef4444, 0 4px 10px rgba(239, 68, 68, 0.5);
}

@keyframes chat-blink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

/* حالت نقطه‌ای کوچک برای نشانگر چت‌های خصوصی */
.chat-unread-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--danger);
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(239, 68, 68, 0.5);
    z-index: 10;
}
.chat-unread-dot.blinking {
    animation: chat-blink 1s ease-in-out infinite;
}

/* Badge کنار تب «گفتگوی داخلی» در سایدبار */
#nav-chat-badge.blinking {
    animation: chat-blink 1s ease-in-out infinite;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #ef4444, 0 4px 10px rgba(239, 68, 68, 0.5);
}
/* === Small Mobile Fixes === */
@media (max-width: 480px) {
    .welcome-banner { padding: 12px; flex-direction: column; gap: 8px; align-items: flex-start; }
    .stat-card { padding: 15px; gap: 10px; }
    .stat-icon { width: 40px; height: 40px; }
    .amount { font-size: 1.1rem; }
    .quick-actions-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .q-action-card { padding: 15px; }
    .main-content { padding: 15px; }
    .modal-header, .modal-body, .modal-footer { padding: 15px; }
    .modal-footer { flex-direction: column; }
    .modal-footer button { width: 100%; }
    .modal-totals { padding: 15px; }
    .modal-totals div { font-size: 0.9rem; }
    .modal-totals strong { font-size: 1rem; }
    .chat-input-area { padding: 10px; }
    .chat-input-area textarea { height: 40px; }
    .nav-item { padding: 6px 8px; font-size: 0.7rem; }
    .nav-item svg { width: 20px; height: 20px; }
    .nav-menu { padding: 8px 5px; }
    .mobile-header { padding: 12px 15px; }
    .mobile-header .brand { font-size: 1.1rem; }
    .stat-card.modern-stat { padding: 16px; }
    .credit-widget { padding: 16px; }
    .expert-card { padding: 15px; gap: 10px; }
    .tickets-list-sidebar { padding: 10px; }
    .chat-messages { padding: 12px; }
    .chat-bubble { max-width: 85%; padding: 10px 12px; font-size: 0.9rem; }
    .details-table th, .details-table td { padding: 8px; font-size: 0.8rem; }
    .details-table { min-width: 500px; }
    #open-order-chat-btn-floating { top: 35%; padding: 12px 6px; }
    #open-order-chat-btn-floating span { font-size: 0.8rem; }
}

/* ==========================================
 * F2 — Comprehensive Responsive Fixes (Round 2)
 * New component styles for cleaner responsive control
 * ========================================== */

/* --- Expert Panel: filters-container (semantic, no inline styles) --- */
.filters-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
}
.filter-input { padding: 8px 10px; font-size: 0.9rem; min-width: 0; }
.filters-container .filter-input[type="text"] { width: 160px; }
.filters-container .filter-input:not(.filter-date):not([type="text"]) { width: 180px; }
.filters-container .filter-input.filter-date { width: 130px; }
.filter-row {
    display: flex;
    gap: 5px;
    align-items: center;
}
.filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.filter-apply-btn {
    padding: 8px 25px;
    margin-right: auto;
}

/* --- Expert Panel: internal chat semantic classes --- */
.chat-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 500px;
    max-height: 800px;
    max-width: 1000px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.chat-contacts {
    width: 320px;
    border-left: 1px solid var(--border);
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.chat-contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}
.chat-main-header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 15px;
    flex-shrink: 0;
}
.chat-main-header h3 { margin: 0; }
.chat-messages-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f1f5f9;
}
.chat-reply-preview {
    display: none;
    padding: 10px 20px;
    background: #ede9fe;
    border-left: 4px solid var(--expert-primary, #8b5cf6);
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 40px;
    border-top: 1px solid var(--border);
}
.chat-reply-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 90%;
}
.chat-reply-sender {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--expert-primary, #8b5cf6);
}
.chat-reply-text {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-file-preview {
    display: none;
    padding: 10px 20px;
    background: #e2e8f0;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 40px;
    border-top: 1px solid var(--border);
}
.chat-file-name {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}
.chat-cancel-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-remove-file-btn { color: var(--danger); }
.chat-form {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    align-items: center;
    min-height: 70px;
}
.chat-attach-btn {
    color: var(--text-muted);
    background: #f8fafc;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-file-input { display: none; }
.chat-input-text {
    flex: 1;
    margin: 0;
    background: #f8fafc;
    min-width: 0;
    font-size: 16px;
}
.chat-submit-btn {
    background: var(--expert-primary, #8b5cf6);
    color: white;
    padding: 0 25px;
    flex-shrink: 0;
    height: 100%;
    min-height: 44px;
}
.chat-back-btn {
    display: none;
    margin-bottom: 10px;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    color: var(--text-main);
    min-height: 40px;
}

/* --- Expert Panel: modal-refer-section + modal-footer-expert --- */
.modal-card-wide { max-width: 900px; }
.modal-refer-section {
    background: #f8fafc;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    display: none;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.modal-refer-info { flex: 1; min-width: 200px; }
.modal-refer-info h4 { margin: 0 0 5px 0; color: var(--text-main); font-size: 0.95rem; }
.modal-refer-info p { margin: 0; font-size: 0.8rem; color: var(--text-muted); }
.modal-refer-select { width: 200px; margin: 0; padding: 8px; }
.modal-refer-btn { background: #f59e0b; color: white; min-height: 44px; }

.modal-footer-expert {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}
.modal-footer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.modal-print-btn { background: #64748b; color: white; min-height: 44px; }
.modal-label-btn { background: #334155; color: white; min-height: 44px; }
.modal-approve-btn { background: var(--success); color: white; padding: 12px 40px; min-height: 44px; }

/* --- Order chat sidebar (shared by dashboard + expert) --- */
.order-chat-messages { height: calc(100vh - 180px); }

/* --- Dashboard: profile-actions row (was inline flex) --- */
#profile-actions {
    display: none;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- Dashboard: ticket form (was inline flex) --- */
#new-ticket-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: calc(100% - 70px);
    overflow-y: auto;
}

/* --- Dashboard: ticket empty state (was inline flex) --- */
#ticket-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* --- Dashboard: quick notif modal (was inline flex column) --- */
#quick-notif-modal .modal-card {
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
#quick-notif-modal .modal-header { flex-shrink: 0; }
#quick-notif-modal .modal-body { padding: 15px; overflow-y: auto; flex: 1; }
#quick-notif-list.quick-notif-list-style { gap: 8px; }
.quick-notif-list-style .loading-state { padding: 20px; }

/* === Responsive: filters at 1024px (tablet) === */
@media (max-width: 1024px) and (min-width: 769px) {
    .filters-container .filter-input[type="text"] { width: 180px; }
    .filters-container .filter-input:not(.filter-date):not([type="text"]) { width: 150px; }
    .filters-container .filter-input.filter-date { width: 110px; }
}

/* === Responsive: expert chat at 768px === */
@media (max-width: 768px) {
    /* Filters: stack vertically on mobile */
    .filters-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .filters-container .filter-input,
    .filters-container .filter-input[type="text"],
    .filters-container .filter-input:not(.filter-date):not([type="text"]),
    .filters-container .filter-input.filter-date {
        width: 100%;
    }
    .filter-row { width: 100%; }
    .filter-row .filter-input.filter-date { flex: 1; }
    .filter-apply-btn { width: 100%; margin-right: 0; padding: 12px; min-height: 44px; }

    /* Internal chat: stack and toggle */
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 160px);
        min-height: 400px;
        max-height: none;
        max-width: 100%;
    }
    .chat-contacts {
        width: 100%;
        max-height: 140px;
        border-left: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    .chat-contacts-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px;
    }
    .chat-contacts-list .list-card {
        flex-shrink: 0;
        min-width: 160px;
    }
    .chat-main { flex: 1; min-height: 0; }
    .chat-messages-area { padding: 12px; gap: 10px; }

    /* Mobile chat pattern: hide contacts when chat is active */
    .chat-container.mobile-chat-active .chat-contacts {
        display: none;
    }
    .chat-back-btn {
        display: inline-flex;
    }
    .chat-container:not(.mobile-chat-active) .chat-back-btn {
        display: none;
    }

    /* Chat form: wrap on small screens */
    .chat-form {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    .chat-input-text {
        flex: 1 1 100%;
        order: 1;
    }
    .chat-attach-btn { order: 2; }
    .chat-submit-btn {
        order: 3;
        flex: 1;
        padding: 12px;
        height: auto;
    }

    /* Modal refer section: stack vertically */
    .modal-refer-section {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .modal-refer-info { width: 100%; }
    .modal-refer-select { width: 100%; }
    .modal-refer-btn { width: 100%; }

    /* Modal footer: stack vertically */
    .modal-footer-expert {
        flex-direction: column;
        align-items: stretch;
    }
    .modal-footer-actions {
        flex-direction: column;
        gap: 8px;
    }
    .modal-print-btn, .modal-label-btn, .modal-approve-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    .modal-approve-btn { padding: 12px; }

    /* Order chat sidebar: full screen on mobile */
    .order-chat-messages { height: calc(100vh - 130px) !important; }
    .chat-sidebar-card { max-width: 100% !important; }

    /* Modal card wide: full width on mobile */
    .modal-card-wide { max-width: 100% !important; }
}

/* === Responsive: very small screens === */
@media (max-width: 480px) {
    .filters-container { padding: 12px; }
    .filter-input { font-size: 16px; }
    .filter-apply-btn { padding: 12px; }
    .chat-container { height: calc(100vh - 140px); }
    .chat-contacts { max-height: 120px; }
    .chat-contacts-list .list-card { min-width: 140px; padding: 10px !important; }
    .chat-messages-area { padding: 10px; }
    .chat-bubble { font-size: 0.85rem; padding: 8px 10px; }
    .modal-header h2 { font-size: 1rem; }
}

/* === iOS zoom prevention: ensure all inputs use 16px font on mobile === */
@media (max-width: 768px) {
    .profile-input,
    input[type="text"],
    input[type="tel"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
    }
}

/* === Better touch targets on mobile === */
@media (max-width: 768px) {
    .expert-call-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; }
    .icon-btn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 8px; }
    .close-btn { width: 40px; height: 40px; }
    .nav-item { min-height: 44px; }
    .logout-btn { min-height: 44px; }
    .q-action-card { min-height: 88px; }
}

/* === Fluid typography (desktop only — mobile keeps explicit sizes from 768px query) === */
@media (min-width: 769px) {
    .section-title { font-size: clamp(1rem, 1.5vw, 1.2rem); }
    .welcome-banner h1 { font-size: clamp(1.1rem, 1.5vw, 1.25rem); }
}

/* === Tables: always wrap in scrollable container === */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* === Profile actions responsive === */
@media (max-width: 480px) {
    #profile-actions { flex-direction: column-reverse; align-items: stretch; }
    #profile-actions button { width: 100%; }
}



/* ===== F4 ISSUE 4: Mobile order list cards in expert panel ===== */
@media (max-width: 768px) {
    /* لیست سفارشات در پنل اپراتور - چیدمان عمودی */
    #orders-list .list-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 16px !important;
        border-radius: 14px !important;
    }
    #orders-list .list-card-right {
        width: 100% !important;
        gap: 8px !important;
    }
    #orders-list .list-card-left {
        width: 100% !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding-top: 12px !important;
        border-top: 1px dashed var(--border) !important;
    }
    #orders-list .list-card-left .list-card-title {
        text-align: right !important;
        font-size: 1.1rem !important;
        color: var(--primary) !important;
    }
    #orders-list .order-card-btn {
        width: 100% !important;
        text-align: center !important;
        padding: 12px !important;
        min-height: 44px !important;
        font-size: 0.95rem !important;
    }
    #orders-list .list-card-title.order-card-id {
        font-size: 1.1rem !important;
        font-weight: bold !important;
    }
    #orders-list .list-card-date.order-card-colleague {
        font-size: 0.85rem !important;
        color: var(--text-muted) !important;
    }
    #orders-list .status-badge {
        font-size: 0.8rem !important;
        padding: 6px 14px !important;
    }
    #orders-list .order-card-referred {
        font-size: 0.75rem !important;
    }
}

/* ===== F4 ISSUE 5: Mobile order details modal - colleague info section ===== */
@media (max-width: 768px) {
    /* اطلاعات همکار در مودال - چیدمان عمودی */
    #modal-colleague-info {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 15px !important;
    }
    #modal-colleague-info .info-group {
        background: var(--surface) !important;
        padding: 12px !important;
        border-radius: 10px !important;
        border: 1px solid var(--border) !important;
    }
    #modal-colleague-info .info-group label {
        font-size: 0.8rem !important;
        color: var(--text-muted) !important;
        font-weight: bold !important;
        margin-bottom: 8px !important;
        display: block !important;
    }
    #modal-colleague-info .info-group > div {
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
    }
    /* بخش ارجاع در مودال */
    #modal-refer-section {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 15px !important;
    }
    #modal-refer-section > div:first-child {
        width: 100% !important;
    }
    #modal-refer-section select {
        width: 100% !important;
    }
    #modal-refer-section button {
        width: 100% !important;
    }
    /* فوتر مودال */
    #order-review-modal .modal-footer {
        flex-direction: column !important;
        gap: 10px !important;
    }
    #order-review-modal .modal-footer > div {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    #order-review-modal .modal-footer button {
        width: 100% !important;
        min-height: 44px !important;
        text-align: center !important;
    }
    #order-review-modal .modal-card {
        max-width: 100% !important;
        margin: 0 !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    #order-review-modal .modal-overlay {
        padding: 0 !important;
    }
    /* جدول اقلام سفارش */
    #order-review-modal .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    #order-review-modal .details-table {
        min-width: 500px !important;
        font-size: 0.85rem !important;
    }
    #order-review-modal .details-table th,
    #order-review-modal .details-table td {
        padding: 10px 8px !important;
    }
    /* input تعداد تایید شده */
    #order-review-modal .approved-qty-input {
        width: 60px !important;
        height: 36px !important;
        font-size: 1rem !important;
        text-align: center !important;
    }
}

/* ===== F4 ISSUE 4b: Mobile filters in expert panel orders tab ===== */
@media (max-width: 768px) {
    .filters-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px !important;
    }
    .filters-container > input[type="text"],
    .filters-container > select {
        width: 100% !important;
        padding: 10px !important;
        font-size: 16px !important;
    }
    .filters-container > div[style*="display: flex"] {
        width: 100% !important;
    }
    .filters-container > div[style*="display: flex"] input {
        flex: 1 !important;
        width: auto !important;
    }
    .filters-container > button {
        width: 100% !important;
        margin-right: 0 !important;
        padding: 12px !important;
        min-height: 44px !important;
    }
}

/* ===== F4 ISSUE 6: Mobile chat in expert panel ===== */
@media (max-width: 768px) {
    #tab-chat > div[style*="display: flex"][style*="height: calc"] {
        flex-direction: column !important;
        height: calc(100vh - 160px) !important;
        min-height: 400px !important;
        max-width: 100% !important;
        max-height: none !important;
    }
    #tab-chat > div > div[style*="width: 320px"] {
        width: 100% !important;
        max-height: 140px !important;
        border-left: none !important;
        border-bottom: 1px solid var(--border) !important;
        flex-shrink: 0 !important;
    }
    #tab-chat > div > div[style*="flex: 1"] {
        min-height: 0 !important;
        flex: 1 !important;
    }
    #internal-chat-form {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px !important;
    }
    #internal-chat-input {
        width: 100% !important;
        flex: 1 1 100% !important;
        order: 1 !important;
    }
    #internal-chat-attach-btn {
        order: 2 !important;
    }
    #internal-chat-form > button[type="submit"] {
        order: 3 !important;
        flex: 1 !important;
        padding: 12px !important;
        min-height: 44px !important;
    }
}


/* ===== FIX: Ticket form in desktop mode ===== */
#new-ticket-form {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#new-ticket-form .info-group {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}

#new-ticket-form select#ticket-subject,
#new-ticket-form .profile-input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}

/* اطمینان از اینکه ticket-chat-area عرض کامل می‌گیرد */
.ticket-chat-area {
    overflow: hidden;
}

#new-ticket-form-area {
    width: 100%;
    overflow-y: auto;
}

/* در دسکتاپ، فرم تیکت باید عرض کامل بگیرد */
@media (min-width: 769px) {
    #new-ticket-form {
        padding: 20px !important;
    }
    
    #new-ticket-form .info-group {
        width: 100% !important;
        margin-bottom: 15px;
    }
    
    #new-ticket-form select#ticket-subject {
        width: 100% !important;
        max-width: 100% !important;
    }
}


/* ===== FIX: Ticket subject white overlay in desktop ===== */
.ticket-chat-area {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
}

#new-ticket-form-area {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
    position: relative !important;
}

#new-ticket-form-area .chat-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: var(--surface) !important;
}

/* اطمینان از اینکه select موضوعات کامل دیده شود */
#new-ticket-form-area select#ticket-subject {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: var(--surface) !important;
    color: var(--text-main) !important;
}

/* جلوگیری از overlay سفید روی موضوعات */
#new-ticket-form-area .info-group {
    position: relative !important;
    z-index: 1 !important;
    background: var(--surface) !important;
}

#new-ticket-form-area label {
    background: var(--surface) !important;
    position: relative !important;
    z-index: 2 !important;
}


/* ===== Expert Panel - Order Detail Info Cards ===== */
#modal-colleague-info {
    gap: 12px !important;
}
.info-card {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    transition: all 0.25s ease;
}
.info-card:hover {
    border-color: #C7D2FE;
    box-shadow: 0 4px 12px -3px rgba(99, 102, 241, 0.1);
}
.info-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.info-card-header svg {
    color: #6366F1;
    flex-shrink: 0;
}
.info-card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.info-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 4px;
}
.info-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
}
.info-card-row span {
    color: #94A3B8;
    flex-shrink: 0;
}
.info-card-row strong {
    color: #1E293B;
    text-align: left;
}
.info-card-customer { border-right: 3px solid #6366F1; }
.info-card-finance { border-right: 3px solid #10B981; }
.info-card-shipping { border-right: 3px solid #F59E0B; }
.info-card-payment { border-right: 3px solid #8B5CF6; }

/* ===== FIX: Ticket subject select - remove white bar ===== */
select#ticket-subject {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    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='%236366f1' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: left 12px center !important;
    background-color: #fff !important;
    padding-left: 35px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 10px !important;
    height: 44px !important;
    font-size: 0.9rem !important;
    color: #1e293b !important;
    outline: none !important;
}
select#ticket-subject:focus {
    border-color: #6366f1 !important;
}
select#ticket-subject option {
    color: #1e293b !important;
    background: #fff !important;
}

/* ===== Product Slider ===== */
.product-slider-container { position: relative; display: flex; align-items: center; gap: 8px; }
.product-slider {
    display: flex; gap: 12px; overflow-x: auto; scroll-behavior: smooth;
    scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; padding: 4px 0;
    flex: 1; -webkit-overflow-scrolling: touch;
}
.product-slider::-webkit-scrollbar { height: 4px; }
.product-slider::-webkit-scrollbar-track { background: transparent; }
.product-slider::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.slider-nav-btn {
    background: var(--primary); color: white; border: none; width: 36px; height: 36px;
    border-radius: 50%; cursor: pointer; font-size: 1.3rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all 0.2s; z-index: 5;
}
.slider-nav-btn:hover { background: var(--primary-hover); transform: scale(1.1); }
.slider-nav-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }
.slider-card {
    background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px;
    min-width: 180px; max-width: 180px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
    transition: box-shadow 0.2s;
}
.slider-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.slider-card img { width: 100%; height: 100px; object-fit: contain; border-radius: 8px; background: #f8fafc; padding: 4px; box-sizing: border-box; }
.slider-card-name { font-size: 0.8rem; font-weight: 600; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slider-card-price { font-size: 0.82rem; font-weight: 700; color: #059669; }
.slider-card-badge { font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; display: inline-block; }
@media (max-width: 768px) {
    .slider-nav-btn { display: none; }
    .slider-card { min-width: 150px; max-width: 150px; }
    .slider-card img { height: 80px; }
}

/* ============================================================
   Wholesale Baskets (سبدهای فروش عمده)
   ============================================================ */

.wholesale-basket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.wholesale-basket-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
}

.wholesale-basket-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.wholesale-basket-card.expired {
    background: #f8fafc;
    opacity: 0.7;
    filter: grayscale(0.6);
}

.wholesale-basket-card.expired:hover {
    transform: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.wholesale-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.wholesale-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.4;
}

.wholesale-card-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.wholesale-card-badge.active-badge {
    background: #dcfce7;
    color: #047857;
}

.wholesale-card-badge.expired-badge {
    background: #fee2e2;
    color: #b91c1c;
}

.wholesale-card-desc {
    font-size: 0.82rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
    min-height: 1.5em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wholesale-card-stats {
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
}

.wholesale-meta-item {
    font-size: 0.78rem;
    color: #475569;
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.wholesale-meta-item span {
    color: #94a3b8;
}

.wholesale-meta-item strong {
    color: #1e293b;
    font-weight: 600;
}

.wholesale-card-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.wholesale-price-box {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    border: 1px solid #a7f3d0;
}

.wholesale-price-box:nth-child(2) {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-color: #c4b5fd;
}

.wholesale-price-label {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 4px;
}

.wholesale-price-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #047857;
    line-height: 1.2;
}

.wholesale-price-box:nth-child(2) .wholesale-price-value {
    color: #6d28d9;
}

.wholesale-price-value small {
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
}

.wholesale-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.wholesale-view-btn,
.wholesale-buy-btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
}

.wholesale-view-btn {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.wholesale-view-btn:hover {
    background: #e2e8f0;
}

.wholesale-buy-btn {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #fff;
}

.wholesale-buy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.wholesale-error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-right: 4px solid #dc2626;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* مودال سبد عمده */
.wholesale-popup-table {
    font-size: 0.82rem;
}

.wholesale-popup-table th,
.wholesale-popup-table td {
    padding: 8px 10px;
    text-align: right;
    border-bottom: 1px solid #e2e8f0;
}

.wholesale-popup-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 0.78rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

.wholesale-popup-totals {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wholesale-totals-block {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px 14px;
}

.wholesale-totals-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.wholesale-totals-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: #475569;
    padding: 3px 0;
}

.wholesale-totals-row.total {
    border-top: 1px dashed #cbd5e1;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 0.95rem;
}

.wholesale-credit-info {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.82rem;
    color: #92400e;
}

.wholesale-stock-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-right: 4px solid #dc2626;
    color: #991b1b;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    margin-top: 12px;
    line-height: 1.7;
}

.wholesale-popup-payment {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.wholesale-payment-option {
    cursor: pointer;
    display: block;
    flex: 1;
    min-width: 200px;
}

.wholesale-payment-option input[type="radio"] {
    display: none;
}

.wholesale-payment-card {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    transition: all 0.2s;
    background: #fff;
}

.wholesale-payment-card strong {
    display: block;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 4px;
}

.wholesale-payment-card small {
    display: block;
    font-size: 0.78rem;
    color: #64748b;
}

.wholesale-payment-option:hover .wholesale-payment-card {
    border-color: #94a3b8;
}

.wholesale-payment-option.selected .wholesale-payment-card {
    border-color: var(--primary, #6366f1);
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.wholesale-payment-option.selected .wholesale-payment-card strong {
    color: var(--primary, #6366f1);
}

/* ریسپانسیو */
@media (max-width: 768px) {
    .wholesale-basket-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .wholesale-card-stats {
        grid-template-columns: 1fr;
    }
    .wholesale-card-prices {
        grid-template-columns: 1fr;
    }
    .wholesale-card-actions {
        flex-direction: column;
    }
    .wholesale-popup-table {
        font-size: 0.78rem;
    }
    .wholesale-popup-table th,
    .wholesale-popup-table td {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .wholesale-basket-card {
        padding: 14px;
    }
    .wholesale-card-name {
        font-size: 0.95rem;
    }
}


/* ===== Wholesale Order Badges (تمایز سفارشات سبد عمده) ===== */
/* کارت سفارش عمده — حاشیه راست بنفش + پس‌زمینه ملایم */
.wholesale-order-card {
    border-right: 4px solid #6366f1 !important;
    background: linear-gradient(135deg, #fafbff 0%, #f5f7ff 100%) !important;
}

/* نشان در جزئیات سفارش */
.wholesale-badge-detail {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 700;
    margin-right: 8px;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* موبایل */
@media (max-width: 480px) {
    .wholesale-order-card {
        border-right-width: 3px !important;
    }
}


/* ===== Product Gallery Modal (گالری تصاویر محصول) ===== */
/* اطمینان از مرکزی بودن مودال گالری در همه دستگاه‌ها */
#product-gallery-modal {
    align-items: center !important;
    justify-content: center !important;
}

#product-gallery-modal .modal-card {
    margin: auto !important;
    max-width: 700px;
    width: 100%;
}

#product-gallery-modal .modal-card > div[style*="padding"] {
    text-align: center;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

#gallery-main-img {
    display: block;
    margin: 0 auto 15px !important;
    object-fit: contain;
}

#gallery-thumbnails {
    justify-content: center;
}

#gallery-thumbnails img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    cursor: pointer;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: #f8fafc;
    padding: 2px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#gallery-thumbnails img:hover {
    border-color: var(--primary);
}

#gallery-thumbnails img.active {
    border-color: var(--primary);
    border-width: 3px;
}

/* موبایل */
@media (max-width: 480px) {
    #product-gallery-modal .modal-card {
        max-width: calc(100vw - 30px);
        margin: 10px !important;
    }
    #gallery-main-img {
        max-height: 300px !important;
    }
    #gallery-thumbnails img {
        width: 50px;
        height: 50px;
    }
}


/* ===== Dashboard Banners (بنرهای داشبورد همکار) ===== */
.dashboard-banner-container {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-banner {
    display: block;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #f8fafc;
}

.dashboard-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.dashboard-banner picture {
    display: block;
    width: 100%;
}

.banner-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* دسکتاپ: تصویر دسکتاپ نمایش داده شود، موبایل مخفی */
.banner-desktop {
    display: block;
}
.banner-mobile {
    display: none;
}

/* موبایل: تصویر موبایل نمایش داده شود، دسکتاپ مخفی */
@media (max-width: 768px) {
    .banner-desktop {
        display: none;
    }
    .banner-mobile {
        display: block;
    }
    .dashboard-banner {
        border-radius: 10px;
    }
}

/* موبایل کوچک */
@media (max-width: 480px) {
    .dashboard-banner-container {
        margin-bottom: 12px;
        gap: 8px;
    }
}
