/* Devlio RTL Stylesheet for Arabic (ar) */
html[dir="rtl"],
body[dir="rtl"],
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Cairo', 'Noto Sans Arabic', Tahoma, sans-serif;
}

/* Fix Arabic Typography: letter-spacing breaks cursive Arabic script */
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] p,
[dir="rtl"] span,
[dir="rtl"] a,
[dir="rtl"] button,
[dir="rtl"] input {
    letter-spacing: normal !important;
}

/* Header & Navbar in RTL */
[dir="rtl"] .navbar .container {
    display: flex;
    align-items: center;
    gap: 20px;
}

@media (min-width: 901px) {
    [dir="rtl"] .nav-brand {
        margin-left: 0;
        margin-right: 0;
        flex-shrink: 0;
    }

    [dir="rtl"] .nav-search {
        min-width: 0;
        flex: 1 1 360px;
        max-width: 480px;
    }

    [dir="rtl"] .search-form input {
        min-width: 0;
    }

    [dir="rtl"] .nav-links {
        margin-right: auto;
        margin-left: 0;
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    [dir="rtl"] .nav-links > a,
    [dir="rtl"] .nav-links .dropdown,
    [dir="rtl"] .lang-switcher-dropdown {
        flex-shrink: 0;
    }
}

@media (max-width: 900px) {
    [dir="rtl"] .navbar .container {
        justify-content: space-between;
    }

    [dir="rtl"] .nav-brand {
        margin-left: auto;
        margin-right: 0;
    }

    [dir="rtl"] .mobile-menu-btn {
        margin-right: 0;
        margin-left: 0;
    }

    [dir="rtl"] .nav-links {
        display: none;
    }

    [dir="rtl"] .nav-links.mobile-open {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px;
        padding: 20px 16px;
    }

    [dir="rtl"] .nav-links.mobile-open > a {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    [dir="rtl"] .nav-links.mobile-open .lang-switcher-dropdown {
        width: 100%;
        justify-content: center;
    }

    [dir="rtl"] .nav-links.mobile-open .lang-btn {
        width: 100%;
        justify-content: center;
    }

    [dir="rtl"] .nav-links.mobile-open .dropdown {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    [dir="rtl"] .nav-links.mobile-open .dropdown-toggle {
        width: 100%;
        justify-content: center;
    }

    [dir="rtl"] .nav-links.mobile-open .notif-toggle {
        margin: 0 auto;
    }
}

/* Directional Chevron / Arrow flip */
.rtl-flip {
    display: inline-block;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

[dir="rtl"] .rtl-flip {
    transform: scaleX(-1);
}

/* Section Header in RTL: naturally space-between (Title on Right, View All on Left) */
[dir="rtl"] .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

[dir="rtl"] .section-header h2 {
    text-align: right;
}

[dir="rtl"] .section-header .view-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Dropdowns & Popups in RTL */
[dir="rtl"] .dropdown-menu,
[dir="rtl"] .notif-dropdown,
[dir="rtl"] .lang-dropdown-menu {
    right: auto !important;
    left: 0 !important;
    text-align: right;
}

[dir="rtl"] .dropdown-toggle {
    text-align: right;
}

[dir="rtl"] .dropdown-menu a,
[dir="rtl"] .dropdown-menu button,
[dir="rtl"] .lang-dropdown-menu a {
    text-align: right;
    justify-content: flex-start;
}

[dir="rtl"] .notif-item {
    text-align: right;
}

[dir="rtl"] .notif-icon {
    margin-right: 0;
    margin-left: 12px;
}

/* Search Form Input & Button in RTL */
[dir="rtl"] .search-form input,
[dir="rtl"] .hero-search-form input {
    text-align: right;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

[dir="rtl"] .search-form button,
[dir="rtl"] .hero-search-form button {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* Creator Card Stats in RTL */
[dir="rtl"] .creator-downloads {
    border-right: none;
    border-left: 1px solid var(--glass-border);
}

/* Card Badges in RTL */
[dir="rtl"] .mp-card-badges {
    left: auto;
    right: 12px;
}

/* Footer in RTL */
[dir="rtl"] .footer-section {
    text-align: right;
}

/* Toast Notifications in RTL */
[dir="rtl"] .toast-container {
    left: 20px;
    right: auto;
}

[dir="rtl"] .alert-dismissible .close-btn {
    left: 12px;
    right: auto;
}


/* Language Switcher Styling */
.lang-switcher-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    background: rgba(12, 32, 64, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.lang-btn:hover {
    background: rgba(18, 50, 100, 0.7);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 200, 255, 0.2);
}

.lang-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: rgba(4, 17, 35, 0.96);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    padding: 6px;
    z-index: 1000;
}

.lang-switcher-dropdown.active .lang-dropdown-menu {
    display: block !important;
    animation: fadeInDown 0.15s ease;
}

.lang-btn svg {
    transition: transform 0.2s ease;
}

.lang-switcher-dropdown.active .lang-btn svg {
    transform: rotate(180deg);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.lang-option:hover {
    background: rgba(0, 200, 255, 0.12);
    color: var(--accent-primary-hover);
}

.lang-option.active {
    background: rgba(0, 200, 255, 0.18);
    color: var(--accent-primary);
    font-weight: 700;
}

.lang-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.flag-img {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
    display: inline-block;
    vertical-align: middle;
}

.lang-label {
    flex: 1;
}

.lang-active-check {
    color: var(--accent-primary);
    font-weight: bold;
}

/* Carousel & Category Sliders in RTL */
[dir="rtl"] .carousel-prev,
[dir="rtl"] .hp-cat-prev {
    left: auto !important;
    right: 8px !important;
}

[dir="rtl"] .carousel-next,
[dir="rtl"] .hp-cat-next {
    right: auto !important;
    left: 8px !important;
}
