/* Navbar block styles */
.navbar-block-content {
    position: relative;
}

/* Vertical alignment support - Higher specificity to override layout styles */
.navbar-block-content.navbar-vertical-down {
    min-height: 300px !important; /* Ensure enough height to see bottom alignment */
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    position: relative !important;
}

.navbar-block-content.navbar-vertical-up {
    min-height: 200px !important; /* Some height to show the top alignment effect */
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    position: relative !important;
}

/* Ensure navbar inside vertical containers behaves properly */
.navbar-vertical-down .navbar,
.navbar-vertical-up .navbar {
    flex-shrink: 0; /* Prevent the navbar from shrinking */
}

/* Override specific layout conflicts for vertical alignments */
.navbar-vertical-down .navbar-layout-logo-center-split,
.navbar-vertical-up .navbar-layout-logo-center-split {
    display: flex !important; /* Override grid display for vertical alignment */
    flex-direction: row !important;
    justify-content: center !important;
}

.navbar-vertical-down .navbar-layout-logo-center-above,
.navbar-vertical-up .navbar-layout-logo-center-above {
    /* Keep flex column but ensure proper alignment */
    align-items: center !important;
}



.navbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    min-height: 50px;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

/* Layout variations */
.navbar-layout-standard {
    /* Default flex layout */
}

.navbar-layout-logo-left-links-right {
    justify-content: space-between !important;
}

.navbar-layout-logo-right-links-left {
    justify-content: space-between !important;
}

/* Text-only layout overrides (when no logo is present) */
.navbar-block-content:not(:has(.navbar-logo-container)) .navbar-layout-logo-left-links-right {
    justify-content: flex-end !important; /* Links Right */
}

.navbar-block-content:not(:has(.navbar-logo-container)) .navbar-layout-logo-right-links-left {
    justify-content: flex-start !important; /* Links Left */
}

.navbar-layout-logo-center-above {
    flex-direction: column;
    gap: var(--spacing-lg);
}

.navbar-layout-logo-center-split {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--spacing-lg);
    align-items: center;
}

/* Logo wrapper for center-above layout */
.navbar-logo-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Links wrapper for center-above layout */
.navbar-links-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Split navigation links */
.nav-links-left {
    justify-content: flex-end;
}

.nav-links-right {
    justify-content: flex-start;
}

/* Spacer for center-split when no logo */
.navbar-spacer {
    width: 100px;
}

.navbar-horizontal {
    flex-direction: row;
}

.navbar-vertical {
    flex-direction: column;
    align-items: flex-start;
}

.nav-link {
    text-decoration: none;
    color: var(--color-text);
    font-weight: 500;
    font-size: var(--font-size-base);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.nav-link:hover {
    /* Hover colors now applied via JavaScript for customization */
    /* Fallback for non-JavaScript environments */
    background: var(--color-hover);
    color: var(--color-blue-accent);
}

.nav-link:focus {
    outline: none;
    background: var(--color-blue-accent-light);
    color: var(--color-blue-accent);
}

.nav-link-current {
    /* Background and color now set via JavaScript for custom colors */
    /* Fallback to default if JavaScript fails */
    background: var(--color-blue-accent);
    color: white;
}

.nav-link-current:hover {
    /* Maintain current color on hover, but slightly darken */
    filter: brightness(0.9);
}

.add-link-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    color: var(--color-text-light);
    font-size: 16px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-link-btn:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: scale(1.1);
}

.navbar-settings-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    color: var(--color-text-light);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.navbar-settings-btn:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
    transform: scale(1.1);
}

/* Vertical navbar styling */
.navbar-vertical .nav-link {
    display: block;
    width: 100%;
    text-align: left;
}

.navbar-vertical .add-link-btn {
    align-self: flex-start;
    margin-top: var(--spacing-sm);
}

/* Navigation links */
.nav-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

/* Logo styles */
.navbar-logo-container {
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--border-radius);
    padding: var(--spacing-xs);
    flex-shrink: 0;
}

.navbar-logo-container:hover {
    background: var(--color-hover);
}

/* Logo layout options */
.navbar-logo-container.logo-layout-horizontal {
    flex-direction: row;
    gap: var(--spacing-sm);
}

.navbar-logo-container.logo-layout-vertical {
    flex-direction: column;
    gap: var(--spacing-xs);
    align-items: center;
}

/* Logo text */
.navbar-logo-text {
    margin: 0;
    outline: none;
    cursor: text;
    transition: all 0.2s ease;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    flex-shrink: 1;
}

.navbar-logo-text:focus {
    background: var(--color-accent-light);
}

.navbar-logo-text:empty:before {
    content: "Your Logo";
    color: var(--color-text-light);
    font-style: italic;
}

/* Logo image wrapper */
.navbar-logo-image-wrapper {
    position: relative;
    display: inline-block;
}

/* Logo image */
.navbar-logo-image {
    width: auto;
    object-fit: contain;
    transition: all 0.2s ease;
    display: block;
    flex-shrink: 0;
}

/* Image placeholder */
.navbar-logo-image-placeholder {
    background: var(--color-bg-secondary);
    border: 2px dashed var(--color-border);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
    min-width: 80px;
    padding: var(--spacing-sm);
}

.navbar-logo-image-placeholder:hover {
    background: var(--color-hover);
    border-color: var(--color-accent);
}

.navbar-logo-image-placeholder .placeholder-icon {
    font-size: 16px;
    color: var(--color-text-light);
}

.navbar-logo-image-placeholder .placeholder-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    text-align: center;
}

/* Change image button overlay */
.navbar-logo-change-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all 0.2s ease;
    opacity: 0;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

.navbar-logo-image-wrapper:hover .navbar-logo-change-btn {
    opacity: 1;
}

.navbar-logo-change-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: translate(-50%, -50%) scale(1.05);
}

/* Darken image on hover when button is shown */
.navbar-logo-image-wrapper:hover .navbar-logo-image {
    filter: brightness(0.7);
}

/* Style Presets */

/* Default style (current) */
.nav-link-default {
    /* Uses base nav-link styles */
}

/* Rounded style */
.nav-link-rounded {
    border-radius: 8px;
    border: 1px solid transparent;
}

/* Pills style */
.nav-link-pills {
    border-radius: 20px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
}

/* Underline style */
.nav-link-underline {
    border-radius: 0;
    border-bottom: 2px solid transparent;
    background: transparent !important; /* Force transparent for underline style */
    padding-bottom: 8px;
}

.nav-link-underline.nav-link-current {
    /* Border color now set via JavaScript for custom active page color */
    /* Fallback to currentColor if JavaScript fails */
    border-bottom-color: currentColor;
}

/* Minimal style */
.nav-link-minimal {
    border-radius: 0;
    background: transparent;
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
}

/* Bordered style */
.nav-link-bordered {
    border: 2px solid var(--color-border);
    border-radius: 4px;
    background: transparent;
}

.nav-link-bordered.nav-link-current {
    border-color: currentColor;
}

/* Note: Hover effects are now handled via JavaScript for custom colors */
/* These styles provide the base structure for each preset */

/* Hamburger menu styles */
.navbar-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 100;
    flex-shrink: 0;
}

/* Three lines style */
.hamburger-lines .hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    margin: 3px 0;
    transition: all 0.3s ease;
}

/* Three dots style */
.hamburger-dots {
    flex-direction: row;
    gap: 4px;
}

.hamburger-dots .hamburger-dot {
    display: block;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
}

/* Arrow style */
.hamburger-arrow .hamburger-arrow {
    font-size: 24px;
    line-height: 1;
}

/* Mobile menu container */
.mobile-menu-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    visibility: hidden;
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.mobile-menu-overlay-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Mobile menu styles */
.navbar-mobile-menu {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    max-width: 80vw;
    height: 100vh;
    background: white;
    transition: transform 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
}

/* Mobile menu states */
.mobile-menu-closed {
    transform: translateX(100%);
    visibility: hidden;
}

.mobile-menu-open {
    transform: translateX(0);
    visibility: visible;
}

/* Slide style (default) */
.mobile-menu-slide {
    /* Default styles above */
}

/* Overlay style */
.mobile-menu-overlay {
    width: 100%;
    max-width: 100%;
}

/* Push style */
.mobile-menu-push.mobile-menu-open ~ .navbar {
    transform: translateX(-300px);
}

/* Mobile menu close button */
.mobile-menu-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    font-size: 30px;
    cursor: pointer;
    z-index: 10;
}

/* Mobile navigation links */
.mobile-nav-links {
    padding: 60px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.mobile-nav-link {
    display: block;
    padding: var(--spacing-md);
    text-decoration: none;
    font-size: 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.mobile-logo {
    margin-bottom: var(--spacing-lg);
    justify-content: center;
}

/* Body class when mobile menu is active */
body.mobile-menu-active {
    overflow: hidden;
}

/* Responsive behavior */
@media (max-width: 768px) {
    /* The hamburger visibility is controlled by JavaScript based on mobileMenuEnabled setting */
    
    /* Responsive layout adjustments */
    .navbar-layout-logo-center-split {
        grid-template-columns: 1fr auto 1fr;
        gap: var(--spacing-md);
    }
    
    /* Layout-specific hamburger positioning */
    
    /* Logo Left, Links Right - logo stays left, hamburger goes right */
    /* (inherits justify-content: space-between from desktop CSS) */
    /* When no logo, hamburger still goes right */
    .navbar-block-content:not(:has(.navbar-logo-container)) .navbar-layout-logo-left-links-right .navbar-hamburger {
        margin-left: auto;
    }
    
    /* Logo Right, Links Left - hamburger goes left, logo stays right */
    /* (inherits justify-content: space-between from desktop CSS) */
    .navbar-layout-logo-right-links-left .navbar-hamburger {
        order: -1; /* Move hamburger to beginning (left) */
    }
    /* When no logo, hamburger still goes left */
    .navbar-block-content:not(:has(.navbar-logo-container)) .navbar-layout-logo-right-links-left .navbar-hamburger {
        margin-right: auto;
        margin-left: 0;
    }
    
    /* Standard - everything centered horizontally */
    .navbar-layout-standard {
        justify-content: center !important;
    }
    .navbar-layout-standard .navbar-hamburger {
        margin-left: var(--spacing-md);
    }
    
    /* Logo Center Above Links - hamburger beside logo in wrapper */
    .navbar-layout-logo-center-above {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: center;
    }
    
    .navbar-layout-logo-center-above .navbar-logo-wrapper {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: var(--spacing-md);
    }
    
    /* Logo Center, Split Links - logo center, hamburger right */
    .navbar-layout-logo-center-split {
        grid-template-columns: 1fr auto auto;
    }
    .navbar-layout-logo-center-split .navbar-hamburger {
        grid-column: 3;
        justify-self: center;
    }
    
    /* Handle vertical navbar styles that force flex layout */
    .navbar-vertical-down .navbar-layout-logo-center-split .navbar-hamburger,
    .navbar-vertical-up .navbar-layout-logo-center-split .navbar-hamburger {
        margin-left: auto;
        grid-column: unset;
        justify-self: unset;
    }
    
    /* Hide desktop nav links on mobile */
    .navbar-layout-logo-center-split .nav-links-right {
        display: none;
    }
    
    /* Ensure logo is visible on mobile */
    .navbar-logo-container {
        position: relative;
        z-index: 1;
    }
    
    .nav-links {
        flex-wrap: wrap;
        gap: var(--spacing-md);
    }
    
    .nav-link {
        font-size: var(--font-size-sm);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    /* Stack navbar when logo is present */
    .navbar:has(.navbar-logo-container) {
        flex-direction: column;
        align-items: center;
        gap: 16px !important; /* Fixed mobile spacing, override dynamic gap */
    }
    
    .navbar-logo-container.logo-layout-horizontal {
        flex-direction: column;
        gap: var(--spacing-xs);
        align-items: center;
    }
    
    .navbar-logo-text {
        /* Keep original font size on mobile */
        max-width: 150px;
    }
    
    .navbar-logo-image {
        /* Keep original height on mobile */
    }
    
    .navbar-logo-image-placeholder {
        min-height: 32px;
        min-width: 60px;
    }
    
    /* Center nav links when logo is stacked above */
    .navbar:has(.navbar-logo-container) .nav-links {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .nav-links {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-sm);
    }
    
    /* Mobile menu takes full width on small screens */
    .navbar-mobile-menu {
        width: 100%;
        max-width: 100%;
    }
}