/* ===================================================================
   RTL (Right-to-Left) overrides for Arabic language
   Loaded conditionally when lang == 'ar'
   =================================================================== */

/* Smaller hero h1 for Arabic so it fits in fewer lines */
html[dir="rtl"] .hero-left h1 {
    font-size: 2.8rem !important;
    line-height: 1.25 !important;
}

/* ── Global ─────────────────────────────────────────────────────── */
html[dir="rtl"] body {
    font-family: 'Noto Kufi Arabic', 'Inter', 'Segoe UI', Arial, sans-serif;
    text-align: right;
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6 {
    font-family: 'Noto Kufi Arabic', 'Poppins', sans-serif;
}

/* ── Header / Nav ───────────────────────────────────────────────── */
html[dir="rtl"] .site-nav {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-nav .nav-links {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-nav .auth-buttons {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-logo {
    flex-direction: row-reverse;
}

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

html[dir="rtl"] .mobile-nav-link i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* ── Language toggle button ─────────────────────────────────────── */
.nav-btn-lang {
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 6px;
    color: #4f46e5;
    background: transparent;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    white-space: nowrap;
}

.nav-btn-lang:hover {
    background: rgba(79, 70, 229, 0.08);
    border-color: #4f46e5;
}

.nav-btn-lang i {
    font-size: 0.9rem;
}

/* ── Hero ────────────────────────────────────────────────────────── */
html[dir="rtl"] .hero-grid {
    direction: rtl;
}

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

html[dir="rtl"] .hero-trust {
    justify-content: flex-start;
    flex-direction: row-reverse;
}

html[dir="rtl"] .trust-item i {
    margin-left: 0.4rem;
    margin-right: 0;
}

html[dir="rtl"] .hero-pill {
    flex-direction: row-reverse;
}

html[dir="rtl"] .input-group {
    flex-direction: row-reverse;
}

html[dir="rtl"] .input-group input {
    text-align: right;
    border-radius: 0 12px 12px 0;
}

html[dir="rtl"] .input-group button,
html[dir="rtl"] .input-group input[type="submit"] {
    border-radius: 12px 0 0 12px;
}

/* ── Hero floating badges ────────────────────────────────────────── */
html[dir="rtl"] .hero-float.top-right {
    right: auto;
    left: -1.5rem;
}

html[dir="rtl"] .hero-float.bottom-left {
    left: auto;
    right: -1.5rem;
}

/* ── Social Proof ────────────────────────────────────────────────── */
html[dir="rtl"] .social-proof-inner {
    direction: rtl;
}

html[dir="rtl"] .proof-stats {
    flex-direction: row-reverse;
}

/* ── Section titles ──────────────────────────────────────────────── */
html[dir="rtl"] .landing-section-title,
html[dir="rtl"] .landing-section-subtitle {
    text-align: center;
}

/* ── Feature cards ───────────────────────────────────────────────── */
html[dir="rtl"] .feature-card-modern {
    text-align: right;
}

/* ── Showcase blocks ─────────────────────────────────────────────── */
html[dir="rtl"] .showcase-block {
    direction: rtl;
}

html[dir="rtl"] .showcase-block.reverse {
    direction: ltr;
}

html[dir="rtl"] .showcase-block.reverse>* {
    direction: rtl;
}

html[dir="rtl"] .showcase-text {
    text-align: right;
}

html[dir="rtl"] .showcase-highlights {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

html[dir="rtl"] .showcase-highlight i {
    margin-left: 0.4rem;
    margin-right: 0;
}

/* ── CTA ─────────────────────────────────────────────────────────── */
html[dir="rtl"] .cta-btn i {
    margin-right: 0;
    margin-left: 0;
    transform: scaleX(-1);
}

/* ── AI Section ──────────────────────────────────────────────────── */
html[dir="rtl"] .ai-content-grid {
    direction: rtl;
}

html[dir="rtl"] .ai-feature-item {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .ai-feature-icon {
    margin-left: 1rem;
    margin-right: 0;
}

html[dir="rtl"] .ai-feature-text {
    text-align: right;
}

/* ── Pricing ─────────────────────────────────────────────────────── */
html[dir="rtl"] .price-card {
    text-align: right;
}

html[dir="rtl"] .price-card-features li {
    text-align: right;
    padding-right: 0;
    padding-left: 0;
}

html[dir="rtl"] .price-card-features li::before {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* ── Advantages ──────────────────────────────────────────────────── */
html[dir="rtl"] .adv-card {
    text-align: right;
}

html[dir="rtl"] .adv-tags {
    justify-content: flex-start;
}

/* ── FAQ ──────────────────────────────────────────────────────────── */
html[dir="rtl"] .faq-q {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .faq-a-inner {
    text-align: right;
}

/* ── Footer ──────────────────────────────────────────────────────── */
html[dir="rtl"] .footer-top {
    direction: rtl;
}

html[dir="rtl"] .footer-brand {
    text-align: right;
}

html[dir="rtl"] .footer-links-group {
    text-align: right;
}

html[dir="rtl"] .footer-newsletter {
    text-align: right;
}

html[dir="rtl"] .footer-newsletter-form {
    flex-direction: row-reverse;
}

html[dir="rtl"] .footer-bottom {
    flex-direction: row-reverse;
}

html[dir="rtl"] .footer-logo-link {
    flex-direction: row-reverse;
}

/* ── Analysis Sidebar ────────────────────────────────────────────── */
html[dir="rtl"] aside.dash-sidebar {
    left: auto !important;
    right: 0 !important;
}

html[dir="rtl"] .dash-main {
    margin-left: 0 !important;
    margin-right: 260px !important;
}

html[dir="rtl"] .sidebar-link {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .sidebar-link i {
    margin-left: 0.6rem;
    margin-right: 0;
}

html[dir="rtl"] .sidebar-link .nav-score {
    margin-right: auto;
    margin-left: 0;
}

html[dir="rtl"] .sidebar-group-label {
    text-align: right;
    padding-right: 1rem;
    padding-left: 0;
}

html[dir="rtl"] .sidebar-footer a {
    flex-direction: row-reverse;
}

html[dir="rtl"] .sidebar-footer a i {
    margin-left: 0.5rem;
    margin-right: 0;
    transform: scaleX(-1);
}

/* ── Analysis Topbar ─────────────────────────────────────────────── */
html[dir="rtl"] .dash-topbar {
    flex-direction: row-reverse;
}

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

html[dir="rtl"] .topbar-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-btn i {
    margin-left: 0.4rem;
    margin-right: 0;
}

/* ── Analysis Cards & Content ────────────────────────────────────── */
html[dir="rtl"] .dash-content {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .v2-card,
html[dir="rtl"] .metric-card,
html[dir="rtl"] .score-card {
    text-align: right;
}

/* ── Tables ──────────────────────────────────────────────────────── */
html[dir="rtl"] table {
    direction: rtl;
}

html[dir="rtl"] th,
html[dir="rtl"] td {
    text-align: right;
}

/* ── Misc icons next to text ─────────────────────────────────────── */
html[dir="rtl"] .fas,
html[dir="rtl"] .far,
html[dir="rtl"] .fab {
    margin-left: 0.35rem;
    margin-right: 0;
}

/* ── Login / Signup ──────────────────────────────────────────────── */
html[dir="rtl"] .auth-form,
html[dir="rtl"] .login-form,
html[dir="rtl"] .signup-form {
    text-align: right;
}

html[dir="rtl"] .auth-form input,
html[dir="rtl"] .login-form input,
html[dir="rtl"] .signup-form input {
    text-align: right;
}

/* ── Knowledge Base ─────────────────────────────────────────────── */
html[dir="rtl"] .kb-hero,
html[dir="rtl"] .kb-section,
html[dir="rtl"] .kb-cta {
    text-align: center;
}

html[dir="rtl"] .kb-nav-card {
    text-align: center;
}

html[dir="rtl"] .kb-card {
    text-align: right;
}

html[dir="rtl"] .kb-list li {
    padding-left: 0;
    padding-right: 1.25rem;
}

html[dir="rtl"] .kb-list li::before {
    left: auto;
    right: 0;
}

html[dir="rtl"] .kb-tip {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .kb-step {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .kb-intent-item {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .kb-card-icon {
    align-self: flex-end;
}

/* ── Insights ───────────────────────────────────────────────────── */
html[dir="rtl"] .ins-hero {
    text-align: center;
}

html[dir="rtl"] .ins-card-body {
    text-align: right;
}

html[dir="rtl"] .ins-card-link {
    flex-direction: row-reverse;
}

html[dir="rtl"] .ins-card-meta {
    flex-direction: row-reverse;
}

/* ── Competition Analysis ───────────────────────────────────────── */
html[dir="rtl"] .v2-card-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .v2-card-header h3,
html[dir="rtl"] .v2-card-title {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .v2-card-header h3 i,
html[dir="rtl"] .v2-card-title i {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

html[dir="rtl"] .v2-card-body {
    text-align: right;
}

html[dir="rtl"] .v2-rec-item {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .v2-rec-body {
    text-align: right;
}

html[dir="rtl"] .v2-table th {
    text-align: right !important;
}

html[dir="rtl"] .v2-table th:last-child,
html[dir="rtl"] .v2-table td:last-child {
    text-align: left !important;
}

html[dir="rtl"] .v2-metric-row {
    direction: rtl;
}

html[dir="rtl"] .v2-metric-card {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .v2-metric-icon {
    margin-right: 0;
    margin-left: 0.75rem;
}

html[dir="rtl"] .v2-grid-2 {
    direction: rtl;
}

/* ── Search Console ────────────────────────────────────────────── */
html[dir="rtl"] .gsc-tab {
    direction: rtl;
}

html[dir="rtl"] #gscFetchBtn i,
html[dir="rtl"] #btn-generate-trends i {
    margin-right: 0 !important;
    margin-left: 0.4rem !important;
}

/* Flip inline margin-right on icons in card headers for RTL */
html[dir="rtl"] [style*="margin-right:0.5rem"] {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* Table header alignment for RTL */
html[dir="rtl"] table th[style*="text-align:right"] {
    text-align: left !important;
}

html[dir="rtl"] table th[style*="text-align:left"] {
    text-align: right !important;
}

html[dir="rtl"] table td[style*="text-align:right"] {
    text-align: left !important;
}

/* Flex row items: dir="rtl" on <html> already reverses flex layout.
   Do NOT add a blanket flex-direction:row-reverse — it double-reverses. */

/* ── Google Insights ───────────────────────────────────────────── */
html[dir="rtl"] .v2-chart-wrap {
    direction: ltr;
    /* Keep charts LTR */
}

html[dir="rtl"] .v2-task-bar {
    direction: ltr;
    /* Keep progress bars LTR */
}

html[dir="rtl"] .v2-empty-state {
    text-align: right;
}

/* ══════════════════════════════════════════════════════════════════
   RTL MOBILE RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */

/* ── Tablet (1024px) ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    html[dir="rtl"] .hero-left h1 {
        font-size: 2.4rem !important;
    }

    html[dir="rtl"] .showcase-text {
        text-align: center;
    }
}

/* ── Mobile (768px) ──────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Sidebar */
    html[dir="rtl"] aside.dash-sidebar {
        right: -260px !important;
        left: auto !important;
    }

    html[dir="rtl"] aside.dash-sidebar.open {
        right: 0 !important;
    }

    html[dir="rtl"] .dash-main {
        margin-right: 0 !important;
    }

    /* Hero */
    html[dir="rtl"] .hero-left h1 {
        font-size: 2rem !important;
        line-height: 1.3 !important;
    }

    html[dir="rtl"] .hero-subtitle {
        font-size: 0.95rem !important;
    }

    html[dir="rtl"] .hero-left {
        text-align: center;
    }

    html[dir="rtl"] .hero-trust {
        justify-content: center;
        flex-direction: row;
    }

    html[dir="rtl"] .hero-pill {
        font-size: 0.78rem;
    }

    html[dir="rtl"] .input-group {
        flex-direction: column;
    }

    html[dir="rtl"] .input-group input {
        border-radius: 12px !important;
    }

    html[dir="rtl"] .input-group button,
    html[dir="rtl"] .input-group input[type="submit"] {
        border-radius: 12px !important;
        width: 100%;
    }

    /* Section titles */
    html[dir="rtl"] .landing-section-title {
        font-size: 1.7rem !important;
        line-height: 1.35 !important;
    }

    html[dir="rtl"] .landing-section-subtitle {
        font-size: 0.9rem !important;
    }

    /* Feature cards */
    html[dir="rtl"] .feature-card-modern {
        text-align: center;
    }

    /* Showcase */
    html[dir="rtl"] .showcase-text h3 {
        font-size: 1.2rem !important;
    }

    html[dir="rtl"] .showcase-text p {
        font-size: 0.88rem !important;
    }

    /* Pricing */
    html[dir="rtl"] .price-card {
        text-align: center;
    }

    html[dir="rtl"] .price-card-features li {
        text-align: right;
    }

    /* FAQ */
    html[dir="rtl"] .faq-q {
        font-size: 0.9rem;
    }

    /* CTA */
    html[dir="rtl"] .landing-cta h3 {
        font-size: 1.3rem !important;
    }

    html[dir="rtl"] .landing-cta p {
        font-size: 0.9rem !important;
    }

    /* Footer */
    html[dir="rtl"] .footer-newsletter-form {
        flex-direction: column;
    }

    /* Mobile menu */
    html[dir="rtl"] .mobile-dropdown-content {
        text-align: right;
    }

    html[dir="rtl"] .mobile-nav-link {
        flex-direction: row-reverse;
    }

    html[dir="rtl"] .mobile-nav-link.signup,
    html[dir="rtl"] .mobile-nav-link.login {
        flex-direction: row;
        justify-content: center;
    }

    html[dir="rtl"] .mobile-user-info {
        flex-direction: row-reverse;
    }

    html[dir="rtl"] .mobile-user-details {
        text-align: right;
    }

    /* Header: language button + hamburger order */
    html[dir="rtl"] .mobile-rank-now {
        flex-direction: row-reverse;
    }

    /* Analysis topbar */
    html[dir="rtl"] .dash-topbar {
        flex-direction: row-reverse;
    }

    html[dir="rtl"] .sidebar-mobile-toggle {
        margin-right: 0;
        margin-left: 0.5rem;
    }

    /* Analysis section headers */
    html[dir="rtl"] .dash-section-header {
        flex-direction: row-reverse;
    }

    html[dir="rtl"] .dash-section-header h2 {
        font-size: 1rem;
    }

    /* Score cards */
    html[dir="rtl"] .score-card,
    html[dir="rtl"] .metric-card {
        text-align: right;
    }

    /* Analysis history */
    html[dir="rtl"] .history-header {
        text-align: right;
    }

    html[dir="rtl"] .domain-group-header {
        flex-direction: row-reverse;
        flex-wrap: wrap;
    }

    html[dir="rtl"] .analysis-row {
        direction: rtl;
    }

    html[dir="rtl"] .row-info {
        text-align: right;
    }

    /* Knowledge Base & Insights */
    html[dir="rtl"] .kb-hero h1,
    html[dir="rtl"] .ins-hero h1 {
        font-size: 1.8rem !important;
        line-height: 1.35 !important;
    }
}

/* ── Small mobile (480px) ────────────────────────────────────────── */
@media (max-width: 480px) {
    html[dir="rtl"] .hero-left h1 {
        font-size: 1.65rem !important;
        line-height: 1.35 !important;
    }

    html[dir="rtl"] .hero-subtitle {
        font-size: 0.88rem !important;
    }

    html[dir="rtl"] .landing-section-title {
        font-size: 1.35rem !important;
    }

    html[dir="rtl"] .landing-section-subtitle {
        font-size: 0.85rem !important;
    }

    html[dir="rtl"] .showcase-text h3 {
        font-size: 1.05rem !important;
    }

    html[dir="rtl"] .landing-cta h3 {
        font-size: 1.15rem !important;
    }

    html[dir="rtl"] .kb-hero h1,
    html[dir="rtl"] .ins-hero h1 {
        font-size: 1.5rem !important;
    }

    html[dir="rtl"] .history-header-left h1 {
        font-size: 1.1rem !important;
    }
}