/* Header Actions Container */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    float: right;
    z-index: 9998;
    position: relative;
}

/* Language Switcher Styles */
.language-switcher {
    position: relative;
    display: inline-block;
    z-index: 9999;
}

.language-toggle {
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-toggle:hover {
    opacity: 0.8;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    min-width: 120px;
    width: 120px;
    overflow: hidden;
    pointer-events: none;
}

/* Adjust dropdown position when Arabic is selected */
body[dir="rtl"] .language-dropdown {
    right: 20px;
}

/* Create invisible bridge between button and dropdown */
.language-dropdown::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 16px;
    background: transparent;
}

/* Arrow pointer */
.language-dropdown::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: none;
    border-right: none;
    transform: rotate(45deg);
}

.language-switcher:hover .language-dropdown,
.language-switcher.active .language-dropdown,
.language-switcher.hover-active .language-dropdown,
.language-switcher.clicked .language-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Improved hover behavior */
.language-switcher {
    transition: all 0.2s ease;
}

.language-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.language-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: transparent;
    border: none;
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    margin: 0;
    z-index: 10000;
    pointer-events: auto;
}

.language-option:first-child {
    border-radius: 12px 12px 0 0;
}

.language-option:last-child {
    border-radius: 0 0 12px 12px;
}

.language-option:only-child {
    border-radius: 12px;
}

.language-option:hover {
    background: linear-gradient(135deg, rgba(77, 85, 245, 0.08) 0%, rgba(77, 85, 245, 0.12) 100%);
    transform: translateX(2px);
}

.language-option.active {
    background: linear-gradient(135deg, rgba(77, 85, 245, 0.15) 0%, rgba(77, 85, 245, 0.2) 100%);
    color: #4D55F5;
    font-weight: 500;
}

.language-option.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #4D55F5;
    border-radius: 0 2px 2px 0;
}

.lang-code {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    transition: color 0.2s ease;
    pointer-events: none;
    cursor: pointer !important;
}

.lang-name {
    font-size: 13px;
    color: #666;
    font-weight: 400;
    transition: color 0.2s ease;
    pointer-events: none;
    cursor: pointer !important;
}

.language-option:hover .lang-code {
    color: #4D55F5;
}

.language-option:hover .lang-name {
    color: #4D55F5;
}

.language-option.active .lang-code,
.language-option.active .lang-name {
    color: #4D55F5;
}

/* RTL Support */
body[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

body[dir="rtl"] .header-actions {
    float: left;
}

body[dir="rtl"] .language-switcher {
    margin-right: 0;
    margin-left: 0;
}

body[dir="rtl"] .language-dropdown {
    right: auto;
    left: 0;
    direction: ltr;
}

body[dir="rtl"] .language-option {
    direction: ltr;
    text-align: left;
}

body[dir="rtl"] .lang-name {
    text-align: left;
}

/* Arabic Font Support */
body[dir="rtl"] {
    font-family: 'Poppins', 'Tajawal', 'Cairo', Arial, sans-serif;
}

body[dir="rtl"] .secondary-font {
    font-family: 'Playfair Display', 'Amiri', 'Scheherazade New', serif;
}

/* RTL Layout Adjustments */
body[dir="rtl"] .button-wrap.right {
    float: left;
}

body[dir="rtl"] .button-wrap.left {
    float: right;
}

body[dir="rtl"] .hero-footer-left {
    float: right;
    text-align: right;
}

body[dir="rtl"] .hero-footer-right {
    float: left;
    text-align: left;
}

/* Hide share section completely in RTL */
body[dir="rtl"] #share.page-action-content {
    display: none;
}

body[dir="rtl"] .footer-middle {
    text-align: center;
}

body[dir="rtl"] .socials-wrap {
    float: left;
}

body[dir="rtl"] #backtotop {
    float: right;
}

/* Header adjustments for RTL */
body[dir="rtl"] #header-container {
    direction: rtl;
}

body[dir="rtl"] #clapat-logo {
    float: right;
}

body[dir="rtl"] .clapat-nav-wrapper {
    float: left;
}

body[dir="rtl"] .header-button {
    margin-left: 0;
    margin-right: 20px;
}

/* Navigation RTL */
body[dir="rtl"] .flexnav li {
    float: right;
}

/* Content RTL adjustments */
body[dir="rtl"] .text-align-center {
    text-align: center;
}

body[dir="rtl"] .pinned-lists {
    text-align: center;
}

/* Hero section RTL adjustments */
body[dir="rtl"] #hero-caption {
    text-align: center;
}

body[dir="rtl"] #hero-caption .inner {
    padding-right: 0;
    margin-right: 0;
}

body[dir="rtl"] .hero-title {
    text-align: right;
}

/* Keep Alpha text centered in both languages */


body[dir="rtl"] .hero-subtitle {
    text-align: center;
    width: 100%;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    direction: rtl;
}

body[dir="rtl"] .hero-subtitle .secondary-font {
    text-align: left;
}

body[dir="rtl"] .hero-subtitle > div {
    text-align: left;
}


/* Project navigation RTL adjustments */
body[dir="rtl"] #next-project-caption {
    text-align: right !important;
}

body[dir="rtl"] .next-caption-wrapper {
    text-align: right;
}

body[dir="rtl"] .next-hero-title {
    text-align: right;
}

body[dir="rtl"] .next-hero-subtitle {
    text-align: right;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .header-actions {
        gap: 10px;
    }
    
    .language-switcher {
        margin-right: 0;
    }
    
    body[dir="rtl"] .language-switcher {
        margin-right: 0;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .language-dropdown {
        min-width: 120px;
    }
    
    .language-option {
        padding: 10px 12px;
    }
    
    .lang-code {
        font-size: 13px;
    }
    
    .lang-name {
        font-size: 12px;
    }
}
