/* css/header.css */
:root {
    --header-bg: #ffffff;
    --header-sticky-bg: rgba(255, 255, 255, 0.98);
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.dark-mode {
    --header-bg: #0f172a;
    --header-sticky-bg: #0f172a;
    --text-dark: #f1f5f9;
    --text-light: #94a3b8;
    --border-color: #334155;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Tahoma', 'Segoe UI', sans-serif; direction: rtl; }
.site-header {
    background: var(--header-bg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}
.site-header.scrolled {
    background: var(--header-sticky-bg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.header-top { padding: 15px 0; border-bottom: 1px solid var(--border-color); }
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.logo-area .logo-link { display: flex; align-items: center; gap: 15px; text-decoration: none; }
.logo-img { height: 50px; width: auto; object-fit: contain; }
.site-title-group { line-height: 1.3; }
.site-title { font-size: 1.4rem; font-weight: 700; color: var(--primary-color); display: block; }
.site-slogan { font-size: 0.75rem; color: var(--text-light); display: block; }
.header-right { display: flex; align-items: center; gap: 15px; }
.search-box {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 40px;
    overflow: hidden;
    background: var(--header-bg);
}
#search-input {
    border: none;
    padding: 8px 15px;
    width: 220px;
    outline: none;
    font-size: 0.9rem;
    background: var(--header-bg);
    color: var(--text-dark);
}
#search-btn {
    background: none;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    color: var(--text-light);
}
#search-btn:hover { color: var(--primary-color); }
.btn-login-register {
    display: inline-block;
    padding: 8px 22px;
    background: var(--primary-color);
    color: white;
    border-radius: 40px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}
.btn-login-register:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    width: 30px;
    height: 25px;
    justify-content: space-between;
}
.mobile-menu-toggle span {
    width: 100%;
    height: 3px;
    background: var(--text-dark);
    transition: 0.3s;
    border-radius: 3px;
}
.mobile-menu-toggle.active span:nth-child(1) { transform: translateY(11px) rotate(45deg); }
.mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.active span:nth-child(3) { transform: translateY(-11px) rotate(-45deg); }
.header-bottom { background: var(--header-bg); }
.main-nav .menu {
    display: flex;
    justify-content: flex-start;
    list-style: none;
    margin: 0;
    padding: 0;
}
.main-nav .menu > li { position: relative; }
.main-nav .menu > li > a {
    display: block;
    padding: 15px 18px;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
}
.main-nav .menu > li > a:hover,
.main-nav .menu > li.active > a { color: var(--primary-color); }
.main-nav .menu .submenu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--header-bg);
    min-width: 200px;
    box-shadow: var(--shadow-md);
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
    list-style: none;
    padding: 8px 0;
}
.main-nav .menu li:hover > .submenu { opacity: 1; visibility: visible; }
.main-nav .menu .submenu li a {
    display: block;
    padding: 8px 20px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.9rem;
}
.main-nav .menu .submenu li a:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}
@media (max-width: 992px) {
    .mobile-menu-toggle { display: flex; }
    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    .menu-overlay.active { display: block; }
    .header-bottom {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100%;
        background: var(--header-bg);
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s;
        z-index: 1000;
        overflow-y: auto;
        padding-top: 80px;
    }
    .header-bottom.open { right: 0; }
    .main-nav .menu { flex-direction: column; padding: 20px; }
    .main-nav .menu > li > a { padding: 12px 0; }
    .main-nav .menu .submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        padding-right: 20px;
        display: none;
    }
    .main-nav .menu li:hover > .submenu { display: block; }
    .desktop-only { display: none !important; }
}
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--header-bg);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    justify-content: space-around;
    padding: 8px 0;
    z-index: 1000;
}
@media (max-width: 992px) {
    .mobile-bottom-nav { display: flex; }
    body { margin-bottom: 70px; }
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.7rem;
}
.nav-item i { font-size: 1.3rem; margin-bottom: 4px; }
.nav-item.active, .nav-item:hover { color: var(--primary-color); }
.user-panel {
    position: relative;
    display: inline-block;
    margin-right: 20px;
    cursor: pointer;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--hover-bg);
    padding: 6px 12px;
    border-radius: 40px;
}
.user-info:hover { background: var(--border-color); }
.user-name-display { font-weight: 500; color: var(--text-dark); font-size: 0.9rem; }
.user-role {
    font-size: 0.7rem;
    color: var(--text-light);
    background: var(--border-color);
    padding: 2px 8px;
    border-radius: 20px;
}
.user-info i.fa-chevron-down {
    transition: transform 0.2s;
    font-size: 0.8rem;
    color: var(--text-light);
}
.user-info i.fa-chevron-down.rotate { transform: rotate(180deg); }
.user-dropdown-menu {
    position: absolute;
    top: 110%;
    left: 0;
    background: var(--card-bg);
    min-width: 200px;
    box-shadow: var(--shadow-md);
    border-radius: 12px;
    z-index: 1000;
    overflow: hidden;
    padding: 8px 0;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.9rem;
    width: 100%;
    text-align: right;
    border: none;
    background: none;
    cursor: pointer;
}
.dropdown-item i { width: 20px; color: var(--primary-color); }
.dropdown-item:hover { background: var(--hover-bg); }
.dropdown-item.logout { color: #dc2626; }
.dropdown-item.logout i { color: #dc2626; }
.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}
@media (max-width: 992px) {
    .header-bottom .container { display: flex; flex-direction: column; }
    .user-panel { order: -1; margin: 15px 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }
    .user-info { justify-content: space-between; width: 100%; }
    .user-dropdown-menu { position: static; box-shadow: none; background: transparent; padding: 0; margin-top: 10px; }
    .dropdown-item { padding: 12px 20px; }
}
@media (min-width: 993px) {
    .header-bottom .container {
        display: flex;
        justify-content: space-between; /* فاصله بین منو و پنل کاربری */
        align-items: center;
    }
    .main-nav {
        order: 0; /* منو اول */
        flex: 1;
    }
    .user-panel {
        order: 1; /* پنل کاربری بعد از منو */
        margin-left: 0;
        margin-right: 20px;
    }
}
.user-text {
    display: flex;
    flex-direction: column;
    gap: 2px; /* فاصله اندک بین دو خط (اختیاری) */
}
/* آیتم تغییر تم در منوی موبایل (پیش‌فرض مخفی در دسکتاپ) */
.mobile-theme-menu-item {
    display: none;
}

/* نمایش آیتم فقط در موبایل (زمانی که منوی همبرگر باز است) */
@media (max-width: 992px) {
    .mobile-theme-menu-item {
        display: block;
        border-top: 1px solid var(--border-color);
        margin-top: 10px;
        padding-top: 10px;
    }
    .theme-toggle-mobile {
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
        font-weight: 500;
        color: var(--text-dark);
        text-align: right;
        transition: background 0.2s;
    }
    .theme-toggle-mobile:hover {
        background: var(--hover-bg);
    }
    .theme-toggle-mobile i {
        width: 20px;
        font-size: 1.2rem;
    }
}
@media (max-width: 992px) {
    /* تغییر ترتیب آیتم‌های هدر در موبایل */
    .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    /* لوگو به سمت راست منتقل می‌شود (در راست‌چین، راست همان ابتداست) */
    .logo-area {
        order: 2;
        flex: 1;
        text-align: right;
    }
    /* دکمه همبرگر به سمت چپ برود */
    .mobile-menu-toggle {
        order: 0;  /* عدد کوچک‌تر یعنی زودتر (چپ‌ترین) در راست‌چین */
        margin-left: 0;
        margin-right: auto; /* فاصله از راست */
    }
    /* دکمه تغییر تم موبایل (اگر دارید) - در صورت نیاز */
    .mobile-theme-toggle {
        order: 2;
        margin-left: 10px;
    }
}
@media (max-width: 992px) {
    .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    /* لوگو را به سمت چپ ببریم (در RTL، چپ انتهای خط است) */
    .logo-area {
        order: 1;   /* عدد بزرگتر = دیرتر (سمت چپ) */
        text-align: left;
    }
    /* دکمه همبرگر را در سمت راست نگه داریم (اگر بخواهید) */
    .mobile-menu-toggle {
        order: 0;   /* عدد کوچکتر = سمت راست */
        margin-right: 0;
    }
    /* دکمه تغییر تم موبایل (اختیاری) */
    .mobile-theme-toggle {
        order: 2;
        margin-left: auto;
        margin-right: 10px;
    }
}

/*---------------------------------------------------------------*/




/* ========== زیرمنوها ========== */
.main-nav .menu .submenu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    min-width: max-content; /* حداقل عرض به اندازه محتوا */
    box-shadow: var(--shadow-md);
    border-radius: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
    list-style: none;
    padding: 0.5rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: row; /* افقی */
    flex-wrap: nowrap; /* بدون شکستن سطر */
    gap: 0.25rem;
    border: 1px solid var(--border-color);
}

/* در صورت زیاد شدن آیتم‌ها، اسکرول افقی اضافه می‌شود */
.main-nav .menu .submenu {
    max-width: 90vw; /* حداکثر 90% عرض صفحه */
    overflow-x: auto;
    overflow-y: hidden;
}

/* مخفی کردن اسکرول بار در مرورگرهای Webkit (اختیاری) */
.main-nav .menu .submenu::-webkit-scrollbar {
    height: 4px;
}
.main-nav .menu .submenu::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 10px;
}
.main-nav .menu .submenu::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.main-nav .menu li:hover > .submenu {
    opacity: 1;
    visibility: visible;
}

/* آیتم‌های زیرمنو (کنار هم) */
.main-nav .menu .submenu li {
    flex: 0 0 auto; /* عرض بر اساس محتوا */
}

.main-nav .menu .submenu li a {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.85rem;
    border-radius: 30px;
    transition: all 0.2s;
    white-space: nowrap; /* جلوگیری از شکستن متن */
}

.main-nav .menu .submenu li a:hover {
    background: var(--primary-color);
    color: white;
}
@media (max-width: 992px) {
    .main-nav .menu .submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        padding-right: 20px;
        display: none;
        flex-direction: column;
        flex-wrap: wrap;
        gap: 0;
        max-width: 100%;
        overflow-x: visible;
    }
    
    .main-nav .menu .submenu li {
        flex: 1;
    }
    
    .main-nav .menu .submenu li a {
        white-space: normal;
        padding: 8px 0;
    }
}

/* ========== ???? ???? (??? ??? ?? ???) ========== */
.dynamic-widget-container {
    max-width: 1200px;
    margin: 2rem auto;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

.dynamic-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--hover-bg);
    border-bottom: 1px solid var(--border-color);
}

.dynamic-widget-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-widget-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-widget-btn:hover {
    background: var(--delete-bg);
    color: var(--delete-color);
}

.dynamic-widget-content {
    padding: 1rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}