/* ==========================================================================
   style: header.css
   کاربرد: استایل‌دهی کامل هدر دو سطری، شماره تماس بزرگ، سرچ باکس و منوی ناوبری
   ========================================================================== */

/* کانتینر استاندارد قالب */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   سطر اول هدر: بخش اصلی (Main Header)
   -------------------------------------------------------------------------- */
.header-main {
    background-color: #ffffff;
    padding: 20px 0;
    border-bottom: 1px solid #f0f0f0;
}

.header-main-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: rtl; /* راست‌چین کردن کل سطر */
    gap: 30px;
}

/* بخش لوگو */
.logo-wrapper {
    flex: 0 0 auto;
}

.logo-wrapper img {
    height: 70px; /* سایز استاندارد لوگو */
    width: auto;
    display: block;
    max-width: 100%;
}

.site-title-fallback {
    font-size: 22px;
    font-weight: bold;
    color: #0a2a66;
    text-decoration: none;
}

/* شماره تماس بزرگ (وسط هدر) */
.phone-wrapper {
    flex: 0 0 auto;
    text-align: center;
}

.header-phone-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    background: #f4f7fc; /* یک پس‌زمینه ملایم برای جلب توجه */
    padding: 8px 25px;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
    transition: all 0.3s ease;
}

.header-phone-large:hover {
    background: #e0ebf6;
    transform: translateY(-2px);
}

.header-phone-large .phone-label {
    font-size: 11px;
    color: #64748b;
    font-weight: bold;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.header-phone-large .phone-number {
    font-size: 22px; /* سایز بزرگ و خوانا */
    font-weight: 800;
    color: #0a2a66;
    letter-spacing: 1px;
}

/* جعبه جستجو (سمت چپ هدر) */
.search-wrapper {
    flex: 0 0 350px;
}

.search-wrapper form {
    display: flex;
    align-items: center;
    width: 100%;
}

.search-wrapper input[type="search"],
.search-wrapper input[type="text"] {
    flex: 1;
    height: 46px;
    padding: 0 15px;
    border: 1px solid #d1d5db;
    border-radius: 0 8px 8px 0; /* گرد کردن گوشه سمت راست در حالت RTL */
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-wrapper input[type="search"]:focus,
.search-wrapper input[type="text"]:focus {
    border-color: #0a2a66;
}

.search-wrapper button,
.search-wrapper input[type="submit"] {
    height: 46px;
    padding: 0 20px;
    border: none;
    background: #0a2a66;
    color: #ffffff;
    border-radius: 8px 0 0 8px; /* گرد کردن گوشه سمت چپ در حالت RTL */
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.3s ease;
}

.search-wrapper button:hover,
.search-wrapper input[type="submit"]:hover {
    background: #113c84;
}

/* --------------------------------------------------------------------------
   سطر دوم هدر: منوی ناوبری (Navigation)
   -------------------------------------------------------------------------- */
.header-nav {
    background-color: #ffffff;
    border-bottom: 2px solid #0a2a66; /* خط تیره زیر منو برای جداسازی */
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.header-nav-inner {
    display: flex;
    justify-content: flex-start; /* شروع چیدمان منو از راست */
    align-items: center;
}

.main-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 35px; /* فاصله بین گزینه‌های منو */
    direction: rtl;
}

.main-menu > li {
    position: relative;
}

.main-menu > li > a {
    display: block;
    padding: 15px 0;
    color: #1e293b;
    font-size: 15px;
    font-weight: bold;
    text-decoration: none;
    transition: color 0.3s ease;
}

.main-menu > li > a:hover {
    color: #0a2a66;
}

/* استایل زیرمنوهای آبشاری (Dropdown) */
.main-menu li ul {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    position: absolute;
    top: 100%;
    right: 0; /* تراز از راست در حالت RTL */
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    display: none;
    z-index: 999;
}

.main-menu li:hover > ul {
    display: block;
}

.main-menu li ul li a {
    display: block;
    padding: 10px 20px;
    color: #334155;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s, color 0.2s;
}

.main-menu li ul li a:hover {
    background-color: #f1f5f9;
    color: #0a2a66;
}

/* پیام راهنمای منو */
.menu-fallback-msg {
    padding: 15px 0;
    font-size: 13px;
    color: #64748b;
    border-right: 3px solid #3b82f6;
    padding-right: 10px;
}

/* --------------------------------------------------------------------------
   ریسپانسیو (Responsive Design)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
    .header-main-flex {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .search-wrapper {
        width: 100%;
        max-width: 100%;
    }
    
    .main-menu {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .logo-wrapper img {
        height: 55px;
    }
    
    .header-phone-large .phone-number {
        font-size: 18px;
    }
    
    .main-menu {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        padding: 15px 0;
    }
    
    .main-menu > li > a {
        padding: 8px 0;
    }
}
/* اصلاحیه برای وسط‌چین شدن منو و خوانایی بیشتر */
.header-nav-inner {
    display: flex;
    justify-content: center; /* منوها بیان وسط */
    align-items: center;
}

.main-menu > li > a {
    font-size: 16px; /* کمی درشت‌تر */
    padding: 18px 20px;
    color: #0a2a66; /* هماهنگ با رنگ برند */
}

.main-menu > li:hover > a {
    background-color: #f8fafc;
    color: #2563eb;
}
/* استایل شیک برای زیرمنوی دسته‌بندی‌ها */
.main-menu li ul {
    border-top: 3px solid #0a2a66; /* خط رنگی بالای بازشو */
    border-radius: 0 0 8px 8px;
    padding: 10px;
}

.main-menu li ul li a {
    border-bottom: 1px solid #f1f5f9;
    padding: 12px 15px;
}

.main-menu li ul li:last-child a {
    border-bottom: none;
}
/* استایل منوی خودکار */
.main-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    direction: rtl;
}

.main-menu > li > a {
    display: block;
    padding: 15px 25px;
    color: #0a2a66;
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 5px;
}

/* تغییر رنگ هنگام هاور روی سر دسته */
.main-menu > li:hover > a {
    background-color: #0a2a66;
    color: #ffffff !important;
}

/* آیکون فلش کنار کلمه دسته بندی */
.main-menu i.dashicons {
    font-size: 14px;
    vertical-align: middle;
    margin-right: 5px;
}

/* استایل زیرمنو (سطر اول بازشو) */
.main-menu li {
    position: relative;
}

.sub-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    min-width: 250px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-top: 3px solid #0a2a66;
    list-style: none;
    margin: 0;
    padding: 10px 0;
    display: none; /* در حالت عادی مخفی */
    z-index: 999;
    border-radius: 0 0 8px 8px;
}

.main-menu li:hover > .sub-menu {
    display: block; /* نمایش هنگام هاور */
    animation: fadeInMenu 0.3s ease;
}

.sub-menu li a {
    display: block;
    padding: 12px 20px;
    color: #334155;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

/* هاور روی زیر دسته‌ها */
.sub-menu li a:hover {
    background-color: #f8fafc;
    color: #2563eb;
    padding-right: 25px; /* افکت جابجایی کوچک هنگام هاور */
}

/* زیر-زیر منو (اگر دسته ها لایه سوم داشتند) */
.sub-menu .sub-menu {
    top: 0;
    right: 100%; /* باز شدن به سمت چپ */
    border-top: none;
    border-right: 3px solid #0a2a66;
}

@keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* --- اصلاح هدر برای موبایل (Responsive) --- */
@media (max-width: 768px) {
    /* 1. کنترل کانتینر اصلی هدر */
    .header-main-inner {
        flex-direction: column; /* چیدمان ستونی به جای افقی */
        align-items: center;
        text-align: center;
        gap: 15px; /* فاصله بین لوگو و جستجو */
        padding: 10px 0;
    }

    /* 2. تنظیم لوگو */
    .site-logo {
        margin: 0 auto;
        order: -1; /* لوگو همیشه برود بالاترین قسمت */
    }
    
    .site-logo img {
        max-width: 150px; /* سایز لوگو در موبایل */
        height: auto;
    }

    /* 3. مدیریت فرم جستجو در موبایل */
    .header-search {
        width: 90%; /* جستجو در موبایل پهن‌تر شود */
        order: 1;
    }

    /* 4. اصلاح منوی اصلی در موبایل */
    .header-nav-inner {
        justify-content: center;
    }

    .main-menu {
        flex-direction: column; /* منوها زیر هم قرار بگیرند */
        width: 100%;
        gap: 0;
    }
    
    .main-menu > li {
        width: 100%;
        border-bottom: 1px solid #eee;
    }
}
