/**
 * Header Styles
 * Modern, clean header with slide drawer navigation for mobile
 */

/* CSS reset for header */
html, body {
    margin: 0;
    padding: 0;
}

/* Z-index hierarchy */
.topbar {
    z-index: 1000;
    /* Fixed di semua device untuk menempel di atas */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border-bottom: none;
}

/* Mobile topbar transition */
@media (max-width: 1023px) {
    .topbar {
        transition: transform 0.3s ease;
    }
}

.header-main {
    z-index: 999;
}

.mobile-drawer-overlay {
    z-index: 9998;
}

.mobile-drawer {
    z-index: 9999;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    transition: transform 0.3s ease;
    margin: 0;
    padding: 0;
    will-change: transform;
}

/* ============================================
   MAIN HEADER - ALWAYS STICKY/FIXED
   ============================================ */
.header-main {
    will-change: transform, top;
    transition: box-shadow 0.2s ease, top 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    border-top: none;
}

/* Desktop topbar height calculated automatically */
@media (min-width: 1024px) {
    .header-main {
        margin-top: 0;
    }
}

/* Mobile header below topbar */
@media (max-width: 1023px) {
    .header-main {
        transition: top 0.3s ease;
    }
}

/* Body padding set dynamically by JavaScript */
body {
    padding-top: 0;
}

/* Main content - add padding to compensate for fixed header */
main {
    margin-top: 0;
    padding-top: 5rem; /* Remove padding - let header overlap naturally */
}

.header-main.scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Logo animation */
.logo-wrapper img {
    transition: transform 0.3s ease;
}

/* Search input focus effect */
.search-desktop input:focus,
.search-mobile input:focus,
.drawer-search input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Language dropdown */
.lang-dropdown {
    z-index: 10001;
    transform-origin: top right;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.language-switcher:hover .lang-dropdown {
    transform: translateY(0);
}

/* Bookmark badge animation */
.bookmark-badge {
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Desktop navigation */
.desktop-nav {
    margin-top: 0;
    padding-bottom: 0.5rem; /* 8px padding di bawah */
}

.desktop-nav ul {
    gap: 0.25rem; /* 4px gap antar menu */
}

.nav-link {
    position: relative;
}

/* Hapus garis bawah */
/* .nav-link::after removed */

/* ============================================
   MOBILE DRAWER
   ============================================ */

/* Overlay */
.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    z-index: 9998;
}

.mobile-drawer-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto;
}

/* Drawer container */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 400px;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mobile-drawer.active {
    transform: translateX(0) !important;
}

/* Drawer header fixed at top */
.drawer-header {
    position: relative;
    z-index: 2;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(255, 255, 255, 1) 100%);
    overflow: hidden;
    flex-shrink: 0; /* Prevent shrinking */
}

.drawer-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    animation: drawer-bg-move 10s ease-in-out infinite;
    z-index: -1;
}

@keyframes drawer-bg-move {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-10%, -10%) scale(1.1);
    }
}

/* Drawer search fixed at top */
.drawer-search {
    position: relative;
    z-index: 2;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Drawer content scrollable area */
.drawer-content {
    position: relative;
    z-index: 1;
    flex: 1 1 0%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Drawer footer fixed at bottom */
.drawer-footer {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    flex-grow: 0;
}

/* Drawer scrollbar */
.drawer-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.3) transparent;
}

.drawer-content::-webkit-scrollbar {
    width: 6px;
}

.drawer-content::-webkit-scrollbar-track {
    background: transparent;
}

.drawer-content::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.3);
    border-radius: 3px;
}

.drawer-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.5);
}

/* Drawer Menu Links */
.drawer-menu-link {
    position: relative;
}

/* ============================================
   BODY SCROLL LOCK
   ============================================ */
body.drawer-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ============================================
   LOADING STATES
   ============================================ */
.header-main.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet: 640px - 1023px */
@media (min-width: 640px) and (max-width: 1023px) {
    .mobile-drawer {
        width: 360px;
    }
}

/* Desktop: ≥ 1024px */
@media (min-width: 1024px) {
    /* Hide mobile elements */
    .mobile-toggle,
    .mobile-drawer,
    .mobile-drawer-overlay,
    .search-mobile {
        display: none !important;
    }
    
    /* Show desktop elements */
    .desktop-nav,
    .search-desktop {
        display: block !important;
    }
}

/* Mobile: < 640px */
@media (max-width: 639px) {
    .mobile-drawer {
        width: 90vw;
    }
    
    .header-main .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus Visible for Keyboard Navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .topbar,
    .header-actions,
    .mobile-drawer,
    .mobile-drawer-overlay {
        display: none !important;
    }
    
    .header-main {
        position: relative !important;
        box-shadow: none !important;
    }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}
