/**
 * Premium Dropdown Navigation CSS
 * Inspired by Tokopedia, Shopee, GitHub Desktop, Apple, Vercel
 */

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN CONTAINER
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown {
    position: relative;
    display: inline-block;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN TOGGLE BUTTON
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    
    padding: 10px 14px;
    
    background: transparent;
    border: none;
    
    color: #64748B;
    font-size: 13px;
    font-weight: 500;
    
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    white-space: nowrap;
}

.dropdown-toggle:hover {
    color: #2563EB;
    background: #EFF6FF;
}

body.dark-mode .dropdown-toggle {
    color: #94A3B8;
}

body.dark-mode .dropdown-toggle:hover {
    color: #60A5FA;
    background: rgba(37, 99, 235, 0.15);
}

.dropdown-toggle.active {
    color: #2563EB;
    background: #EFF6FF;
}

body.dark-mode .dropdown-toggle.active {
    color: #60A5FA;
    background: rgba(37, 99, 235, 0.15);
}

/* For header nav links */
.header-nav-inner .dropdown-toggle {
    padding: 10px 14px;
    border-radius: var(--radius);
}

/* For header actions */
.header-actions .dropdown-toggle {
    padding: 6px 10px;
    border-radius: var(--radius);
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN MENU
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    max-width: 320px;
    
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08);
    
    padding: 8px;
    margin-top: 8px;
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    
    transition: all 0.225s cubic-bezier(0.4, 0, 0.2, 1);
    
    z-index: 1000;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dark mode */
body.dark-mode .dropdown-menu {
    background: #1E293B;
    border-color: #334155;
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN ITEM
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    
    padding: 10px 12px;
    
    color: #1E293B;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    
    border-radius: 8px;
    
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    white-space: nowrap;
}

.dropdown-item:hover {
    background: #EFF6FF;
    color: #2563EB;
}

body.dark-mode .dropdown-item {
    color: #E2E8F0;
}

body.dark-mode .dropdown-item:hover {
    background: rgba(37, 99, 235, 0.15);
    color: #60A5FA;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN HEADER (Category Brand Name)
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-header {
    padding: 8px 12px;
    
    font-size: 12px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    
    pointer-events: none;
}

body.dark-mode .dropdown-header {
    color: #94A3B8;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN DIVIDER
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-divider {
    height: 1px;
    background: #E2E8F0;
    margin: 8px 12px;
}

body.dark-mode .dropdown-divider {
    background: #334155;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN ICON (Chevron)
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown:hover .dropdown-icon {
    transform: rotate(180deg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   NESTED DROPDOWN (Sub-menu)
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-nested {
    position: relative;
}

.dropdown-nested-menu {
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 200px;
    
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    padding: 8px;
    margin-left: 8px;
    
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    
    transition: all 0.225s cubic-bezier(0.4, 0, 0.2, 1);
    
    z-index: 1001;
}

.dropdown-nested:hover .dropdown-nested-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

body.dark-mode .dropdown-nested-menu {
    background: #1E293B;
    border-color: #334155;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MOBILE ACCORDION
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .dropdown-menu {
        position: static;
        width: 100%;
        max-width: none;
        min-width: 0;
        
        margin-top: 0;
        padding: 0;
        
        opacity: 1;
        visibility: visible;
        transform: none;
        
        display: none;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    
    .dropdown.active .dropdown-menu {
        display: block;
    }
    
    .dropdown-item {
        padding: 12px 16px;
        border-radius: 0;
        border-bottom: 1px solid #E2E8F0;
    }
    
    body.dark-mode .dropdown-item {
        border-bottom-color: #334155;
    }
    
    .dropdown-header {
        padding: 12px 16px;
        background: #F8FAFC;
        border-bottom: 1px solid #E2E8F0;
    }
    
    body.dark-mode .dropdown-header {
        background: #1E293B;
        border-bottom-color: #334155;
    }
    
    .dropdown-divider {
        display: none;
    }
    
    .dropdown-nested-menu {
        position: static;
        width: 100%;
        max-width: none;
        min-width: 0;
        
        margin-left: 0;
        padding-left: 24px;
        
        opacity: 1;
        visibility: visible;
        transform: none;
        
        display: none;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    
    .dropdown-nested.active .dropdown-nested-menu {
        display: block;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   ACCESSIBILITY
   ───────────────────────────────────────────────────────────────────────────── */
.dropdown-toggle:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

.dropdown-item:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: -2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   REDUCED MOTION
   ───────────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .dropdown-menu,
    .dropdown-nested-menu,
    .dropdown-icon {
        transition: none;
    }
    
    .dropdown-menu,
    .dropdown-nested-menu {
        transform: none;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   TABLET (Click-based dropdown)
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
    .dropdown-menu {
        /* On tablet, dropdown opens on click, not hover */
        pointer-events: none;
    }
    
    .dropdown.active .dropdown-menu {
        pointer-events: auto;
    }
}
