/* 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 Styles */
.nav-item .megamenu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 950px;
    max-height: 520px;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border-radius: 12px;
    display: none;
    z-index: 1060;
    padding: 24px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    transform: translateY(-10px);
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.nav-item:hover .megamenu,
.nav-item:focus-within .megamenu {
    display: grid !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.megamenu .megamenu-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.megamenu .megamenu-column:hover {
    background: #f9fafb;
}

.megamenu .megamenu-column-title {
    font-weight: 700;
    color: #111827;
    text-decoration: none;
    font-size: 0.95rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
    transition: color 0.2s ease;
    display: block;
}

.megamenu .megamenu-column-title:hover {
    color: #3b82f6;
}

.megamenu .megamenu-subcategory {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 400;
    padding: 6px 0 6px 16px;
    margin-right: 0;
    transition: all 0.2s ease;
    display: block;
    position: relative;
    line-height: 1.5;
}

.megamenu .megamenu-subcategory::before {
    content: '›';
    position: absolute;
    right: 0;
    color: #d1d5db;
    font-size: 14px;
    transition: all 0.2s ease;
}

.megamenu .megamenu-subcategory:hover {
    color: #3b82f6;
    padding-right: 6px;
}

.megamenu .megamenu-subcategory:hover::before {
    color: #3b82f6;
    right: -4px;
}

/* Fallback: Simple dropdown for brands */
.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(99,102,241,0.06);
    color: #4f46e5;
}

.nav-item .dropdown-menu .dropdown-item:last-child { border-bottom: none; }

/* show on hover for desktop */
@media (hover: hover) and (min-width: 992px) {
    .nav-item:hover > .megamenu { display: block; }
    .nav-item:hover > .dropdown-menu { display: block; }
}

/* small device fallback: dropdown shows as block under the header */
@media (max-width: 991px) {
    .nav-item .megamenu { position: static; display: none; }
    .nav-item .dropdown-menu { position: static; display: none; }
}

/* Responsive megamenu for tablets */
@media (max-width: 1200px) {
    .nav-item .megamenu {
        width: 700px;
    }
    .megamenu .megamenu-column {
        width: 30%;
        margin-right: 5%;
    }
}

/* Responsive tweaks */
@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%;
    }
}
