/* ============================================================
   CRM Design System - Utility Classes Extension
   Version: 1.0
   
   This file extends your existing style.css with:
   1. Expanded CSS Variables (including dark mode)
   2. Utility Classes for common inline style patterns
   3. Component modifiers for consistency
   
   HOW TO USE:
   - Add this file AFTER style.css in your base.html
   - Gradually replace inline styles with these classes
   - Dark mode will work automatically once integrated
   ============================================================ */

/* ============================================================
   SECTION 1: EXPANDED CSS VARIABLES
   ============================================================ */

:root {
    /* --- Existing Variables (reference) ---
    --primary: #183453;
    --primary-hover: #2A4568;
    --primary-light: #E8EEF5;
    --text-main: #1B2559;
    --text-secondary: #4f5256;
    --text-muted: #A3AED0;
    --bg-body: #F4F7FE;
    --bg-card: #FFFFFF;
    --success: #05CD99;
    --warning: #FFB547;
    --danger: #E31A1A;
    */
    
    /* --- NEW: Semantic Color Extensions --- */
    --text-inverse: #FFFFFF;
    --text-link: var(--primary);
    --text-link-hover: var(--primary-hover);
    
    /* --- NEW: Border Colors --- */
    --border-light: #F0F0F0;
    --border-default: var(--primary-light);
    --border-strong: var(--primary);
    --border-medium: #22386275; 
    
    /* --- NEW: Background Variants --- */
    --bg-hover: #FFFFFF;
    --bg-active: var(--primary-light);
    --bg-overlay: rgba(24, 52, 83, 0.4);
    --bg-success-light: #E6FFFA;
    --bg-warning-light: #FFF7E6;
    --bg-danger-light: #FFF5F5;
    
    /* --- NEW: Shadow Variants --- */
    --shadow-xs: 0 1px 2px rgba(112, 144, 176, 0.05);
    --shadow-lg: 0 20px 40px rgba(112, 144, 176, 0.15);
    --shadow-focus: 0 0 0 3px rgba(24, 52, 83, 0.1);
    
    /* --- NEW: Spacing Scale --- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 15px;
    --space-lg: 20px;
    --space-xl: 25px;
    --space-2xl: 30px;
    
    /* --- NEW: Font Sizes --- */
    --font-xs: 10px;
    --font-sm: 11px;
    --font-base: 12px;
    --font-md: 13px;
    --font-lg: 14px;
    --font-xl: 15px;
    --font-2xl: 18px;
    --font-3xl: 20px;
    
    /* --- NEW: Tier Colors (for CLV, rankings) --- */
    --tier-titanium: #374151;
    --tier-titanium-light: #E5E7EB;
    --tier-gold: #F59E0B;
    --tier-gold-light: #FEF3C7;
    --tier-silver: #9CA3AF;
    --tier-silver-light: #F3F4F6;
    --tier-cyan: #0891B2;
}

/* ============================================================
   SECTION 2: DARK MODE VARIABLES
   ============================================================ */

[data-theme="dark"] {
    /* --- Core Palette (Inverted) --- */
    --primary: #5B8DEF;
    --primary-hover: #7BA3F3;
    --primary-light: #1E293B;
    
    /* --- Text Colors --- */
    --text-main: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-inverse: #0F172A;
    
    /* --- Backgrounds --- */
    --bg-body: #0F172A;
    --bg-card: #1E293B;
    --bg-hover: #334155;
    --bg-active: #334155;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    
    /* --- Status Colors (adjusted for dark) --- */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg-success-light: rgba(16, 185, 129, 0.15);
    --bg-warning-light: rgba(245, 158, 11, 0.15);
    --bg-danger-light: rgba(239, 68, 68, 0.15);
    
    /* --- Borders --- */
    --border-light: #334155;
    --border-default: #475569;
    --border-strong: #5B8DEF;
    
    /* --- Shadows (darker, more subtle) --- */
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
    --shadow-focus: 0 0 0 3px rgba(91, 141, 239, 0.3);
    
    /* --- Tier Colors (adjusted) --- */
    --tier-titanium: #9CA3AF;
    --tier-titanium-light: #374151;
    --tier-gold: #FBBF24;
    --tier-gold-light: #78350F;
    --tier-silver: #D1D5DB;
    --tier-silver-light: #4B5563;
}

/* ============================================================
   SECTION 3: LAYOUT UTILITIES (UPDATED)
   ============================================================ */

/* --- Flexbox --- */
.flex { display: flex; }
.flex-inline { display: inline-flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow-1 { flex-grow: 1; }
.block { display: block;}

/* --- Alignment --- */
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

/* --- Common Flex Patterns --- */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col-gap { display: flex; flex-direction: column; gap: var(--space-md); }

/* --- Gap Utilities --- */
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* --- Grid Utilities (FIXED) --- */
/* اضافه کردن display: grid به تمام کلاس‌های ستونی */
.grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-5 {
    display: grid;
    gap: var(--space-md);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}
.grid-cols-5 {
    grid-template-columns: repeat(5, 1fr);
}
/* Responsive Grid */
@media (max-width: 1400px) { 
    .grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
    .grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(3, 1fr); } 
}

@media (max-width: 992px) { 
    .grid-cols-5 { grid-template-columns: 1fr; }
    .grid-cols-4 { grid-template-columns: 1fr; }
    .grid-cols-3 { grid-template-columns: 1fr; }
    .grid-cols-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   SECTION 4: SPACING UTILITIES
   ============================================================ */

/* --- Margin --- */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mr-sm { margin-right: var(--space-sm); }
.mr-md { margin-right: var(--space-md); }
.ml-sm { margin-left: var(--space-sm); }
.ml-xs { margin-left: var(--space-xs); }




/* --- Padding --- */
.p-0 { padding: 0; }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }
.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.py-sm { padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.pb-md { padding-bottom: var(--space-md); }

/* ============================================================
   SECTION 5: TYPOGRAPHY UTILITIES
   ============================================================ */

/* --- Font Sizes --- */
.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-base { font-size: var(--font-base); }
.text-md { font-size: var(--font-md); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.text-2xl { font-size: var(--font-2xl); }
.text-3xl { font-size: var(--font-3xl); }

/* --- Font Weights --- */
.fw-normal { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.fw-extrabold { font-weight: 800; }

/* --- Text Alignment --- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }

/* --- Text Utilities --- */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.text-nowrap { white-space: nowrap; }
.text-wrap { white-space: normal; }
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================================
   SECTION 6: COLOR UTILITIES
   ============================================================ */

/* --- Text Colors --- */
.text-primary { color: var(--primary); }
.text-main { color: var(--text-main); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-inverse { color: var(--text-inverse); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* --- Icon Colors (for <i> elements) --- */
.icon-primary { color: var(--primary); }
.icon-success { color: var(--success); }
.icon-warning { color: var(--warning); }
.icon-danger { color: var(--danger); }
.icon-muted { color: var(--text-muted); }
.icon-secondary { color: var(--text-secondary); }

/* --- Background Colors --- */
.bg-body { background-color: var(--bg-body); }
.bg-card { background-color: var(--bg-card); }
.bg-primary { background-color: var(--primary); }
.bg-primary-light { background-color: var(--primary-light); }
.bg-success-light { background-color: var(--bg-success-light); }
.bg-warning-light { background-color: var(--bg-warning-light); }
.bg-danger-light { background-color: var(--bg-danger-light); }
.bg-transparent { background-color: transparent; }

/* --- Tier Background Colors --- */
.bg-tier-titanium { background-color: var(--tier-titanium); }
.bg-tier-gold { background-color: var(--tier-gold); }
.bg-tier-silver { background-color: var(--tier-silver); }
.text-tier-titanium { color: var(--tier-titanium); }
.text-tier-gold { color: var(--tier-gold); }
.text-tier-silver { color: var(--tier-silver); }

/* ============================================================
   SECTION 7: BORDER UTILITIES
   ============================================================ */

.border-0 { border: none; }
.border { border: 1px solid var(--border-default); }
.border-light { border: 1px solid var(--border-light); }
.border-medium { border: 1px solid var(--border-medium); }
.border-strong { border: 1px solid var(--border-strong); }
.border-transparent { border: 1px solid transparent; }

/* --- Border Sides --- */
.border-bottom { border-bottom: 1px solid var(--border-light); }
.border-top { border-bottom: 1px solid var(--border-light); }

/* --- Accent Borders (from your templates) --- */
.border-accent-success { border-right: 3px solid var(--success); }
.border-accent-warning { border-right: 3px solid var(--warning); }
.border-accent-danger { border-right: 3px solid var(--danger); }
.border-accent-primary { border-right: 3px solid var(--primary); }
.border-accent-cyan { border-right: 3px solid var(--tier-cyan); }

/* --- Top Accent Borders (for CLV columns) --- */
.border-top-titanium { border-top: 3px solid var(--tier-titanium); }
.border-top-gold { border-top: 3px solid var(--tier-gold); }
.border-top-silver { border-top: 3px solid var(--tier-silver); }

/* --- Border Radius --- */
.rounded-xs { border-radius: 4px;}
.rounded-sm { border-radius: 8px; }
.rounded { border-radius: 12px; }
.rounded-lg { border-radius: 16px; }
.rounded-xl { border-radius: 20px; }
.rounded-full { border-radius: 50%; }

/* ============================================================
   SECTION 8: WIDTH & HEIGHT UTILITIES
   ============================================================ */

.w-full { width: 100%; }
.w-auto { width: auto; }
.w-40 { width: 40px; }
.w-50 { width: 50px; }
.w-80 { width: 80px; }
.w-100 { width: 100px; }
.w-120 { width: 120px; }
.w-150 { width: 150px; }
.w-200 { width: 200px; }
.w-300 { width: 300px; }

.h-auto { height: auto; }
.h-40 { height: 40px; }
.h-42 { height: 42px; }
.h-full { height: 100%; }

.min-w-0 { min-width: 0; }
.max-w-full { max-width: 100%; }
.max-w-300 { max-width: 300px; }
.max-w-600 { max-width: 600px; }

.max-h-300 { max-height: 300px; }
.max-h-350 { max-height: 350px; }
.max-h-450 { max-height: 450px; }

/* ============================================================
   SECTION 9: DISPLAY & VISIBILITY
   ============================================================ */

.hidden { display: none !important; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }

.visible { visibility: visible; }
.invisible { visibility: hidden; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ============================================================
   SECTION 10: POSITIONING
   ============================================================ */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }
.z-100 { z-index: 100; }

/* ============================================================
   SECTION 11: SHADOWS & EFFECTS
   ============================================================ */

.shadow-none { box-shadow: none; }
.shadow-xs { box-shadow: var(--shadow-xs); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }
.opacity-100 { opacity: 1; }

/* ============================================================
   SECTION 12: CURSOR & INTERACTION
   ============================================================ */

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

.select-none { user-select: none; }

/* ============================================================
   SECTION 13: COMPONENT MODIFIERS
   ============================================================ */

/* --- Card Variants --- */
.card-flush { 
    padding: 0; 
}
.card-compact { 
    padding: var(--space-md); 
}
.card-align-top {
    justify-content: flex-start;
}

/* --- Button Size Modifiers --- */
.btn-xs {
    padding: 4px 10px;
    font-size: var(--font-xs);
    border-radius: 6px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: var(--font-sm);
}
.btn-lg {
    padding: 14px 30px;
    font-size: var(--font-lg);
}

/* --- Button Success (missing from original) --- */
.btn-success {
    background: var(--bg-success-light);
    color: var(--success);
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
}
.btn-success:hover {
    background: var(--success);
    color: var(--text-inverse);
}

/* --- Pill Variants (extend existing) --- */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: var(--font-sm);
    font-weight: 600;
}
.pill-primary {
    background: var(--primary-light);
    color: var(--primary);
}
.pill-cyan {
    background: rgba(8, 145, 178, 0.1);
    color: var(--tier-cyan);
}

[data-theme="dark"] .pill-success {
    background: #0c5a4b;
    color: #05CD99;
}
[data-theme="dark"] .pill-danger {
    background: #b73a3a;
    color: #ffaeae;
}
[data-theme="dark"] .pill-warning {
    background: #ffc055;
    color: #36332e; 
}

/* --- Icon Box (for stat cards) --- */
.icon-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.icon-box-primary {
    background: var(--primary-light);
    color: var(--primary);
}
.icon-box-success {
    background: var(--bg-success-light);
    color: var(--success);
}
.icon-box-warning {
    background: var(--bg-warning-light);
    color: var(--warning);
}
.icon-box-danger {
    background: var(--bg-danger-light);
    color: var(--danger);
}
.icon-box-muted {
    background: var(--bg-body);
    color: var(--text-secondary);
}

/* --- Stat Card Component --- */
.stat-card-item {
    background: var(--bg-body);
    padding: var(--space-sm);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    position: relative; 
    padding-bottom: var(--space-lg);
}
.stat-card-info-btn {
    position: absolute;
    left: var(--space-sm);
    bottom: var(--space-sm);
    font-size: 14px;
    color: var(--text-muted);
    cursor: help;
    transition: color 0.2s ease;
    z-index: 10;
}

.stat-card-info-btn:hover {
    color: var(--primary);
}
.stat-card-label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-card-value {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-main);
}

/* --- Section Icon (for section headers) --- */
.section-icon {
    color: var(--primary);
    margin-left: 8px;
}

/* --- Stage Item Variants --- */
.stage-item-accent {
    border-right-width: 3px;
    border-right-style: solid;
}

/* --- Table Cell Utilities --- */
.cell-center { text-align: center; }
.cell-right { text-align: right; }
.cell-nowrap { white-space: nowrap; }
.cell-truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   SECTION 14: THEME TOGGLE BUTTON
   ============================================================ */

.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: var(--bg-body);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.theme-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.theme-icon-dark,
.theme-icon-light {
    position: absolute;
    font-size: 16px;
    transition: opacity 0.2s, transform 0.3s;
}

/* Light theme: show moon, hide sun */
[data-theme="light"] .theme-icon-dark {
    opacity: 1;
    transform: rotate(0deg);
}

[data-theme="light"] .theme-icon-light {
    opacity: 0;
    transform: rotate(-90deg);
}

/* Dark theme: show sun, hide moon */
[data-theme="dark"] .theme-icon-dark {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .theme-icon-light {
    opacity: 1;
    transform: rotate(0deg);
}

/* ============================================================
   SECTION 15: ANIMATION UTILITIES
   ============================================================ */

.transition-all { transition: all 0.2s ease; }
.transition-colors { transition: color 0.2s, background-color 0.2s, border-color 0.2s; }
.transition-transform { transition: transform 0.2s ease; }

.hover-lift:hover { transform: translateY(-2px); }
.hover-scale:hover { transform: scale(1.02); }

/* --- Icon Rotation (for accordions) --- */
.rotate-0 { transform: rotate(0deg); }
.rotate-180 { transform: rotate(180deg); }

/* ============================================================
   SECTION 16: RESPONSIVE UTILITIES
   ============================================================ */

@media (max-width: 992px) {
    .tablet\:hidden { display: none !important; }
    .tablet\:flex-col { flex-direction: column; }
    .tablet\:w-full { width: 100%; }
    .tablet\:gap-md { gap: var(--space-md); }
}

@media (max-width: 768px) {
    .mobile\:hidden { display: none !important; }
    .mobile\:block { display: block !important; }
    .mobile\:flex-col { flex-direction: column; }
    .mobile\:w-full { width: 100%; }
    .mobile\:text-center { text-align: center; }
    .mobile\:gap-sm { gap: var(--space-sm); }
    .mobile\:p-sm { padding: var(--space-sm); }
}

/* ============================================================
   SECTION 17: DARK MODE COMPONENT OVERRIDES
   ============================================================ */

[data-theme="dark"] {
    /* Fix hardcoded whites in original CSS */
    .profile-pill,
    .dropdown-menu,
    .modal-box,
    .stage-item,
    .person-widget-item:hover,
    .accordion-button,
    .login-card {
        background-color: var(--bg-card);
    }
    
    .sidebar-logo {
        filter: brightness(0) invert(1);
        opacity: 0.6;
    }
    
    .accordion-item,
    .sales-main-row,
    .essence-row {
        background-color: var(--bg-card);
        border-color: var(--border-default);
    }
    
    .form-control:focus,
    .login-input:focus {
        background-color: var(--bg-card);
        border-color: var(--primary);
    }
    
    /* Table adjustments */
    tbody td {
        border-bottom-color: var(--border-light);
    }
    
    thead th {
        border-bottom-color: var(--border-default);
    }
    
    /* Modal backdrop */
    .modal-overlay {
        background: var(--bg-overlay);
    }
    
    /* Sales detail row */
    .sales-detail-wrapper {
        background-color: var(--bg-body);
    }
    
    .detail-table-inner {
        background-color: var(--bg-card);
        border-color: var(--border-default);
    }
    
    .detail-table-inner th {
        background-color: var(--primary);
    }
    
    /* Login page blobs */
    .blob-1, .blob-2 {
        opacity: 0.2;
    }
    
    /* Charts & SVG */
    .donut-segment {
        stroke: var(--bg-card);
    }
    
    /* Scrollbar */
    ::-webkit-scrollbar-thumb {
        background-color: var(--text-muted);
    }
    
    ::-webkit-scrollbar-track {
        background-color: var(--bg-body);
    }
}

/* ============================================================
   SECTION 18: REPORTS PAGE COMPONENTS
   ============================================================ */

/* --- Performance Metrics Grid --- */
.performance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 768px) {
    .performance-grid {
        grid-template-columns: 1fr;
    }
}

/* --- CLV Grid --- */
.clv-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

@media (max-width: 992px) {
    .clv-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Profitability Grid --- */
.profitability-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* --- Funnel Chart --- */
.funnel-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.funnel-label {
    width: 130px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.funnel-bar-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    font-weight: 700;
}

.funnel-bar {
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    color: var(--text-inverse);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    min-width: 30px;
}

.funnel-bar-empty {
    background: var(--bg-body);
    color: var(--text-muted);
    border: 1px dashed var(--text-muted);
}

.funnel-bar-segmented {
    height: 32px;
    border-radius: 8px;
    display: flex;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    min-width: 20px;
}

.funnel-segment-active {
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.funnel-segment-rejected {
    background: linear-gradient(90deg, #f87171, #ef4444);
    color: white;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.funnel-segment-abandoned {
    background: #94a3b8;
    color: white;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .funnel-row {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    .funnel-label {
        width: 100%;
        text-align: right;
        font-size: 12px;
        margin-bottom: 2px;
    }
}

/* --- Scrollable Columns --- */
.scrollable-column {
    overflow-y: auto;
    padding-right: 2px;
    flex-grow: 1;
}

.scrollable-column::-webkit-scrollbar { width: 4px; }
.scrollable-column::-webkit-scrollbar-track { background: transparent; }
.scrollable-column::-webkit-scrollbar-thumb { background-color: var(--text-muted); border-radius: 4px; }

/* --- Suggestions Dropdown (Reports) --- */
.suggestions-dropdown { 
    display: none; 
    position: absolute; 
    top: 100%; 
    left: 0; 
    right: 0; 
    background-color: var(--bg-card); 
    border: 1px solid var(--border-default); 
    border-radius: 0 0 12px 12px; 
    box-shadow: var(--shadow-md);
    z-index: 1000; 
    max-height: 200px; 
    overflow-y: auto; 
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    transition: background-color 0.15s ease;
}

.suggestion-item:hover {
    background-color: var(--bg-body);
    color: var(--primary);
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* --- Additional Width Utilities --- */
.min-w-170 { min-width: 170px; }
.min-w-180 { min-width: 180px; }
.min-w-220 { min-width: 220px; }
.min-w-250 { min-width: 250px; }
.max-h-260 { max-height: 260px; }

/* --- Text Cyan Color --- */
.text-cyan { color: var(--tier-cyan); }
.border-accent-cyan { border-right: 3px solid var(--tier-cyan); }


/* ============================================================
   GLOBAL TOOLBAR MOBILE LAYOUT (FINAL PERFECTED)
   Row 1: Search (Fill) + Buttons (Fixed)
   Row 2: Filters (Smart: Auto-Fill or Scroll)
   ============================================================ */

@media (max-width: 992px) {
    
    /* 1. کانتینر اصلی */
    .toolbar-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }

    /* 2. نوار جستجو (ردیف بالا - پرکننده) */
    .toolbar-search {
        order: 1 !important;
        flex-grow: 1 !important;
        flex-basis: 0 !important;
        min-width: 50% !important;
        width: auto !important;
        margin: 0 !important;
    }

    .toolbar-search input,
    #searchBox,
    #salesSearchInput {
        width: 100% !important;
        height: 42px !important;
        margin: 0 !important;
    }

    /* 3. دکمه‌های عملیات (ردیف بالا - ثابت) */
    .toolbar-actions {
        order: 2 !important;
        flex-shrink: 0 !important;
        width: auto !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .toolbar-actions button,
    .toolbar-actions a {
        height: 42px !important;
        width: 42px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 10px !important;
        margin: 0 !important;
    }
    
    .toolbar-actions i {
        font-size: 16px !important;
        margin: 0 !important;
    }

    /* 4. فیلترها (ردیف پایین - هوشمند) */
    .toolbar-filters {
        order: 3 !important;
        flex-basis: 100% !important;
        width: 100% !important;
        margin-top: 4px !important;
        
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        
        /* اسکرول افقی در صورت نیاز */
        overflow-x: auto !important;
        padding-bottom: 5px;
        
        /* حذف اسکرول بار */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .toolbar-filters::-webkit-scrollbar {
        display: none;
    }

    /* تنظیم هوشمند دراپ‌دان‌ها */
    .toolbar-filters select,
    .minimal-select,
    #periodFilter,
    #responsibleFilter, 
    #companyFilter {
        height: 40px !important;
        
        /* منطق هوشمند سایزدهی: */
        flex-grow: 1 !important;       /* 1. سعی کن کل فضای خالی را پر کنی */
        flex-shrink: 0 !important;     /* 2. اگر جا نبود، کوچک نشو (اسکرول بخور) */
        width: auto !important;        
        min-width: 130px !important;   /* 3. حداقل عرض هر فیلتر */
        
        margin: 0 !important;
    }
}


/* ============================================================
   SECTION 19: PROJECTS PAGE COMPONENTS
   ============================================================ */

/* --- Toolbar Container --- */
.toolbar-container {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 25px;
}

.toolbar-search {
    flex: 1;
    min-width: 200px;
}

.toolbar-search input {
    height: 45px;
}

.toolbar-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-right: 5px;
}

.toolbar-filters select,
.toolbar-actions .btn-icon {
    height: 2.45rem;
    display: flex;
    align-items: center;
    border-radius: 12px;
}

.toolbar-filters select, .form-group select {
    background-color: var(--bg-body);
    border: none;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    max-width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238F9BBA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 16px;
    background-position: left 12px center;
}

.toolbar-filters select {
    padding: 8px 12px 8px 35px; 
}

.form-group select, .form-group input {
    padding: 10px 15px;
    border: 1px solid transparent;
}

.minimal-select:hover, .minimal-select:focus, .form-group select:hover, .form-group select:focus { background: #E8EEF5; color: var(--primary); }

@media (max-width: 992px) {
    .toolbar-container { 
        flex-direction: column; 
        align-items: stretch; 
        gap: 12px;
    }
    .toolbar-search { width: 100%; order: 1; }
    .toolbar-filters { 
        width: 100%; 
        overflow-x: auto; 
        padding-bottom: 5px; 
        order: 2;
    }
    .toolbar-actions { 
        width: 100%; 
        justify-content: flex-end; 
        order: 3;
        margin-right: 0;
    }
}

/* --- Bulk Toolbar --- */
.bulk-toolbar {
    display: none; 
    align-items: center; 
    justify-content: space-between;
    margin-bottom: 15px; 
    background: var(--bg-body); 
    padding: 8px 15px; 
    border-radius: 12px; 
    border: 1px solid var(--border-default);
    animation: fadeIn 0.3s ease;
}

.bulk-divider {
    height: 20px;
    width: 1px;
    background: var(--border-default);
}

.btn-text {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 12px;
}

.btn-text:hover {
    color: var(--text-main);
}

/* --- Loading Indicator --- */
.loading-indicator {
    text-align: center;
    padding: 20px;
    color: var(--primary);
}

/* --- Modal Form Grid --- */
.modal-form-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .modal-form-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Essences Section --- */
.essences-section {
    background: var(--bg-body);
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 25px;
}

/* --- Essence Row --- */
.essence-row {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.essence-row:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.essence-row-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 2.5fr 2fr auto;
    gap: 15px;
    align-items: flex-start;
}

@media (max-width: 992px) {
    .essence-row-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 576px) {
    .essence-row-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Button Icon Square (for remove button) --- */
.btn-icon-square {
    padding: 12px;
    height: 44px;
    width: 44px;
    margin-top: 22px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}


.btn-icon-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-icon-mini:hover {
    color: var(--primary);
    background: var(--primary-light);
}




/* --- Multi-select Wrapper --- */
.multiselect-wrapper {
    background-color: var(--bg-body);
    border: 1px solid transparent; 
    border-radius: 12px;
    min-height: 42px; 
    padding: 4px 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    position: relative; 
    cursor: text;
    transition: all 0.2s ease;
    width: 100%;
}

.multiselect-wrapper:focus-within {
    background-color: var(--bg-card);
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.multiselect-input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 60px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    padding: 5px 0;
    height: 100%;
}

.multiselect-tag {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px 3px 10px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(24, 52, 83, 0.15);
}

.tag-remove-btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.2s;
}

.tag-remove-btn:hover {
    background: rgba(255,255,255,0.4);
}

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
}

.multiselect-dropdown .item {
    padding: 10px 15px;
    font-size: 12px;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-light);
}

.multiselect-dropdown .item:last-child {
    border-bottom: none;
}

.multiselect-dropdown .item:hover {
    background: var(--bg-body);
    color: var(--primary);
}

/* --- Additional Width Utilities --- */
.min-w-110 { min-width: 110px; }
.min-w-130 { min-width: 130px; }

/* --- Button Small --- */
.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

/* ============================================================
   SECTION 20: SALES REPORTS PAGE COMPONENTS
   ============================================================ */

/* --- Card Icon Variants --- */
.card-icon-primary {
    background: var(--bg-body);
    color: var(--primary);
}

.card-icon-success {
    background: var(--bg-success-light);
    color: var(--success);
}

.card-icon-warning {
    background: var(--bg-warning-light);
    color: var(--warning);
}

.card-icon-danger {
    background: var(--bg-danger-light);
    color: var(--danger);
}

/* --- Section Header Bordered --- */
.section-header-bordered {
    border-bottom: 1px solid var(--primary-light);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

/* --- Chart Legend Inline --- */
.chart-legend-inline {
    display: flex;
    gap: 15px;
    font-size: 11px;
    color: var(--text-secondary);
}

.legend-item-inline {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-box-filled {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-box-dashed {
    width: 10px;
    height: 2px;
    background: var(--text-muted);
    border-top: 2px dashed var(--text-muted);
}

/* --- Chart Container --- */
.chart-container-lg {
    position: relative;
    height: 300px;
    width: 100%;
}

/* --- Legend Box (Matrix) --- */
.legend-box {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-body);
    padding: 8px 15px;
    border-radius: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

[data-theme="dark"] .legend-item {
    background: #56345182;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.bg-muted {
    background-color: var(--text-muted);
}

/* --- Search Wrapper --- */
.search-wrapper {
    position: relative;
}

.search-wrapper .form-control {
    padding-left: 35px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
}

/* --- Matrix Table --- */
.matrix-wrapper {
    max-height: 200vh;
    overflow: auto;
    position: relative;
    border: 1px solid var(--bg-body);
    border-radius: 12px;
    background: var(--bg-card);
}

.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    font-size: 12px;
    color: var(--text-main);
}

.matrix-table th, 
.matrix-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
}

/* --- Matrix Headers --- */
.matrix-table thead {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-card);
}

.header-corner {
    background: var(--primary) !important;
    color: var(--text-inverse);
    z-index: 30 !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    border-right: 1px solid rgba(255,255,255,0.1) !important;
}

.group-header {
    background: var(--primary);
    color: var(--text-inverse);
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-right: 1px solid rgba(255,255,255,0.1);
}

.code-header {
    background: var(--primary);
    height: 100px;
    vertical-align: bottom;
    padding-bottom: 10px;
    position: relative;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.vertical-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    margin: 0 auto;
    font-size: 11px;
    color: var(--text-inverse);
    opacity: 0.9;
    font-weight: 500;
}

.header-total {
    background: var(--primary-light) !important;
    color: var(--primary);
    z-index: 30 !important;
    font-weight: 700;
}

/* --- Sticky Columns --- */
.sticky-col {
    position: sticky;
    z-index: 10;
    background: var(--bg-card);
}

.first-col {
    right: 0;
    border-left: 2px solid var(--primary-light) !important;
    border-right: none;
}

.last-col {
    left: 0;
    border-right: 2px solid var(--primary-light) !important;
}

/* --- Matrix Cells --- */
.company-cell {
    background: var(--bg-card);
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    min-width: 150px;
}

.company-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.value-cell {
    text-align: center;
    min-width: 45px;
    padding: 5px;
}

.value-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 11px;
}

.badge-success {
    background: var(--primary);
    color: var(--text-inverse);
}

.badge-warning {
    background: var(--warning);
    color: var(--text-inverse);
}

.badge-danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.badge-neutral {
    background: var(--text-muted);
    color: var(--text-inverse);
}

.empty-dash {
    color: var(--border-light);
    font-size: 14px;
}

.total-cell {
    background: var(--primary-light);
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

/* --- Footer Rows --- */
.footer-row td {
    font-weight: 600;
    background: var(--bg-body);
}

.total-row td {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.avg-row td {
    background: var(--bg-success-light);
    color: var(--success);
}

.footer-row .first-col {
    background: inherit;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 40px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* --- Min Width Utility --- */
.min-w-200 { min-width: 200px; }

/* --- Dark Mode Matrix Overrides --- */
[data-theme="dark"] .matrix-wrapper {
    background: var(--bg-card);
    border-color: var(--border-default);
}

[data-theme="dark"] .matrix-table th,
[data-theme="dark"] .matrix-table td {
    border-color: var(--border-light);
}

[data-theme="dark"] .matrix-table thead {
    background: var(--bg-card);
}

[data-theme="dark"] .sticky-col {
    background: var(--bg-card);
}

[data-theme="dark"] .company-cell {
    background: var(--bg-card);
}

[data-theme="dark"] .footer-row td {
    background: var(--bg-body);
}

[data-theme="dark"] .total-row td {
    background: var(--primary);
    color: var(--text-inverse);
}

[data-theme="dark"] .avg-row td {
    background: rgba(16, 185, 129, 0.2);
}

/* ============================================================
   SECTION 21: COMPANIES/PERSONS PAGE COMPONENTS
   ============================================================ */

/* --- Modal Form Grids --- */
.modal-form-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.modal-form-grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .modal-form-grid-2-1 {
        grid-template-columns: 1fr;
    }
}

/* --- Cell Truncate Variants --- */
.cell-truncate-200 {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-truncate-150 {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Multiselect Container (for modals) --- */
.multiselect-container {
    background-color: var(--bg-body);
    border: 1px solid transparent;
    border-radius: 12px;
    min-height: 42px;
    padding: 4px 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    position: relative;
    cursor: text;
    transition: all 0.2s ease;
}

.multiselect-container:focus-within {
    background-color: var(--bg-card);
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.multiselect-container input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 60px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    padding: 5px 0;
}

/* --- Tags --- */
.tag {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px 3px 10px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tag-remove {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.2s;
}

.tag-remove:hover {
    background: rgba(255,255,255,0.4);
}

/* --- Min Width Utilities --- */
.min-w-150 { min-width: 150px; }

/* ============================================================
   SECTION 22: PRINT UTILITIES (BONUS)
   ============================================================ */

@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ============================================================
   SECTION 23: PROJECT DETAILS
   ============================================================ */

/* --- Timeline Container --- */
.timeline-container {
    position: relative;
    padding: 40px 20px 20px;
    direction: rtl; 
    width: 100%;
}

/* --- Connecting Lines --- */
/* خط خاکستری پس‌زمینه */
.timeline-line-bg {
    position: absolute;
    top: 55px;      /* فاصله ثابت از بالا */
    right: 80px;    /* شروع دقیق از مرکز دایره اول */
    left: 80px;     /* پایان دقیق در مرکز دایره آخر */
    height: 4px;    /* ارتفاع ثابت */
    background: #E2E8F0; 
    z-index: 0;
    border-radius: 4px;
}

/* خط سبز (پیشرفت) - اصلاح شده */
.timeline-line-progress {
    position: absolute;
    top: 55px;      /* دقیقاً هم‌ارتفاع با خط طوسی */
    right: 80px;    /* دقیقاً هم‌شروع با خط طوسی */
    height: 4px;    /* ارتفاع ثابت */
    /* 
     * مهم: width باید نسبت به عرض خط خاکستری محاسبه شود
     * خط خاکستری = 100% - 160px (80px از هر طرف)
     * پس وقتی میخواهیم 50% پیشرفت داشته باشیم، باید 50% از (100% - 160px) باشد
     * فرمول: width = calc((100% - 160px) * X / 100) که X درصد پیشرفت است
     */
    background: var(--success);
    z-index: 1;
    border-radius: 4px;
    transition: width 0.4s ease-in-out;
    /* max-width برای جلوگیری از بیرون زدن */
    max-width: calc(100% - 160px);
}

/* --- Steps Wrapper --- */
.timeline-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 2;
    width: 100%;
}

/* --- Individual Step --- */
.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 120px; 
    cursor: pointer;
    transition: all 0.2s ease;
}

/* --- Node Circles --- */
.node-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #E2E8F0; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    transition: all 0.2s;
    position: relative;
    z-index: 5;
}

/* 1. Completed State */
.timeline-step.completed .node-circle {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

/* 2. Active State */
.timeline-step.active .node-circle {
    width: 40px;
    height: 40px;
    margin-top: -4px;
    margin-bottom: 4px;
    border: 3px solid var(--primary);
    color: var(--primary);
    background: #fff;
    font-size: 16px;
    box-shadow: 0 0 0 5px rgba(24, 52, 83, 0.1);
}

/* 3. Failed/Closed State */
.timeline-step.failed .node-circle {
    border-color: var(--danger);
    color: var(--danger);
    background: #FFF5F5;
}

/* --- Labels --- */
.node-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
    transition: color 0.2s;
    height: 20px;
}

.timeline-step.active .node-label {
    color: var(--primary);
    font-weight: 800;
}

/* --- Date Badges (کپسول تاریخ) --- */
.date-badge {
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 90px;
    height: 28px;
    position: relative;
    z-index: 10;
}

.timeline-step.completed .date-badge {
    background: #fff;
    border-color: var(--success);
    color: var(--success);
}

.timeline-step.active .date-badge {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* --- منطق نمایش اینپوت/متن (بسیار مهم) --- */

/* حالت پیش‌فرض: اینپوت مخفی، متن نمایان */
.step-date-input {
    display: none; 
}
.date-badge-text {
    display: block;
}

/* حالت ویرایش: وقتی کلاس editing به کانتینر اضافه شود */
.timeline-container.editing .date-badge-text {
    display: none;
}

.timeline-container.editing .step-date-input {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secendary);
    cursor: pointer;
    border-bottom: 1px dashed var(--primary); /* خط‌چین برای نشان دادن قابلیت ویرایش */
    padding-bottom: 2px;
    z-index: 50; /* باید بالاترین لایه باشد تا کلیک را دریافت کند */
    position: relative;
}

.timeline-container.editing .step-date-input:focus {
    outline: none;
    border-bottom-style: solid;
}

/* --- Tooltips (مسئول پروژه) --- */
.responsible-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 10px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.timeline-step.active .responsible-tooltip {
    opacity: 1;
    visibility: visible;
    top: -45px;
}

.responsible-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: var(--primary) transparent transparent transparent;
}

/* ============================================================
   FIX: TIMELINE MOBILE SCROLL
   ============================================================ */

/* تنظیمات اسکرول فقط برای موبایل و تبلت */
@media (max-width: 992px) {
    
    /* کانتینر اسکرول: اجازه می‌دهد محتوا اسکرول شود */
    .timeline-scroll-wrapper {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 15px; /* فضا برای نمایش اسکرول‌بار */
        -webkit-overflow-scrolling: touch; /* اسکرول نرم در iOS */
        cursor: grab;
    }

    /* کانتینر اصلی: عرض ثابت می‌گیرد تا خطوط و دایره‌ها جمع نشوند */
    .timeline-container {
        min-width: 1000px; /* عرض کافی برای جایگیری تمام مراحل */
        padding-right: 0;
        padding-left: 0;
        margin: 0 auto;
    }

    /* اصلاح خط‌های اتصال در حالت اسکرول */
    .timeline-line-bg,
    .timeline-line-progress {
        /* در حالت دسکتاپ left/right: 80px بود */
        /* در اینجا چون عرض ثابت دادیم، باید مطمئن شویم خطوط کشیده می‌شوند */
        left: 80px;
        right: 80px;
        width: auto; 
    }
    
    /* مخفی کردن متن "تاریخ" در حالت عادی موبایل برای خلوت شدن */
    .date-badge-text {
        font-size: 10px;
    }
    
    /* استایل اسکرول بار برای زیبایی بیشتر */
    .timeline-scroll-wrapper::-webkit-scrollbar {
        height: 4px;
    }
    .timeline-scroll-wrapper::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    .timeline-scroll-wrapper::-webkit-scrollbar-thumb {
        background: var(--primary-light);
        border-radius: 4px;
    }
    .timeline-scroll-wrapper::-webkit-scrollbar-thumb:hover {
        background: var(--primary);
    }
    .btn-action {
    justify-content: left;
}

/* 1. مخفی کردن متن داخل اسپن */
    .mobile-hidden-text {
        display: none;
    }

    /* 2. مربعی کردن دکمه‌ها در هدر (چون متن حذف شد) */
    .detail-header .btn-danger,
    .detail-header .btn-secondary,
    .detail-header .btn-primary,
    .detail-header .btn-success {
        padding: 0;           /* حذف پدینگ اضافی */
        width: 40px;          /* عرض ثابت */
        height: 40px;         /* ارتفاع ثابت */
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;  /* گردی گوشه */
    }
    
    /* تنظیم اندازه آیکون‌ها */
    .detail-header .btn-danger i,
    .detail-header .btn-secondary i {
        margin: 0 !important; /* حذف فاصله احتمالی آیکون */
        font-size: 16px;
    }
    
    /* چیدمان دکمه‌ها در یک خط */
    .detail-header .flex.gap-sm {
        gap: 8px; /* فاصله بین دو دکمه */
        width: 8rem;
    }
}

/* ==============================================
   Funnel Conversion Rates - نرخ تبدیل قیف فروش
   ============================================== */

/* کانتینر قیف با ستون نرخ‌ها */
.funnel-with-rates {
    display: flex;
    position: relative;
}

/* ستون نوارهای قیف */
.funnel-bars {
    flex: 1;
    padding-left: 1rem;
}

/* ستون خطوط نرخ تبدیل */
.funnel-rates-column {
    width: 50px;
    position: relative;
    margin-left: 10px;
}

/* خط عمودی هاشوردار */
.rate-line-vertical {
    position: absolute;
    width: 0;
    border-left: 1.5px dashed;
    opacity: 0.6;
}

/* رنگ خطوط */
.rate-line-lead {
    border-color: var(--primary);
}

.rate-line-win {
    border-color: var(--success);
}

.rate-line-repeat {
    border-color: var(--text-main);
}

.rate-line-grow {
    border-color: var(--warning);
}

/* نقاط اتصال بالا و پایین خط (دایره‌ها) */
.rate-line-vertical::before,
.rate-line-vertical::after {
    content: '';
    position: absolute;
    right: -3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.rate-line-vertical::before { 
    top: -2px; 
}

.rate-line-vertical::after { 
    bottom: -2px; 
}

/* رنگ دایره‌های گره‌ها */
.rate-line-lead::before,
.rate-line-lead::after {
    background: var(--primary);
}

.rate-line-win::before,
.rate-line-win::after {
    background: var(--success);
}

/* ★ دایره‌های گره‌های تکرار فروش و رشد ★ */
.rate-line-repeat::before,
.rate-line-repeat::after {
    background: var(--text-main);
}

.rate-line-grow::before,
.rate-line-grow::after {
    background: var(--warning);
}

/* بج درصد نرخ تبدیل */
.rate-percent-badge {
    position: absolute;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: -0.3px;
}

.rate-percent-lead {
    color: var(--primary);
}

.rate-percent-win {
    color: var(--success);
}

.rate-percent-repeat {
    color: var(--text-main);
}

.rate-percent-grow {
    color: var(--warning);
}

*==============================================
   Heatmap - هیت‌مپ فصلی فروش
   اضافه کنید به style-utilities.css
============================================== */

/* Wrapper */
.heatmap-wrapper {
    min-height: 200px;
    overflow-x: auto;
}

/* راهنمای رنگ گرادیانی - قدیمی */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.legend-gradient {
    width: 100px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to left, var(--primary), transparent);
}

.legend-label {
    font-weight: 500;
}

/* راهنمای رنگ جدید - سطوح */
.heatmap-color-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.heatmap-color-legend .legend-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.legend-item-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #1565C0;
}

.legend-item-box:nth-child(5),
.legend-item-box:nth-child(6) {
    color: #fff;
}

/* گرید هیت‌مپ */
.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

/* هدر */
.heatmap-header {
    display: flex;
    gap: 2px;
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-bg);
    padding-bottom: 4px;
}

.heatmap-corner-name {
    width: 80px;
    min-width: 80px;
    flex-shrink: 0;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}

.heatmap-corner-code {
    width: 70px;
    min-width: 70px;
    flex-shrink: 0;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}

.heatmap-month {
    flex: 1;
    min-width: 55px;
    padding: 6px 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* بدنه هیت‌مپ */
.heatmap-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 500px;
    overflow-y: auto;
}

/* ردیف */
.heatmap-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* ستون نام اسانس */
.heatmap-name {
    width: 80px;
    min-width: 80px;
    flex-shrink: 0;
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-main);
    background: var(--bg-secondary);
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

/* ستون کد */
.heatmap-code {
    width: 70px;
    min-width: 70px;
    flex-shrink: 0;
    padding: 6px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 4px;
    white-space: nowrap;
    text-align: right;
}

/* سلول هیت‌مپ - با اعداد */
.heatmap-cell {
    flex: 1;
    min-width: 55px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 2;
    position: relative;
}

/* سلول پیک فروش */
.heatmap-cell.is-peak {
    box-shadow: inset 0 0 0 2px #F59E0B;
    font-weight: 700;
}

/* سطوح رنگی */
.heatmap-cell.level-0 {
    background: transparent;
    color: var(--text-muted);
}

.heatmap-cell.level-1 {
    background: #E3F2FD;
    color: #1565C0;
}

.heatmap-cell.level-2 {
    background: #90CAF9;
    color: #0D47A1;
}

.heatmap-cell.level-3 {
    background: #42A5F5;
    color: #fff;
}

.heatmap-cell.level-4 {
    background: #1E88E5;
    color: #fff;
}

.heatmap-cell.level-5 {
    background: #0D47A1;
    color: #fff;
}

/* Empty state */
.empty-state-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    color: var(--text-muted);
    font-size: 13px;
}

.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Dark Mode */
[data-theme="dark"] .heatmap-cell.level-1 {
    background: rgba(66, 165, 245, 0.15);
    color: #90CAF9;
}

[data-theme="dark"] .heatmap-cell.level-2 {
    background: rgba(66, 165, 245, 0.3);
    color: #90CAF9;
}

[data-theme="dark"] .heatmap-cell.level-3 {
    background: rgba(66, 165, 245, 0.5);
    color: #fff;
}

[data-theme="dark"] .heatmap-cell.level-4 {
    background: rgba(66, 165, 245, 0.7);
    color: #fff;
}

[data-theme="dark"] .heatmap-cell.level-5 {
    background: #42A5F5;
    color: #fff;
}

[data-theme="dark"] .legend-item-box {
    color: #90CAF9;
}

[data-theme="dark"] .legend-item-box:nth-child(5),
[data-theme="dark"] .legend-item-box:nth-child(6) {
    color: #fff;
}


/* ============================================================
   END OF UTILITY CLASSES
   ============================================================ */ 