/* ============================================ */
/* فایل: استایل‌های مشترک و پایه */
/* ============================================ */

/* ============================================ */
/* بخش ۱: تعریف فونت (۶ وزن مختلف) */
/* ============================================ */

@font-face {
    font-family: 'IRANSansWeb';
    src: url("fonts/IRANSansWeb.eb5adaac0d81.woff2") format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSansWeb';
    src: url("fonts/IRANSansWeb_Black.24f304ff5075.woff2") format('woff2');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSansWeb';
    src: url("fonts/IRANSansWeb_Bold.ceaf6d89af9f.woff2") format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSansWeb';
    src: url("fonts/IRANSansWeb_Light.3f707510b310.woff2") format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSansWeb';
    src: url("fonts/IRANSansWeb_Medium.62528a12d06f.woff2") format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSansWeb';
    src: url("fonts/IRANSansWeb_UltraLight.6e57754a4baf.woff2") format('woff2');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

/* ============================================ */
/* بخش ۲: ریست و تنظیمات پایه */
/* ============================================ */

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

html {
    font-size: 14px;
    direction: rtl;
}

body {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
    line-height: 1.5;
    transition: all 0.3s ease;
    overflow-x: hidden;
}

/* ============================================ */
/* بخش ۳: متغیرهای پیش‌فرض CSS */
/* ============================================ */

:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* ============================================ */
/* بخش ۴: اسکرول بار سفارشی */
/* ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track, #e9ecef);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #c9a03d);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover, #a8862e);
}

/* ============================================ */
/* بخش ۵: ساختار اصلی (سایدبار + محتوا) */
/* ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ============================================ */
/* بخش ۶: استایل سایدبار */
/* ============================================ */

.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    background: inherit;
}

/* حالت جمع شده سایدبار (دسکتاپ) */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .menu-item span,
.sidebar.collapsed .menu-group-title {
    display: none;
}

.sidebar.collapsed .logo-text {
    display: none;
}

.sidebar.collapsed .logo {
    justify-content: center;
    padding: 20px 0;
}

/* ============================================ */
/* بخش ۷: لوگو */
/* ============================================ */

.logo {
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border-radius: 12px;
}

.logo-text {
    font-size: 20px;
    font-weight: bold;
}

/* ============================================ */
/* بخش ۸: منوی گروه‌بندی شده */
/* ============================================ */

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

.menu-group-title {
    padding: 12px 20px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    opacity: 0.7;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    transition: var(--transition);
    border-right: 3px solid transparent;
}

.menu-item i {
    width: 20px;
    font-size: 18px;
}

.menu-item span {
    font-size: 14px;
}

.menu-item:hover {
    border-right-color: var(--primary-color);
}

.menu-item.active {
    border-right-color: var(--primary-color);
}

/* ============================================ */
/* بخش ۹: محتوای اصلی */
/* ============================================ */

.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    transition: margin-right 0.3s ease, width 0.3s ease;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
}

.sidebar.collapsed + .main-content {
    margin-right: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* ============================================ */
/* بخش ۱۰: هدر بالایی */
/* ============================================ */

.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 999;
    background: inherit;
}

.sidebar-toggle {
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--hover-bg);
}

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

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box input {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    width: 250px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
}

/* ============================================ */
/* بخش ۱۱: نوتیفیکیشن و پروفایل */
/* ============================================ */

.notifications-btn {
    position: relative;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: var(--transition);
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notifications-dropdown,
.user-dropdown-menu {
    position: absolute;
    top: 60px;
    left: 20px;
    width: 300px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: none;
    z-index: 1000;
}

.notifications-dropdown.show,
.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 30px;
    transition: var(--transition);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* ============================================ */
/* بخش ۱۲: کارت‌های آماری */
/* ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    padding: 24px;
}

.stat-card {
    padding: 20px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-info h3 {
    font-size: 28px;
    font-weight: bold;
}

.stat-info p {
    font-size: 14px;
    opacity: 0.7;
}

.stat-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 24px;
}

/* ============================================ */
/* بخش ۱۳: جداول داده */
/* ============================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    font-weight: 600;
}

/* جدول واکنش‌گرا با اسکرول افقی */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================ */
/* بخش ۱۴: دکمه‌ها */
/* ============================================ */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

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

/* ============================================ */
/* بخش ۱۵: سوئیچر استایل (انتخاب بین ۵ استایل) */
/* ============================================ */

.style-switcher {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1001;
}

.style-switcher-toggler {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: white;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    transition: var(--transition);
}

.style-switcher-toggler:hover {
    transform: scale(1.1);
}

.style-switcher-menu {
    position: absolute;
    bottom: 60px;
    left: 0;
    border-radius: 12px;
    padding: 15px;
    width: 200px;
    display: none;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}

.style-switcher-menu.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.style-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.style-option:hover {
    background: var(--hover-bg);
}

.style-preview {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.style-preview-1 { background: linear-gradient(135deg, #1a2a3a, #c9a03d); }
.style-preview-2 { background: linear-gradient(135deg, #2c3e50, #95a5a6); }
.style-preview-3 { background: linear-gradient(135deg, #667eea, #764ba2); }
.style-preview-4 { background: linear-gradient(135deg, #0a0a0a, #d4af37); }
.style-preview-5 { background: linear-gradient(135deg, #f8c9d4, #c9e9c0); }

/* ============================================ */
/* بخش ۱۶: سوئیچر پک (انتقال بین ۵ پک مختلف) */
/* ============================================ */

.pack-switcher {
    position: fixed;
    left: 20px;
    bottom: 90px;
    z-index: 1001;
}

.pack-switcher-toggler {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: white;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    transition: var(--transition);
}

.pack-switcher-toggler:hover {
    transform: scale(1.1);
}

.pack-switcher-menu {
    position: absolute;
    bottom: 60px;
    left: 0;
    border-radius: 12px;
    padding: 15px;
    width: 220px;
    display: none;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}

.pack-switcher-menu.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.pack-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.pack-option:hover {
    background: var(--hover-bg);
}

/* ============================================ */
/* بخش ۱۷: انیمیشن‌ها */
/* ============================================ */

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

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

/* ============================================ */
/* بخش ۱۸: کلاس‌های کمکی */
/* ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hide-on-mobile { display: flex; }
.show-on-mobile { display: none; }

/* ============================================ */
/* بخش ۱۹: پاسخگویی کامل موبایل و تبلت */
/* ============================================ */

/* تبلت و صفحه‌های متوسط (992px به پایین) */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 260px;
    }
    
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }
    
    .sidebar .menu-item span,
    .sidebar .menu-group-title,
    .sidebar .logo-text {
        display: none;
    }
    
    .main-content {
        margin-right: var(--sidebar-collapsed-width);
        width: calc(100% - var(--sidebar-collapsed-width));
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
        padding: 20px;
    }
    
    .search-box input {
        width: 180px;
    }
}

/* موبایل (768px به پایین) */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --border-radius: 10px;
    }
    
    html {
        font-size: 13px;
    }
    
    /* سایدبار در موبایل - پنهان و از راست بیرون می‌آید */
    .sidebar {
        transform: translateX(100%);
        position: fixed;
        width: 280px;
        box-shadow: none;
        transition: transform 0.3s ease;
        z-index: 1002;
    }
    
    .sidebar .menu-item span,
    .sidebar .menu-group-title,
    .sidebar .logo-text {
        display: block;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: -5px 0 20px rgba(0,0,0,0.2);
    }
    
    .main-content {
        margin-right: 0;
        width: 100%;
    }
    
    /* هدر موبایل */
    .header {
        padding: 0 16px;
        height: 60px;
    }
    
    .sidebar-toggle {
        display: flex;
    }
    
    .header-left {
        gap: 12px;
    }
    
    .search-box input {
        width: 140px;
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .user-dropdown-btn span {
        display: none;
    }
    
    .user-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    /* کارت‌های آماری */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-info h3 {
        font-size: 24px;
    }
    
    /* جداول */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    /* فرم‌ها */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .form-control {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    /* دکمه‌ها */
    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* هدر صفحات */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
        gap: 12px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    /* تب‌ها */
    .tabs {
        flex-wrap: wrap;
        gap: 5px;
        margin: 0 16px 16px 16px;
    }
    
    .tab {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    /* مودال */
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }
    
    .modal-header h3 {
        font-size: 18px;
    }
    
    /* پنل‌ها و کارت‌ها */
    .category-card,
    .product-card,
    .ticket-card,
    .faq-item {
        padding: 15px;
    }
    
    /* سوئیچرها در موبایل */
    .style-switcher,
    .pack-switcher {
        transform: scale(0.9);
        transform-origin: bottom left;
    }
    
    .style-switcher-toggler,
    .pack-switcher-toggler {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    
    /* کلاس‌های کمکی موبایل */
    .hide-on-mobile {
        display: none;
    }
    
    .show-on-mobile {
        display: flex;
    }
    
    /* فوتر صفحات */
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* موبایل کوچک (480px به پایین) */
@media (max-width: 480px) {
    html {
        font-size: 12px;
    }
    
    .header {
        padding: 0 12px;
    }
    
    .header-left {
        gap: 8px;
    }
    
    .search-box input {
        width: 100px;
    }
    
    .search-box i {
        font-size: 14px;
    }
    
    .notifications-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .notification-badge {
        width: 16px;
        height: 16px;
        font-size: 9px;
        top: -5px;
        right: -5px;
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .page-title {
        font-size: 18px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-info h3 {
        font-size: 20px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .category-icon {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
    
    .category-name {
        font-size: 16px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .style-switcher-menu,
    .pack-switcher-menu {
        width: 180px;
        padding: 12px;
    }
    
    .notifications-dropdown,
    .user-dropdown-menu {
        width: 280px;
        left: 10px;
        right: auto;
    }
}

/* صفحه‌های بسیار بزرگ (1400px به بالا) */
@media (min-width: 1400px) {
    html {
        font-size: 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 24px;
    }
    
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
}

/* ============================================ */
/* بخش ۲۰: کلاس‌های رفع مشکل موبایل */
/* ============================================ */

/* منوی همبرگری برای موبایل - در پشت سایدبار */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.mobile-menu-overlay.show {
    display: block;
    opacity: 1;
}

/* سایدبار در موبایل بالای overlay قرار می‌گیرد */
@media (max-width: 768px) {
    .sidebar {
        z-index: 1000;
    }
}

/* جلوگیری از اسکرول body وقتی منو باز است */
body.menu-open {
    overflow: hidden;
}

/* جلوگیری از اسکرول body وقتی مودال باز است */
body.modal-open {
    overflow: hidden;
}

/* بهبود تاچ برای موبایل */
@media (max-width: 768px) {
    button,
    .menu-item,
    .category-card,
    .faq-question,
    .article-item,
    .btn {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    button:active,
    .menu-item:active,
    .category-card:active,
    .btn:active {
        transform: scale(0.98);
    }
    
    /* افزایش فضای قابل کلیک برای آیتم‌های منو */
    .menu-item {
        padding: 14px 20px;
    }
    
    .sidebar-toggle {
        width: 44px;
        height: 44px;
    }
}

/* بهبود نمایش فونت در موبایل */
@media (max-width: 768px) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ============================================ */
/* بخش ۲۱: رفع مشکل همپوشانی در موبایل */
/* ============================================ */

@media (max-width: 768px) {
    /* اطمینان از اینکه محتوا زیر هدر نمی‌رود */
    .main-content {
        padding-top: 0;
    }
    
    /* بهبود نمایش کارت‌ها */
    .category-card,
    .product-card {
        width: 100%;
    }
    
    /* بهبود نمایش فرم‌ها */
    input, select, textarea {
        font-size: 16px !important; /* جلوگیری از زوم خودکار در iOS */
    }
    
    /* بهبود نمایش مودال */
    .modal {
        align-items: flex-end;
    }
    
    .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
    }
}

/* ============================================ */
/* بخش ۲۲: پشتیبانی از صفحه‌های بسیار کوچک */
/* ============================================ */

@media (max-width: 360px) {
    .header {
        padding: 0 10px;
    }
    
    .search-box input {
        width: 80px;
    }
    
    .page-title {
        font-size: 16px;
    }
    
    .stat-info h3 {
        font-size: 18px;
    }
    
    .btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .style-switcher-toggler,
    .pack-switcher-toggler {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
}