/* RTL Support for Ghost Dawn Theme - Comprehensive Fix */

html[lang="ar"] {
    direction: rtl;
    text-align: right;
}

html[lang="ar"] body {
    direction: rtl;
}

/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */

/* Reverse the main header flex container */
html[lang="ar"] .gh-head-inner {
    flex-direction: row-reverse;
}

/* Logo positioning */
html[lang="ar"] .gh-head-brand {
    margin-right: 0;
    margin-left: 40px;
}

/* Desktop Menu positioning */
html[lang="ar"] .gh-head-menu {
    margin-left: 0;
    margin-right: auto;
}

/* Actions (Search/Sign in) positioning */
html[lang="ar"] .gh-head-actions {
    margin-left: 0;
    margin-right: 40px;
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* Search icon spacing */
html[lang="ar"] .gh-head-actions .gh-search {
    margin-left: 20px;
    margin-right: 0;
}

/* Desktop Nav Items */
html[lang="ar"] .nav li {
    margin-left: 0;
    margin-right: 32px;
}

html[lang="ar"] .nav li:first-child {
    margin-right: 0;
}

/* ==========================================================================
   MOBILE MENU (The critical part)
   ========================================================================== */

/* The Burger Icon */
html[lang="ar"] .gh-burger {
    margin-left: 0;
    margin-right: 20px;
}

@media (max-width: 991px) {
    
    /* Force header inner to row-reverse on mobile too */
    html[lang="ar"] .gh-head-inner {
        grid-template-columns: 1fr auto 1fr; /* Reset grid if used */
        display: flex;
    }

    /* Logo center/right adjustments */
    html[lang="ar"] .gh-head-brand {
        margin-left: auto;
        margin-right: auto;
        width: auto;
        max-width: 200px;
    }

    /* Burger to the Right */
    html[lang="ar"] .gh-burger {
        position: absolute;
        right: 20px;
        left: auto;
        margin: 0;
        z-index: 9999;
    }

    /* Search to the Left */
    html[lang="ar"] .gh-head-brand .gh-search {
        position: absolute;
        left: 20px;
        right: auto;
        margin: 0;
        display: block;
        z-index: 9998;
    }
    
    /* THE OPEN MENU OVERLAY */
    /* Dawn uses specific positioning for the menu overlay */
    html[lang="ar"] .gh-head-open .gh-head-menu {
        text-align: right;
        align-items: flex-end;
        padding-right: 5vw; 
        padding-left: 0;
    }

    /* Nav items in open menu */
    html[lang="ar"] .gh-head-open .nav {
        align-items: flex-end;
        text-align: right;
        margin-right: 0;
    }

    html[lang="ar"] .gh-head-open .nav li {
        text-align: right;
        margin: 0 0 12px 0;
    }
    
    html[lang="ar"] .gh-head-open .gh-head-actions {
        justify-content: flex-end;
        text-align: right;
        align-items: flex-end;
    }
    
    html[lang="ar"] .gh-head-open .gh-head-actions .gh-head-btn {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        text-align: center;
    }
}

/* ==========================================================================
   CONTENT & OTHER
   ========================================================================== */

/* Article Text */
html[lang="ar"] .gh-content,
html[lang="ar"] .gh-article-header,
html[lang="ar"] .gh-article-excerpt,
html[lang="ar"] .gh-feature-image-caption,
html[lang="ar"] .gh-canvas {
    text-align: right;
}

html[lang="ar"] .gh-article-meta {
    flex-direction: row-reverse;
}

/* Footer */
html[lang="ar"] .gh-foot-inner {
    flex-direction: row-reverse;
}

html[lang="ar"] .gh-foot-menu .nav {
    flex-direction: row-reverse;
}

html[lang="ar"] .gh-copyright {
    text-align: right;
}

/* Forms */
html[lang="ar"] .gh-form-group {
    flex-direction: row-reverse;
}

html[lang="ar"] input,
html[lang="ar"] textarea,
html[lang="ar"] select {
    text-align: right;
    direction: rtl;
}

html[lang="ar"] .gh-portal-trigger-btn {
    margin-left: 0;
    margin-right: 10px;
}

/* Portal / Popup Fix */
html[lang="ar"] #ghost-portal-root iframe {
    left: 0 !important;
    right: 0 !important;
    margin: auto !important;
    position: fixed !important;
}

