/* Enhanced Header Styles */
#header {
    padding: 10px 30px;
    background: rgba(30, 30, 47, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-color);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    animation: slideDown 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    height: 60px;
    box-sizing: border-box;
}

#header.scroll-header {
    padding: 8px 30px;
    background: rgba(30, 30, 47, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    height: 56px;
    box-sizing: border-box;
}
  
@keyframes slideDown {
    from { 
        transform: translateY(-100%); 
        opacity: 0;
    }
    to { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}
  
.header-title {
    margin-right: 1.5rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    position: relative;
    white-space: nowrap;
    letter-spacing: -0.025em;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

@keyframes glow {
    0% { text-shadow: 0 0 10px var(--shadow-color, rgba(0, 184, 148, 0.3)); }
    100% { text-shadow: 0 0 25px var(--shadow-color, rgba(0, 184, 148, 0.8)); }
}

.header-title::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color) 0%, transparent 100%);
    border-radius: 10px;
    transition: all 0.5s;
}

.header-title:hover::after {
    width: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color, var(--primary-color)) 100%);
    box-shadow: 0 0 15px var(--shadow-color, rgba(0, 184, 148, 0.4));
}
  
/* Fix for RTL layout - ensure title is properly positioned */
html[dir="rtl"] .header-title {
    margin-right: 0;
    margin-left: 40px;
}
  
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
  
/* Header Links and Buttons */
.header-links {
    display: flex;
    gap: 1.8rem;
    align-items: center;
    justify-content: center;
    flex: 1;
}
  
.header-links a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    letter-spacing: -0.025em;
    transition: all 0.3s ease;
    position: relative;
    padding: 0.75rem 0;
}
  
.header-links a:hover {
    color: var(--primary-color);
    transform: translateY(-3px);
    filter: drop-shadow(0 0 15px var(--shadow-color, rgba(0, 184, 148, 0.3)));
}
  
/* Enhanced underline animation for links */
.header-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    transition: width 0.4s ease, left 0.4s ease;
    border-radius: 2px;
}
  
.header-links a:hover::after {
    width: 100%;
    left: 0;
    box-shadow: 0 0 10px var(--shadow-color, rgba(0, 184, 148, 0.3));
}
  
.header-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-left: auto;
    flex-wrap: wrap;
}
  
header nav button, 
.header-buttons a {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    border: 1px solid var(--card-border);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
}
  
header nav button:hover,
.header-buttons a:hover {
    background: var(--primary-color);
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 20px var(--shadow-color, rgba(0, 184, 148, 0.4));
    border-color: transparent;
}
  
/* Improved Hamburger Menu for Mobile */
.menu-icon {
    display: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-color);
    background: transparent;
    border: none;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
}

.menu-icon:hover {
    transform: scale(1.1);
    text-shadow: 0 0 10px var(--shadow-color, rgba(0, 184, 148, 0.4));
}

.menu-icon.active {
    transform: rotate(90deg);
}
  
/* Enhanced mobile menu styles */
@media (max-width: 900px) {
    #header {
        height: 60px;
        padding: 8px 20px;
        flex-wrap: nowrap;
    }
    
    .menu-icon { 
        display: flex; 
        order: 1;
        margin-right: 1rem;
    }
    
    .header-title {
        order: 2;
        flex: 1;
        margin-right: 1rem;
        font-size: 1.1rem; /* Slightly smaller title */
    }
    
    .header-buttons {
        order: 3;
        margin-left: 0;
        gap: 0.2rem; /* Minimal gap for better fit */
        flex-shrink: 0; /* Prevent shrinking */
    }
    
    header nav button, 
    .header-buttons a {
        width: 15px; /* Match hamburger icon size */
        height: 15px; /* Match hamburger icon size */
        font-size: 1rem; /* Smaller font to fit better */
        flex-shrink: 0; /* Prevent shrinking */
    }
    
    .header-links {
        display: none;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 60px;
        background: rgba(var(--background-color-rgb, 0, 0, 0), 0.95);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        padding: 20px;
        border-radius: 0 0 15px 0;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px var(--shadow-color, rgba(0, 184, 148, 0.2));
        animation: menuSlideIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        width: 100%;
        max-width: 280px;
        gap: 15px;
        border-left: 3px solid var(--primary-color);
        z-index: 1002;
        box-sizing: border-box;
    }
    
    html[dir="rtl"] .header-links {
        left: auto;
        right: 0;
        border-left: none;
        border-right: 3px solid var(--primary-color);
        border-radius: 0 0 15px 0;
    }
    
    @keyframes menuSlideIn {
        from { transform: translateY(-20px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
    
    .header-links.active { 
        display: flex; 
    }
    
    .header-title {
        font-size: 1.2rem;
    }
    
    /* Enhanced mobile menu links */
    .header-links a {
        padding: 10px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        width: 100%;
    }
    
    .header-links a:last-child {
        border-bottom: none;
    }
    
    .header-buttons {
        gap: 10px;
    }
    
    header nav button, 
    .header-buttons a {
        width: 2.2rem;
        height: 2.2rem;
        font-size: 0.9rem;
    }
}
  
/* Active navigation indicator */
.header-links a.active-link {
    color: var(--primary-color);
    font-weight: 700;
    text-shadow: 0 0 15px var(--shadow-color, rgba(0, 184, 148, 0.5));
    flex-wrap: wrap;
}
  
.header-links a.active-link::after {
    width: 100%;
    left: 0;
    background: var(--primary-color);
    height: 3px;
    box-shadow: 0 0 10px var(--shadow-color, rgba(0, 184, 148, 0.4));
    flex-wrap: wrap;
}

/* Header background variable calculation - adds RGB variables for opacity support */
:root {
    --header-bg-rgb: 30, 30, 47;
    --background-color-rgb: 30, 30, 47;
}

/* Dark overlay when mobile menu is open */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.menu-overlay.active {
    display: block;
    opacity: 1;
}

/* Enhanced animation for mobile menu toggle */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.menu-icon.active i {
    animation: pulse 1s infinite;
}

@media (max-width: 480px) {
    #header {
        height: 50px;
        padding: 6px 15px;
        flex-wrap: nowrap;
    }
    
    .menu-icon {
        width: 20px;
        height: 20px;
        font-size: 16px;
        margin-right: 0.8rem;
    }
    
    .header-title {
        font-size: 1rem; /* Even smaller for very small screens */
        margin-right: 0.5rem;
        flex: 1;
    }
    
    html[dir="rtl"] .header-title {
        margin-left: 0.5rem;
        margin-right: 0;
    }
    
    .header-buttons {
        gap: 2px; /* Minimal gap for very small screens */
        margin-left: 0;
        flex-shrink: 0; /* Prevent shrinking */
    }
    
    header nav button, 
    .header-buttons a {
        width: 18px; /* Match smaller hamburger icon size */
        height: 18px; /* Match smaller hamburger icon size */
        padding: 0.15rem; /* Even smaller container padding */
        font-size: 0.65rem; /* Smaller font for very small screens */
        flex-shrink: 0; /* Prevent shrinking */
    }
    
    .header-links {
        top: 50px;
        max-width:180px;
        padding: 12px;
    }
}