/* ==================== متغیرها ==================== */
:root {
    --primary-dark: #000;
    --secondary-dark: #1a1f2e;
    --accent-blue: #2563eb;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --sidebar-width-desktop: 280px;
    --sidebar-width-tablet: 80px;
    --sidebar-width-mobile: 85%;
    --sidebar-collapsed: 80px;
    --sidebar-expanded: 280px;
    --transition-speed: 0.3s;
    --header-height: 77px;
}

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

body {
    background-color: var(--primary-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== کانتینر اصلی ==================== */
.training-page-fix {
    background-color: var(--primary-dark);
    min-height: 100vh;
}

.training-container-fix {
    display: flex;
    gap: 30px;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* ==================== سایدبار ==================== */
.sidebar {
    position: sticky !important;
    top: 100px !important;
    height: calc(100vh - 140px) !important;
    background: linear-gradient(180deg, var(--secondary-dark) 0%, rgba(26, 31, 46, 0.98) 100%);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
    transition: width var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

/* ==================== هدر سایدبار - دکمه بازگشت در راست، دکمه جمع در چپ ==================== */
.sidebar .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* دکمه بازگشت - در سمت راست (اولین عنصر) */
.sidebar .back-to-home-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(37, 99, 235, 0.15);
    color: var(--accent-blue);
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s;
    border: 1px solid rgba(37, 99, 235, 0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    order: 1;
}

.sidebar .back-to-home-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* دکمه جمع کننده - در سمت چپ (دومین عنصر) */
.sidebar .sidebar-toggle {
    position: relative;
    left: 0;
    top: 0;
    transform: none;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 0.9rem;
    transition: all 0.3s;
    order: 2;
}

.sidebar .sidebar-toggle:hover {
    background: var(--accent-blue);
    transform: scale(1.05);
}

/* بخش‌های سایدبار */
.sidebar-sections {
    padding: 15px 0;
    flex: 1;
}

.sidebar-section {
    padding: 12px 15px;
}

.sidebar-section-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-right: 8px;
    transition: all var(--transition-speed);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px !important;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s;
    position: relative;
    min-width: 0;
}

.sidebar-nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(-3px);
}

.sidebar-nav-link.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.2), transparent);
    color: var(--text-primary);
    border-right: 3px solid var(--accent-blue);
}

.sidebar-nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-nav-icon i {
    font-size: 1.1rem;
}

.sidebar-nav-text {
    flex: 1;
    font-size: 0.85rem;
    transition: all var(--transition-speed);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-badge {
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.65rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-badge.bg-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.sidebar-badge.bg-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

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

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .back-to-home-btn {
    display: none;
}

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

.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-nav-text,
.sidebar.collapsed .sidebar-badge {
    display: none;
}

.sidebar.collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 10px !important;
}

.sidebar.collapsed .sidebar-nav-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-nav-icon i {
    font-size: 1.3rem;
}

/* ==================== محتوای اصلی ==================== */
.main-content-fix {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* بنر وضعیت بازار */
.market-status-banner {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(16, 185, 129, 0.1));
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.market-time-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.time-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 15px;
    border-radius: 30px;
    font-size: 0.9rem;
}

.time-badge i {
    color: var(--accent-blue);
    margin-left: 8px;
}

.time-diff-badge {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* بخش‌های بازار */
.market-section {
    padding: 40px 0;
    scroll-margin-top: 120px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.section-title .badge {
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 20px;
}

.section-title .badge.bg-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.section-title .badge.bg-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

/* کارت بازار */
.market-card {
    background: linear-gradient(145deg, var(--secondary-dark), #151a2d);
    border: 1px solid #2d3748;
    border-radius: 16px;
    padding: 25px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    display: flex;
    flex-direction: column;
    color: inherit;
    position: relative;
    overflow: hidden;
    text-decoration: none !important;
    cursor: pointer;
}

.market-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-blue);
}

.card-content {
    flex: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    position: relative;
    z-index: 3;
}

.symbol-info {
    flex: 1;
}

.market-symbol {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.market-name {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.category-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: inline-block;
}

.forex-badge { background: linear-gradient(135deg, #3b82f6, #60a5fa); color: white; }
.crypto-badge { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #000; }
.commodities-badge { background: linear-gradient(135deg, #f97316, #fb923c); color: white; }
.indices-badge { background: linear-gradient(135deg, #8b5cf6, #a78bfa); color: white; }
.stocks-badge { background: linear-gradient(135deg, #10b981, #34d399); color: white; }

.chart-icon {
    font-size: 2.2rem;
    color: var(--accent-blue);
    opacity: 0.7;
    transition: all 0.3s;
}

.market-card:hover .chart-icon {
    transform: scale(1.2) translateY(-5px);
    opacity: 1;
}

.market-hours {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 15px;
}

.market-open {
    color: var(--accent-green);
}

.market-closed {
    color: var(--accent-red);
}

.click-indicator {
    position: absolute;
    bottom: 15px;
    left: 15px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.market-card:hover .click-indicator {
    opacity: 0.7;
}

/* ==================== دکمه منوی موبایل ==================== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    right: 15px;
    top: 80px;
    z-index: 1002;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 12px;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-menu-btn:hover {
    background: #3b82f6;
    transform: scale(1.05);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    z-index: 999;
}

.mobile-overlay.active {
    display: block;
}

/* ==================== ریسپانسیو ==================== */

/* دسکتاپ (بیشتر از 1024px) */
@media (min-width: 1025px) {
    .sidebar {
        width: var(--sidebar-expanded) !important;
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-collapsed) !important;
    }
    
    .mobile-menu-btn {
        display: none !important;
    }
}

/* تبلت (768px تا 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed) !important;
        position: sticky !important;
        top: 100px !important;
    }
    
    /* حالت باز شده در تبلت */
    .sidebar.tablet-expanded {
        width: var(--sidebar-expanded) !important;
    }
    
    /* وقتی باز است، متن‌ها را نشان بده */
    .sidebar.tablet-expanded .sidebar-logo-text,
    .sidebar.tablet-expanded .sidebar-nav-text,
    .sidebar.tablet-expanded .sidebar-badge,
    .sidebar.tablet-expanded .sidebar-section-title,
    .sidebar.tablet-expanded .back-to-home-btn span {
        display: flex !important;
    }
    
    .sidebar.tablet-expanded .sidebar-nav-link {
        justify-content: flex-start !important;
        padding: 8px 12px !important;
    }
    
    .sidebar.tablet-expanded .sidebar-nav-icon {
        margin-left: 0 !important;
    }
    
    .sidebar.tablet-expanded .back-to-home-btn {
        font-size: 0.85rem !important;
        justify-content: center !important;
    }
    
    .sidebar.tablet-expanded .back-to-home-btn::before {
        content: none !important;
    }
    
    /* حالت عادی تبلت (جمع شده) */
    .sidebar .sidebar-logo-text,
    .sidebar .sidebar-nav-text,
    .sidebar .sidebar-badge,
    .sidebar .sidebar-section-title,
    .sidebar .back-to-home-btn span {
        display: none !important;
    }
    
    .sidebar .sidebar-nav-link {
        justify-content: center !important;
        padding: 10px !important;
    }
    
    .sidebar .sidebar-nav-icon {
        margin: 0 !important;
    }
    
    .sidebar .sidebar-nav-icon i {
        font-size: 1.3rem !important;
    }
    
    .sidebar .back-to-home-btn {
        justify-content: center !important;
        padding: 10px !important;
        font-size: 0 !important;
        order: 1;
    }
    
    .sidebar .back-to-home-btn::before {
        content: "←";
        font-size: 1rem;
    }
    
    .sidebar .sidebar-toggle {
        order: 2;
    }
    
    .mobile-menu-btn {
        display: none !important;
    }
}

/* موبایل (کمتر از 768px) */
@media (max-width: 767px) {
    .training-container-fix {
        flex-direction: column;
        padding: 10px;
        gap: 0;
    }
    
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        width: 85% !important;
        max-width: 300px;
        height: 100vh !important;
        transition: right 0.3s ease;
        z-index: 1001;
        border-radius: 0;
    }
    
    .sidebar.mobile-open {
        right: 0 !important;
    }
    
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .main-content-fix {
        margin-right: 0 !important;
        padding-top: 70px !important;
    }
    
    .market-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .market-status-banner {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .market-time-info {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .time-badge {
        width: 100%;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .chart-icon {
        position: absolute;
        left: 25px;
        top: 25px;
        font-size: 1.8rem;
    }
    
    .symbol-info {
        width: 100%;
        padding-right: 45px;
    }
    
    .click-indicator {
        opacity: 0.5;
    }
    
    .market-section {
        padding: 25px 0;
    }
    
    .section-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .market-symbol {
        font-size: 1.2rem;
    }
    
    .market-name {
        font-size: 0.85rem;
    }
    
    .category-badge {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
}

/* اسکرول بار */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}
/* ==================== نمایش آیکون دکمه بازگشت در حالت جمع شده ==================== */

/* حالت جمع شده - نمایش آیکون به جای متن کامل */
.sidebar-fix.collapsed .back-to-home-btn,
.sidebar.collapsed .back-to-home-btn {
    display: flex !important;
    font-size: 0 !important;
    padding: 10px !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    width: 34px !important;
}

.sidebar-fix.collapsed .back-to-home-btn::before,
.sidebar.collapsed .back-to-home-btn::before {
    content: "←";
    font-size: 1.2rem;
    margin: 0;
}

/* تنظیم هدر در حالت جمع شده */
.sidebar-fix.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-header {
    justify-content: space-between !important;
    gap: 5px;
}

/* تنظیم دکمه جمع کننده در کنار آیکون بازگشت */
.sidebar-fix.collapsed .sidebar-toggle,
.sidebar.collapsed .sidebar-toggle {
    order: 2;
}

.sidebar-fix.collapsed .back-to-home-btn,
.sidebar.collapsed .back-to-home-btn {
    order: 1;
}