/**
 * Navigation Spacing and Layout Fixes
 * Fixes navigation item cutoff and spacing issues
 */

/* Enhanced header container with better spacing */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    gap: 0.5rem;
    min-height: 60px;
}

/* Logo section with proper constraints */
.header-logo {
    flex-shrink: 0;
    z-index: 1001;
    min-width: 200px;
    max-width: 250px;
}

/* Desktop navigation with proper flex behavior */
.desktop-nav {
    display: none;
    align-items: center;
    flex: 1;
    justify-content: center;
    max-width: calc(100% - 450px);
    overflow: hidden;
}

/* Navigation menu with optimized spacing */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 0.25rem;
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Navigation items with flex-shrink control */
.nav-item {
    margin: 0;
    flex-shrink: 0;
    min-width: 0; /* Allow text truncation if needed */
}

/* Navigation links with optimized padding */
.desktop-nav .nav-link {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    padding: 0.75rem 0.4rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    white-space: nowrap;
    text-align: center;
    min-width: auto;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header actions with proper constraints */
.header-actions {
    display: none;
    gap: 0.5rem;
    flex-shrink: 0;
    min-width: 150px;
    justify-content: flex-end;
}

/* Header buttons with responsive sizing */
.header-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    background: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* Responsive breakpoints for better navigation */

/* Tablet landscape and small desktop */
@media (min-width: 768px) and (max-width: 1023px) {
    .header-container {
        gap: 0.25rem;
        padding: 0 0.75rem;
    }
    
    .header-logo {
        min-width: 180px;
    }
    
    .desktop-nav {
        max-width: calc(100% - 380px);
    }
    
    .desktop-nav .nav-link {
        font-size: 0.8rem;
        padding: 0.75rem 0.3rem;
        max-width: 100px;
    }
    
    .header-actions {
        gap: 0.25rem;
        min-width: 120px;
    }
    
    .header-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        max-width: 120px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .header-container {
        gap: 0.75rem;
    }
    
    .desktop-nav {
        max-width: calc(100% - 500px);
    }
    
    .desktop-nav .nav-link {
        font-size: 0.9rem;
        padding: 0.75rem 0.5rem;
        max-width: 130px;
    }
    
    .header-actions {
        min-width: 180px;
    }
}

/* Large desktop */
@media (min-width: 1200px) {
    .header-container {
        gap: 1rem;
        padding: 0 1.5rem;
    }
    
    .desktop-nav {
        max-width: calc(100% - 550px);
    }
    
    .desktop-nav .nav-link {
        padding: 0.75rem 0.75rem;
        max-width: 150px;
    }
    
    .nav-menu {
        gap: 0.5rem;
    }
    
    .header-actions {
        gap: 0.75rem;
        min-width: 200px;
    }
    
    .header-btn {
        max-width: 160px;
    }
}

/* Extra large screens */
@media (min-width: 1400px) {
    .header-container {
        padding: 0 2rem;
    }
    
    .desktop-nav .nav-link {
        padding: 0.75rem 1rem;
        max-width: none;
    }
    
    .nav-menu {
        gap: 0.75rem;
    }
    
    .header-btn {
        max-width: none;
    }
}

/* Prevent text overflow and ensure readability */
.nav-item .nav-link,
.header-btn {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ensure minimum touch targets for accessibility */
@media (max-width: 1023px) {
    .desktop-nav .nav-link,
    .header-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Fix for very narrow screens */
@media (min-width: 768px) and (max-width: 900px) {
    .header-logo .logo-text {
        display: none;
    }
    
    .header-logo {
        min-width: 120px;
    }
    
    .desktop-nav {
        max-width: calc(100% - 300px);
    }
    
    .desktop-nav .nav-link {
        font-size: 0.75rem;
        padding: 0.75rem 0.25rem;
        max-width: 90px;
    }
    
    .header-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
    }
}

/* Mobile-specific fixes */
@media (max-width: 767px) {
    /* Ensure proper body spacing for mobile with topbar */
    body {
        padding-top: 85px !important; /* Minimal: Topbar (40px) + Header (45px) */
    }
    
    /* Mobile header adjustments */
    .site-header {
        top: 40px !important; /* Position directly below topbar */
        padding: 0.25rem 0 !important; /* Minimal padding to eliminate gap */
        margin-top: 0 !important;
        border-top: none !important;
    }
    
    /* Topbar mobile visibility */
    .topbar {
        display: flex !important;
        height: 40px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1002 !important;
        background: #ED1C24 !important;
    }
    
    /* Mobile header container */
    .header-container {
        padding: 0 0.75rem;
        min-height: 50px;
        gap: 0.5rem;
    }
    
    /* Mobile logo adjustments */
    .header-logo {
        min-width: auto;
        max-width: 200px;
    }
    
    .logo-img {
        height: 28px;
    }
    
    /* Hide desktop navigation on mobile */
    .desktop-nav,
    .header-actions {
        display: none !important;
    }
    
    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex !important;
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        z-index: 1002;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    body {
        padding-top: 100px !important; /* Reduced for small screens */
    }
    
    .topbar {
        height: 35px !important;
    }
    
    .site-header {
        top: 35px !important;
    }
    
    .header-container {
        padding: 0 0.5rem;
        min-height: 45px;
    }
    
    .logo-img {
        height: 24px;
    }
}

/* Desktop styles to ensure proper layout */
@media (min-width: 768px) {
    /* Desktop topbar and header positioning */
    .topbar {
        display: flex !important;
        height: 40px !important;
    }
    
    .site-header {
        top: 40px !important;
    }
    
    body {
        padding-top: 85px !important; /* Desktop: Topbar (40px) + Header (45px) */
    }
    
    /* Show desktop navigation */
    .desktop-nav {
        display: flex !important;
    }
    
    .header-actions {
        display: flex !important;
    }
    
    /* Hide mobile menu on desktop */
    .mobile-menu-btn {
        display: none !important;
    }
}

/* ========================================
   DROPDOWN NAVIGATION STYLES
   ======================================== */

/* Desktop Dropdown Styles */
.nav-item.dropdown {
    position: relative;
}

/* CSS-only hover functionality as fallback */
.nav-item.dropdown:hover .dropdown-menu {
    display: block;
}

.nav-item.dropdown .nav-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-item.dropdown .nav-link i {
    font-size: 0.75em;
    transition: transform 0.3s ease;
}

.nav-item.dropdown:hover .nav-link i,
.nav-item.dropdown .nav-link[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    min-width: 280px;
    padding: 0.5rem 0;
    margin: 0.125rem 0 0;
    font-size: 0.875rem;
    color: #212529;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5rem 1rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    transition: all 0.3s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: #1e2125;
    background-color: #e9ecef;
}

.dropdown-item i {
    margin-right: 0.5rem;
    width: 16px;
    text-align: center;
    color: #6c757d;
}

.dropdown-item:hover i {
    color: #00008b;
}

.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}

/* Mobile Dropdown Styles */
.mobile-nav-item.mobile-dropdown {
    position: relative;
}

.mobile-nav-dropdown {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.mobile-dropdown-toggle {
    background: none;
    border: none;
    color: #fff;
    padding: 0.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.mobile-dropdown-toggle i {
    font-size: 0.875rem;
}

.mobile-dropdown-toggle.active i {
    transform: rotate(180deg);
}

.mobile-submenu {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    overflow: hidden;
}

.mobile-submenu.show {
    display: block;
}

.mobile-submenu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-submenu-link:last-child {
    border-bottom: none;
}

.mobile-submenu-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.mobile-submenu-link i {
    margin-right: 0.75rem;
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
}

/* Responsive adjustments for dropdown */
@media (max-width: 1200px) {
    .dropdown-menu {
        min-width: 250px;
    }
}

@media (max-width: 992px) {
    .dropdown-menu {
        min-width: 220px;
    }
    
    .dropdown-item {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}
