/* ========================================
   فروش‌نگار Pro - Dashboard Styles
   Modern, Premium, RTL, Glassmorphism
   ======================================== */

:root {
    /* Light Theme Colors */
    --primary: #3B82F6;
    --primary-dark: #1E40AF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --text: #0F172A;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    --shadow: 0 10px 15px -3px rgb(15 23 42 / 0.1), 0 4px 6px -4px rgb(15 23 42 / 0.1);
    --shadow-soft: 0 4px 6px -1px rgb(15 23 42 / 0.07), 0 2px 4px -2px rgb(15 23 42 / 0.07);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.6);
    
    /* Spacing */
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #60A5FA;
    --primary-dark: #3B82F6;
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-2: #334155;
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --border: #475569;
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-soft: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --glass-bg: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(71, 85, 105, 0.6);
}

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

body {
    font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    font-size: 15px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout */
.main-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-right: 280px;
    transition: margin-right 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
}

.sidebar.collapsed {
    width: 78px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo svg {
    flex-shrink: 0;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.logo-sub {
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 0 6px;
}

.sidebar-toggle {
    width: 34px;
    height: 34px;
    border: none;
    background: var(--surface-2);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-nav {
    padding: 12px 14px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    margin: 4px 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--primary), #2563EB);
    color: white;
    box-shadow: 0 4px 14px rgb(59 130 246 / 0.3);
}

.nav-item.active svg {
    color: white;
}

.nav-item svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.nav-item:hover svg {
    transform: scale(1.1);
}

.sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 13px 12px;
}

/* Header */
.header {
    height: 78px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breadcrumb {
    font-weight: 600;
    font-size: 17px;
    color: var(--text);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
}

.header-center {
    flex: 1;
    max-width: 440px;
    margin: 0 24px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 0 18px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.search-box:focus-within {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 12px 12px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
}

.search-box svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

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

.icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}

.profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 6px 18px;
    background: var(--surface-2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.profile:hover {
    box-shadow: var(--shadow-soft);
}

.profile-name {
    font-weight: 600;
    font-size: 14.5px;
}

.profile-role {
    font-size: 12.5px;
    color: var(--text-secondary);
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-soft);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content */
.content {
    padding: 28px;
    flex: 1;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 26px;
}

.section-header h1 {
    font-size: 27px;
    font-weight: 700;
    color: var(--text);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 2px;
}

.section-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 14px rgb(59 130 246 / 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgb(59 130 246 / 0.35);
}

.btn-sm {
    padding: 7px 16px;
    font-size: 13px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: flex-start;
    gap: 18px;
    position: relative;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: linear-gradient(135deg, #3B82F6, #2563EB); color: white; }
.stat-icon.green { background: linear-gradient(135deg, #10B981, #059669); color: white; }
.stat-icon.purple { background: linear-gradient(135deg, #8B5CF6, #6D28D9); color: white; }
.stat-icon.orange { background: linear-gradient(135deg, #F59E0B, #D97706); color: white; }
.stat-icon.teal { background: linear-gradient(135deg, #14B8A6, #0D9488); color: white; }
.stat-icon.pink { background: linear-gradient(135deg, #EC4899, #DB2777); color: white; }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 3px;
}

.stat-label {
    font-size: 13.5px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-change {
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

.stat-chart {
    width: 76px;
    height: 42px;
    position: absolute;
    bottom: 18px;
    left: 22px;
    opacity: 0.75;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1100px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.chart-header p {
    color: var(--text-secondary);
    font-size: 13.5px;
}

.chart-container {
    position: relative;
    height: 260px;
}

.pie-container {
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Table */
.table-wrapper {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

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

.data-table th {
    background: var(--surface-2);
    padding: 16px 20px;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: var(--surface);
}

.data-table td {
    padding: 17px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.data-table tr:hover {
    background: var(--surface-2);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 13px;
    border-radius: 50px;
    font-size: 12.5px;
    font-weight: 600;
}

.status-badge.success { background: #D1FAE5; color: #065F46; }
.status-badge.warning { background: #FEF3C7; color: #92400E; }
.status-badge.danger { background: #FEE2E2; color: #991B1B; }
.status-badge.info { background: #DBEAFE; color: #1E40AF; }

[data-theme="dark"] .status-badge.success { background: #064E3B; color: #6EE7B7; }
[data-theme="dark"] .status-badge.warning { background: #78350F; color: #FCD34D; }
[data-theme="dark"] .status-badge.danger { background: #7F1D1D; color: #FCA5A5; }

/* Stock indicators */
.stock {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}

.stock.good { color: var(--success); background: #D1FAE5; }
.stock.low { color: var(--warning); background: #FEF3C7; }

/* Table Controls */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 16px;
    flex-wrap: wrap;
}

.search-filter {
    flex: 1;
    max-width: 360px;
}

.search-box.small {
    padding: 0 14px;
}

.search-box.small input {
    padding: 10px 10px 10px 10px;
    font-size: 14px;
}

.filters select {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    outline: none;
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 26px;
}

.pagination button {
    padding: 8px 15px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.pagination button.active,
.pagination button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.product-image {
    width: 100%;
    height: 165px;
    background: var(--surface-2);
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.product-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 17px;
}

.product-stock {
    font-size: 13px;
    font-weight: 500;
}

/* Reports */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.report-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.report-card:hover {
    transform: translateY(-4px);
}

.report-icon {
    width: 54px;
    height: 54px;
    background: var(--surface-2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    color: var(--primary);
}

.report-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.report-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.report-actions {
    display: flex;
    gap: 8px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes modalPop {
    from { transform: scale(0.8) translateY(30px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    padding: 22px 26px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 19px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 26px;
}

.modal-footer {
    padding: 18px 26px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Form Elements */
.input {
    width: 100%;
    padding: 13px 17px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    margin-bottom: 16px;
    font-family: inherit;
    transition: var(--transition);
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 300px;
    max-width: 380px;
    animation: toastSlide 0.3s ease forwards;
    border-left: 5px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }

@keyframes toastSlide {
    from { transform: translateX(-30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Messages & Notifications */
.messages-list, .notifications-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-item, .notification-item {
    display: flex;
    gap: 16px;
    background: var(--surface);
    padding: 18px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.msg-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.msg-content {
    flex: 1;
}

.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.msg-header strong {
    font-weight: 700;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
}

.settings-card {
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.setting-item {
    margin-bottom: 18px;
}

.setting-item label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 68px;
    height: 68px;
    margin-bottom: 20px;
    opacity: 0.6;
}

/* ========================================
   RESPONSIVE IMPROVEMENTS
   ======================================== */

/* Large Desktop */
@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    }
}

/* Desktop & Large Tablet */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .header-center {
        max-width: 320px;
    }
}

/* Tablet */
@media (max-width: 992px) {
    .main-container {
        margin-right: 0;
    }
    
    .sidebar {
        transform: translateX(100%);
        width: 280px;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .header {
        padding: 0 20px;
    }
    
    .content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Small Tablet & Large Mobile */
@media (max-width: 768px) {
    .header {
        height: 68px;
        padding: 0 16px;
    }
    
    .header-center {
        max-width: 100%;
        margin: 0 12px;
    }
    
    .search-box {
        padding: 0 14px;
    }
    
    .search-box input {
        font-size: 14px;
        padding: 10px 10px 10px 12px;
    }
    
    .content {
        padding: 16px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }
    
    .section-header h1 {
        font-size: 22px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .stat-card {
        padding: 18px 16px;
    }
    
    .stat-value {
        font-size: 23px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
        gap: 14px;
    }
    
    .product-card {
        padding: 14px;
    }
    
    .product-image {
        height: 140px;
    }
    
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 720px;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .search-filter {
        max-width: 100%;
    }
    
    .filters {
        width: 100%;
    }
    
    .filters select {
        width: 100%;
    }
    
    .chart-container {
        height: 220px;
    }
    
    .pie-container {
        height: 200px;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 8px;
    }
    
    .profile {
        padding: 5px 8px 5px 12px;
    }
    
    .profile-info {
        display: none;
    }
    
    .profile-avatar {
        width: 32px;
        height: 32px;
    }
    
    .icon-btn {
        width: 38px;
        height: 38px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .header {
        padding: 0 12px;
    }
    
    .content {
        padding: 12px;
    }
    
    .stats-grid {
        gap: 12px;
    }
    
    .stat-card {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .stat-chart {
        position: static;
        width: 100%;
        height: 36px;
        margin-top: 8px;
    }
    
    .section-header h1 {
        font-size: 20px;
    }
    
    .btn {
        padding: 9px 16px;
        font-size: 13.5px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-body {
        padding: 18px;
    }
    
    .reports-grid {
        grid-template-columns: 1fr;
    }
    
    .report-card {
        padding: 20px;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        min-width: 640px;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* Extra Small Mobile */
@media (max-width: 400px) {
    .header-right {
        gap: 4px;
    }
    
    .icon-btn {
        width: 34px;
        height: 34px;
    }
    
    .badge {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
    
    .stat-value {
        font-size: 21px;
    }
}

/* Micro interactions & Polish */
.nav-item, .btn, .stat-card, .product-card, .report-card {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:active, .btn:active {
    transform: scale(0.97);
}

/* Custom Scrollbar */
.sidebar-nav::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Accessibility */
.icon-btn:focus,
.btn:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 32px;
    left: 32px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgb(59 130 246 / 0.4);
    z-index: 1100;
    cursor: pointer;
    transition: var(--transition);
}

.fab:hover {
    transform: scale(1.1);
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Glassmorphism accent */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}
/* ========================================
   SIDEBAR & RESPONSIVE LAYOUT — FINAL FIXES
   ======================================== */
html, body { min-width: 0; overflow-x: hidden; }
.main-container { min-width: 0; width: auto; }
.content, .header, .header-left, .header-center, .header-right { min-width: 0; }

/* Keep the content aligned with the actual sidebar width on desktop. */
.sidebar.collapsed ~ .main-container { margin-right: 78px; }
.sidebar.collapsed .sidebar-header { padding: 22px; justify-content: center; }
.sidebar.collapsed .logo > div { display: none; }
.sidebar.collapsed .logo { display: none; }
.sidebar.collapsed .sidebar-toggle { flex: 0 0 34px; }
.sidebar.collapsed .sidebar-nav { padding: 12px 10px; }
.sidebar.collapsed .nav-item { padding-inline: 0; }
.sidebar.collapsed .nav-item svg { width: 22px; height: 22px; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgb(15 23 42 / .48);
    opacity: 0;
    transition: opacity .3s ease;
    -webkit-tap-highlight-color: transparent;
}

/* Sidebar becomes an accessible off-canvas drawer on tablet and mobile. */
@media (max-width: 992px) {
    .main-container,
    .sidebar.collapsed ~ .main-container { margin-right: 0; }

    .sidebar,
    .sidebar.collapsed {
        width: min(86vw, 320px);
        max-width: 320px;
        transform: translateX(calc(100% + 16px));
        transition: transform .3s cubic-bezier(.4, 0, .2, 1);
        overflow: hidden;
    }

    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.mobile-open + .sidebar-backdrop {
        display: block;
        opacity: 1;
    }

    .sidebar.collapsed .sidebar-header { padding: 24px 22px; justify-content: space-between; }
    .sidebar.collapsed .logo { display: flex; }
    .sidebar.collapsed .logo > div { display: block; }
    .sidebar.collapsed .sidebar-nav { padding: 12px 14px; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 13px 18px; }
    .sidebar.collapsed .nav-item span { display: inline; }
    .sidebar.collapsed .nav-item svg { width: 20px; height: 20px; }

    body.sidebar-open { overflow: hidden; touch-action: none; }
    .mobile-menu-btn { width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
    .mobile-menu-btn:hover { background: var(--surface-2); }
}

@media (max-width: 680px) {
    .header { gap: 8px; }
    .header-left { flex: 0 1 auto; gap: 4px; }
    .breadcrumb { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .header-center { display: none; }
    .header-right { margin-right: auto; gap: 6px; }
    .section-actions { width: 100%; }
    .section-actions .btn { width: 100%; justify-content: center; }
    .chart-card { padding: 16px; }
    .settings-grid { grid-template-columns: minmax(0, 1fr); }
    .settings-card { padding: 20px 16px; }
    .toast-container { right: 12px; left: 12px; bottom: 12px; }
    .toast { min-width: 0; max-width: none; width: 100%; }
}

@media (max-width: 430px) {
    .header { height: 62px; padding: 0 8px; }
    .mobile-menu-btn { width: 38px; height: 38px; }
    .breadcrumb { max-width: 74px; font-size: 14px; }
    .header-right { gap: 3px; }
    .icon-btn { width: 36px; height: 36px; }
    .profile { display: none; }
    .badge { top: 3px; left: 3px; }
    .sidebar, .sidebar.collapsed { width: min(90vw, 320px); }
    .modal { padding: 10px; }
    .modal-header, .modal-footer { padding: 16px; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
