/* assets/css/header-custom.css
   طراحی هدر مطابق با تصویر مرجع: دسته‌بندی راست، جستجو وسط، آیکون‌ها چپ
*/

.custom-header {
    height: 80px;
    min-height: 80px;
    display: flex;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid rgba(15,23,42,0.06);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    z-index: 1030;
}

.custom-header .container {
    max-width: 1400px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
}

/* دسته‌بندی - سمت راست */
.header-right {
    flex-shrink: 0;
    order: 1;
}

/* جستجو - وسط */
.header-center {
    flex: 1;
    justify-content: center;
    order: 2;
    max-width: 600px;
}

/* آیکون‌ها - سمت چپ */
.header-left {
    flex-shrink: 0;
    order: 3;
}

/* لوگو */
.navbar-brand {
    text-decoration: none;
    margin-left: 20px;
}

.header-logo-img {
    max-height: 50px;
    height: auto;
    width: auto;
}

.icon-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-group .header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: #1f2937;
    background: #f3f4f6;
    text-decoration: none;
    font-size: 18px;
    transition: all .2s ease;
}

.icon-group .header-icon:hover {
    background: #e5e7eb;
    color: #111827;
    transform: translateY(-2px);
}

.site-search-form {
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.site-search-input {
    height: 46px;
    border-radius: 8px;
    padding-right: 48px;
    padding-left: 16px;
    font-size: 0.9rem;
    box-shadow: none;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    transition: all 0.2s ease;
}

.site-search-input:focus {
    border-color: #d1d5db;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.02);
    outline: none;
}

.site-search-input::placeholder {
    color: #9ca3af;
    font-size: 0.85rem;
}

.search-icon-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 16px;
    padding: 10px 14px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.search-icon-btn:hover {
    color: #111827;
}

.search-suggestions {
    right: 0;
    left: 0;
    border-radius: 10px;
}

.cart-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main nav styles - دسته‌بندی و منوها */
.main-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.main-nav .nav-item { 
    position: relative;
}

.main-nav .categories-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1f2937;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 20px;
    border-radius: 8px;
    background: #f3f4f6;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.main-nav .categories-toggle:hover {
    background: #e5e7eb;
    color: #111827;
}

.main-nav .categories-toggle i {
    font-size: 16px;
}

/* لینک‌های درباره ما و تماس با ما */
.main-nav .nav-link-item {
    color: #4b5563;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.main-nav .nav-link-item:hover {
    color: #111827;
    background: #f9fafb;
}

/* ===== Megamenu - New Design ===== */
.nav-item .megamenu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 960px;
    max-height: 540px;
    background: #fff;
    border: 1px solid #e8e8e8;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    border-radius: 0 0 12px 12px;
    display: none;
    z-index: 1060;
    overflow: hidden;
    /* پر کردن gap با padding-top */
    padding-top: 0;
    margin-top: 0;
}
.nav-item .megamenu.is-open {
    display: flex !important;
}

/* ساختار داخلی */
.megamenu-inner {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* ستون عناوین سمت راست */
.megamenu-sidebar {
    width: 180px;
    flex-shrink: 0;
    background: #f8f9fa;
    border-left: 1px solid #f0f0f0;
    overflow-y: auto;
    padding: 8px 0;
}
.megamenu-sidebar-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    border-right: 3px solid transparent;
    gap: 6px;
}
.megamenu-sidebar-item:hover,
.megamenu-sidebar-item.active {
    background: #fff;
    color: #e63950;
    border-right-color: #e63950;
}
.megamenu-sidebar-item i { font-size: 0.7rem; margin-right: auto; color: #ccc; }
.megamenu-sidebar-item.active i,
.megamenu-sidebar-item:hover i { color: #e63950; }

/* پنل‌های محتوا */
.megamenu-panels {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}
.megamenu-panel {
    display: none;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 0;
}
.megamenu-panel.active {
    display: flex;
}

/* ستون‌های داخل پنل */
.mm-col {
    width: 25%;
    padding: 0 16px 12px 0;
    min-width: 0;
}
.mm-col-title {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    color: #1a1a1a;
    text-decoration: none;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid #f0f0f0;
    transition: color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mm-col-title::before {
    content: '| ';
    color: #e63950;
    font-weight: 900;
}
.mm-col-title:hover { color: #e63950; }
.mm-col-item {
    display: block;
    font-size: 0.82rem;
    color: #666;
    text-decoration: none;
    padding: 2px 0;
    line-height: 1.7;
    transition: color 0.15s, padding-right 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mm-col-item:hover { color: #e63950; padding-right: 4px; }

/* Fallback dropdown */
.nav-item .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.06);
    box-shadow: 0 8px 20px rgba(2,6,23,0.08);
    border-radius: 8px;
    display: none;
    z-index: 1060;
}
.nav-item .dropdown-menu .dropdown-item {
    display: block;
    padding: 10px 12px;
    color: #0f172a;
    text-decoration: none;
    border-bottom: 1px solid rgba(15,23,42,0.03);
    transition: all 0.15s ease;
}
.nav-item .dropdown-menu .dropdown-item:hover {
    background: rgba(230,57,80,0.06);
    color: #e63950;
}
.nav-item .dropdown-menu .dropdown-item:last-child { border-bottom: none; }

@media (hover: hover) and (min-width: 992px) {
    .nav-item:hover > .dropdown-menu { display: block; }
}
@media (max-width: 991px) {
    .nav-item .megamenu { position: static; display: none; }
    .nav-item .dropdown-menu { position: static; display: none; }
}
@media (max-width: 1200px) {
    .nav-item .megamenu { width: 720px; }
    .mm-col { width: 33.33%; }
}
@media (max-width: 1024px) {
    .nav-item .megamenu { width: 600px; }
    .mm-col { width: 50%; }
    .megamenu-sidebar { width: 150px; }
}
@media (max-width: 991px) {
    .custom-header { height: auto; box-shadow: none; border-bottom: 1px solid rgba(15,23,42,0.04); }
    .header-left, .header-right { width: auto; }
    .site-search-form { width: 100%; }
}

/* User Menu Dropdown Styles */
.user-menu-wrapper {
    position: relative;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 240px;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.08);
    box-shadow: 0 12px 32px rgba(2,6,23,0.15);
    border-radius: 12px;
    display: none;
    z-index: 1060;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, transform 0.2s ease-in-out;
    transform: translateX(-50%) translateY(-8px);
}

.user-dropdown-menu.show {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 12px 12px 0 0;
    margin: -8px 0 0 0;
}

.user-dropdown-header i {
    font-size: 24px;
    opacity: 0.9;
}

.user-dropdown-header .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(15,23,42,0.06);
    margin: 8px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #334155;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.user-dropdown-item:hover {
    background: rgba(99,102,241,0.06);
    color: #4f46e5;
}

.user-dropdown-item.text-danger {
    color: #dc2626;
}

.user-dropdown-item.text-danger:hover {
    background: rgba(220,38,38,0.06);
    color: #b91c1c;
}

.user-dropdown-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* Arrow indicator for dropdown */
.user-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid rgba(15,23,42,0.08);
    border-top: 1px solid rgba(15,23,42,0.08);
    transform: translateX(-50%) rotate(45deg);
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .user-dropdown-menu {
        left: auto;
        right: 0;
        transform: none;
    }
    
    .user-dropdown-menu.show {
        transform: translateY(0);
    }
    
    .user-dropdown-menu::before {
        left: auto;
        right: 20px;
        transform: rotate(45deg);
    }
}

/* Active state for user menu icon when menu is open */
.user-menu-wrapper .header-icon.active {
    background: #dbeafe;
    color: #3b82f6;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .custom-header .container {
        gap: 20px;
    }
    
    .header-center {
        max-width: 500px;
    }
    
    .nav-item .megamenu {
        width: 800px;
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991px) {
    .custom-header {
        height: auto;
        min-height: 60px;
    }
    
    .main-nav {
        display: none !important;
    }
    
    .header-center {
        max-width: 100%;
    }
}

/* ── برندها در مگامنو ─────────────────────────────────────────── */
.mm-brands-divider {
    height: 1px;
    background: linear-gradient(to left, transparent, #e5e7eb, transparent);
    margin: 6px 0 5px;
}

/* لینک برند — مشابه mm-col-item ولی با لوگو */
.mm-col-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0 4px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    position: relative;
    transition: color .15s;
    line-height: 1.4;
}
.mm-col-brand::before {
    content: '›';
    position: absolute;
    right: 0;
    color: #d1d5db;
    font-size: 13px;
}
.mm-col-brand:hover {
    color: #2563eb;
    padding-right: 6px;
}
.mm-col-brand:hover::before {
    color: #2563eb;
    right: -4px;
}

/* لوگوی برند کوچک */
.mm-brand-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 3px;
    flex-shrink: 0;
    opacity: .85;
}
.mm-col-brand:hover .mm-brand-logo { opacity: 1; }

/* آیکون fallback وقتی لوگو نداره */
.mm-brand-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    border-radius: 3px;
    color: #3b82f6;
    font-size: 0.65rem;
    flex-shrink: 0;
}
