/**
 * Modern SaaS Header Styles
 * Clean, Premium, Apple-inspired Design
 * Features: Floating Pill, Glassmorphism, Theme Toggle
 */

/* Header Container (Wrapper) */
.modern-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 24px 0;
    /* Spacious initial padding */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent !important;
    /* Wrapper is always transparent */
    box-shadow: none !important;
    backdrop-filter: none !important;
    border: none !important;
}

/* Scrolled State - Wrapper Padding Reduces */
.modern-header.scrolled {
    padding: 12px 0;
}

/* Navigation Layout (The Pill) */
/* This is inside .container-xxl so it handles width naturally */
.modern-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    padding: 12px 30px;
    border-radius: 50px;
    /* Rounded Pill */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

/* Scrolled State - The Pill Appears */
/* "Melayang" logic: Glass background, shadow, border */
.modern-header.scrolled .modern-nav {
    background: rgba(255, 255, 255, 0.85);
    /* Glass Background */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Logo */
.modern-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.modern-logo img {
    height: 32px;
    transition: transform 0.3s ease;
}

.modern-logo:hover img {
    transform: scale(1.05);
}

.modern-logo .logo-light {
    display: block;
}

.modern-logo .logo-dark {
    display: none;
}

[data-bs-theme="dark"] .modern-logo .logo-light {
    display: none;
}

[data-bs-theme="dark"] .modern-logo .logo-dark {
    display: block;
}

/* Desktop Menu */
.modern-menu {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 50px;
}

@media (min-width: 992px) {
    .modern-menu {
        display: flex;
    }
}

.modern-menu-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bs-gray-700);
    text-decoration: none;
    border-radius: 40px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.modern-menu-link:hover {
    color: var(--bs-primary);
    background: rgba(102, 126, 234, 0.08);
    /* Subtle hover pill */
}

.modern-menu-link.active {
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Actions */
.modern-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Icon Button */
.modern-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    color: var(--bs-gray-700);
    cursor: pointer;
    transition: all 0.3s ease;
}

.modern-btn-icon:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--bs-primary);
    transform: scale(1.05);
}

/* Mobile/Tablet View - Always Pill */
@media (max-width: 991.98px) {
    .modern-header {
        padding: 12px 0;
    }

    .modern-nav {
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.5);
        padding: 12px 20px;
    }
}

/* Dark Mode Overrides */
[data-bs-theme="dark"] .modern-header.scrolled .modern-nav {
    background: rgba(20, 20, 30, 0.85);
    /* Dark Glass */
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .modern-menu-link {
    color: rgba(255, 255, 255, 0.85) !important;
}

[data-bs-theme="dark"] .modern-menu-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .modern-btn-icon {
    background: rgba(255, 255, 255, 0.15) !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

[data-bs-theme="dark"] .modern-btn-icon:hover {
    background: rgba(102, 126, 234, 0.3) !important;
    color: #fff !important;
}

@media (max-width: 991.98px) {
    [data-bs-theme="dark"] .modern-nav {
        background: rgba(20, 20, 30, 0.9);
        border-color: rgba(255, 255, 255, 0.08);
    }
}

/* Mobile Panel & Overlay */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-panel {
    position: fixed;
    top: var(--origin-y, 50%);
    left: var(--origin-x, 50%);
    transform: translate(-50%, -50%) scale(0);
    width: 90vw;
    max-width: 500px;
    max-height: 85vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1002;
}

.mobile-panel.active {
    opacity: 1;
    visibility: visible;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
}

[data-bs-theme="dark"] .mobile-panel {
    background: rgba(30, 30, 45, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.mobile-panel-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

[data-bs-theme="dark"] .mobile-panel-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.mobile-panel-body {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.mobile-nav-link {
    padding: 20px 24px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bs-gray-800);
    text-decoration: none;
    border-radius: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
    color: var(--bs-primary);
    background: rgba(102, 126, 234, 0.08);
}

[data-bs-theme="dark"] .mobile-nav-link {
    color: var(--bs-gray-100);
}

[data-bs-theme="dark"] .mobile-nav-link:hover,
[data-bs-theme="dark"] .mobile-nav-link.active {
    color: #fff;
    background: rgba(102, 126, 234, 0.2);
}

.mobile-panel-footer {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] .mobile-panel-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}


/* Theme Icon Logic */
.theme-light-show {
    display: inline-block;
}

.theme-dark-show {
    display: none !important;
}

[data-bs-theme="dark"] .theme-light-show {
    display: none !important;
}

[data-bs-theme="dark"] .theme-dark-show {
    display: inline-block !important;
}

/* View Transition API (Ripple Effect) */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-new(root) {
    z-index: 9999;
}