/**
 * Mobile Fix CSS — Final Override
 * Fixes: horizontal overflow on hero, footer, content pages, nav pages.
 * Loaded LAST — wins over all other stylesheets.
 */

/* =============================================
   GLOBAL OVERFLOW GUARD
   (non-media-query — applies at all sizes)
   ============================================= */

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
}

/* =============================================
   PAGE SECTIONS — push below the fixed header
   Header is fixed at 60px on mobile.
   Each page section starts at body top=0, so
   we need margin-top = header height.
   ============================================= */

@media (max-width: 768px) {

    /* All pages: hide until .active, full-width */
    .page {
        display: none !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        /* Offset fixed header */
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .page.active {
        display: block !important;
    }

    /* The HERO-containing home page: header offset
     is handled by hero-section padding-top  */
    #page-home {
        /* Do NOT set display:block here — navigation controls it */
        padding-top: 0 !important;
    }

    /* Non-hero pages (reader, dashboard etc.) need explicit top offset */
    .page.active:not(#page-home) {
        padding-top: 60px !important;
    }
}

/* =============================================
   HERO SECTION — MOBILE LAYOUT
   ============================================= */

@media (max-width: 1024px) {

    /* --- Hero wrapper -------------------------------- */
    .hero-section {
        background-attachment: scroll !important;
        padding-top: 80px !important;
        /* 60px header + 20px breathing room */
        padding-bottom: 3rem !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        min-height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* --- Inner grid: single column, full-width full ----- */
    .hero-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: center !important;
        padding: 0 1.25rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 auto !important;
        /* Allow hero to not be wider than viewport */
        min-width: 0 !important;
    }

    /* --- Text block ------------------------------------- */
    .hero-text {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* --- Glass card: hide on tablet/mobile ------------- */
    .hero-visual {
        display: none !important;
    }

    /* --- Floating particles/decorations: hide ---------- */
    .floating-decorations,
    .hero-particles {
        pointer-events: none;
    }

    .floating-decorations {
        display: none !important;
    }

    /* --- Bismillah badge ------------------------------- */
    .bismillah-badge {
        display: inline-block !important;
        max-width: 90% !important;
        margin: 0 auto 1.25rem !important;
        box-sizing: border-box !important;
    }

    .bismillah-text {
        font-size: 1.75rem !important;
    }

    /* --- Heading --------------------------------------- */
    .hero-text h1 {
        font-size: 2.1rem !important;
        line-height: 1.2 !important;
        color: white !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 1rem !important;
    }

    .hero-text h1 span {
        background: linear-gradient(to right, #D4AF37, #F4E4BC, #D4AF37) !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        background-clip: text !important;
    }

    /* --- Paragraph ------------------------------------- */
    .hero-text p {
        font-size: 1rem !important;
        color: rgba(255, 255, 255, 0.92) !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 1.5rem !important;
        line-height: 1.7 !important;
        box-sizing: border-box !important;
    }

    /* --- Buttons --------------------------------------- */
    .hero-buttons {
        display: flex !important;
        justify-content: center !important;
        gap: 0.75rem !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 0 !important;
    }

    .hero-buttons .btn {
        flex: 1 1 140px !important;
        max-width: 210px !important;
        min-width: 0 !important;
        font-size: 0.9rem !important;
        padding: 0.8rem 1rem !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
    }

    /* --- Stats row ------------------------------------- */
    .hero-stats-premium {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 1.25rem !important;
        justify-content: center !important;
        align-items: center !important;
        margin-top: 2rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .stat-item-premium {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.6rem !important;
        min-width: 0 !important;
    }

    .stat-content {
        min-width: 0 !important;
    }

    .stat-icon-wrapper {
        width: 38px !important;
        height: 38px !important;
        font-size: 1rem !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
    }

    .stat-number {
        font-size: 1.5rem !important;
        white-space: nowrap !important;
        display: block !important;
    }

    .stat-label {
        font-size: 0.68rem !important;
        letter-spacing: 1px !important;
        display: block !important;
        white-space: nowrap !important;
    }
}

/* 768px refinements */
@media (max-width: 768px) {

    .hero-section {
        padding-top: 72px !important;
        /* header=60px + 12px */
        padding-bottom: 2.5rem !important;
    }

    .hero-content {
        padding: 0 1rem !important;
        gap: 1.5rem !important;
    }

    .hero-text h1 {
        font-size: 1.8rem !important;
    }

    .hero-buttons {
        flex-direction: column !important;
        align-items: center !important;
    }

    .hero-buttons .btn {
        width: 100% !important;
        max-width: 260px !important;
        flex: none !important;
    }

    .hero-stats-premium {
        gap: 1rem !important;
        margin-top: 1.5rem !important;
    }

    .stat-number {
        font-size: 1.35rem !important;
    }
}

/* 480px refinements */
@media (max-width: 480px) {

    .hero-section {
        padding-top: 68px !important;
        padding-bottom: 2rem !important;
    }

    .hero-content {
        padding: 0 0.875rem !important;
        gap: 1.25rem !important;
    }

    .hero-text h1 {
        font-size: 1.5rem !important;
    }

    .hero-text p {
        font-size: 0.88rem !important;
    }

    .bismillah-text {
        font-size: 1.4rem !important;
    }

    .hero-stats-premium {
        gap: 0.75rem !important;
        margin-top: 1.25rem !important;
    }

    .stat-icon-wrapper {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.9rem !important;
    }

    .stat-number {
        font-size: 1.2rem !important;
    }

    .stat-label {
        font-size: 0.6rem !important;
    }
}

/* =============================================
   FEATURES SECTION — MOBILE
   ============================================= */

@media (max-width: 768px) {

    .section,
    .features-section {
        padding: 2.5rem 1rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 1rem !important;
        box-sizing: border-box !important;
    }

    .section-header {
        margin-bottom: 1.5rem !important;
        padding: 0 !important;
    }

    .section-header h2 {
        font-size: 1.5rem !important;
        word-break: break-word !important;
        color: var(--text-primary, #111827) !important;
    }

    .section-header p {
        font-size: 0.9rem !important;
        color: var(--text-secondary, #4b5563) !important;
    }

    /* Single column grid */
    .features-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .feature-card {
        width: 100% !important;
        padding: 1.5rem 1.25rem !important;
        border-radius: 16px !important;
        text-align: center !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .feature-card h3 {
        font-size: 1rem !important;
        color: var(--text-primary, #111827) !important;
        margin-bottom: 0.4rem !important;
    }

    .feature-card p {
        font-size: 0.875rem !important;
        color: var(--text-secondary, #4b5563) !important;
        line-height: 1.6 !important;
    }

    .feature-icon {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.4rem !important;
        margin: 0 auto 0.875rem !important;
    }
}

@media (max-width: 480px) {

    .section,
    .features-section {
        padding: 2rem 0.75rem !important;
    }

    .container {
        padding: 0 0.75rem !important;
    }

    .feature-card {
        padding: 1.25rem 1rem !important;
    }

    .section-header h2 {
        font-size: 1.3rem !important;
    }
}

/* =============================================
   FOOTER — MOBILE
   ============================================= */

@media (max-width: 768px) {

    .footer {
        padding: 2.5rem 1rem 1.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .footer .container {
        max-width: 100% !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* Override premium-responsive.css 4-col grid */
    .footer-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        text-align: center !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .footer-content>div {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding-right: 0 !important;
        grid-column: 1 !important;
    }

    .footer-brand {
        justify-content: center !important;
    }

    .footer p {
        text-align: center !important;
        max-width: 100% !important;
        word-break: break-word !important;
        font-size: 0.875rem !important;
    }

    .footer-links {
        text-align: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .footer-links h4 {
        font-size: 0.95rem !important;
        margin-bottom: 0.6rem !important;
        text-align: center !important;
    }

    .footer-links a {
        padding: 0.3rem 0 !important;
        display: block !important;
        text-align: center !important;
        word-break: break-word !important;
        font-size: 0.875rem !important;
    }

    .footer-bottom {
        margin-top: 1.5rem !important;
        padding-top: 1rem !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .footer-bottom p {
        text-align: center !important;
        font-size: 0.78rem !important;
        max-width: 100% !important;
        word-break: break-word !important;
    }
}

/* =============================================
   CONTENT PAGES — CARDS, DASHBOARD, ETC.
   ============================================= */

@media (max-width: 768px) {

    /* Generic card */
    .card {
        background: var(--bg-secondary, #fff) !important;
        border: 1px solid var(--border-color, #e5e7eb) !important;
        border-radius: 14px !important;
        padding: 1.25rem !important;
        margin-bottom: 1rem !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .card h2,
    .card h3,
    .card h4 {
        color: var(--text-primary, #111827) !important;
        font-size: 1rem !important;
        margin-bottom: 0.4rem !important;
        word-break: break-word !important;
    }

    .card p {
        color: var(--text-secondary, #4b5563) !important;
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
        margin-bottom: 0 !important;
        word-break: break-word !important;
    }

    /* Dashboard stat cards */
    .stats-cards {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .stat-card {
        padding: 1rem !important;
        text-align: center !important;
        background: var(--bg-secondary, #fff) !important;
        border: 1px solid var(--border-color, #e5e7eb) !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
        box-sizing: border-box !important;
    }

    .stat-card .stat-value,
    .stat-card .stat-info .stat-value {
        font-size: 1.5rem !important;
        font-weight: 700 !important;
        color: var(--primary, #059669) !important;
        display: block !important;
    }

    .stat-card .stat-label,
    .stat-card .stat-info .stat-label {
        font-size: 0.75rem !important;
        color: var(--text-secondary, #4b5563) !important;
    }

    /* Page headers (inside non-hero pages) */
    .page-header {
        padding: 1.5rem 1rem !important;
        border-radius: 14px !important;
        margin-bottom: 1.5rem !important;
        box-sizing: border-box !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .page-header h1 {
        font-size: 1.4rem !important;
        color: white !important;
        margin-bottom: 0.25rem !important;
        word-break: break-word !important;
    }

    .page-header p {
        font-size: 0.875rem !important;
        color: rgba(255, 255, 255, 0.9) !important;
        margin-bottom: 0 !important;
        word-break: break-word !important;
    }

    /* Dashboard */
    .dashboard-container {
        padding: 1rem !important;
        box-sizing: border-box !important;
        width: 100% !important;
    }

    .dashboard-header {
        margin-bottom: 1.25rem !important;
    }

    .dashboard-header h1 {
        font-size: 1.35rem !important;
        color: var(--text-primary, #111827) !important;
        word-break: break-word !important;
    }

    .dashboard-header p {
        font-size: 0.875rem !important;
        color: var(--text-secondary, #4b5563) !important;
    }

    .dashboard-section {
        margin-bottom: 1.5rem !important;
    }

    .dashboard-section h2 {
        font-size: 1.05rem !important;
        font-weight: 600 !important;
        margin-bottom: 0.75rem !important;
        color: var(--text-primary, #111827) !important;
    }
}

@media (max-width: 480px) {

    .stats-cards {
        gap: 0.5rem !important;
    }

    .stat-card {
        padding: 0.75rem 0.5rem !important;
    }

    .stat-card .stat-value,
    .stat-card .stat-info .stat-value {
        font-size: 1.2rem !important;
    }
}

/* =============================================
   NAVIGATION SPAN VISIBILITY
   ============================================= */

@media (max-width: 992px) {
    .nav-links.active .nav-link span {
        display: inline !important;
    }

    .nav-links.active .nav-dropdown-btn span {
        display: inline !important;
    }
}

@media (max-width: 480px) {
    .nav-links:not(.active) {
        display: none !important;
    }

    .nav-links.active {
        display: flex !important;
    }
}

/* =============================================
   DARK MODE — TEXT VISIBILITY
   ============================================= */

[data-theme="dark"] .hero-text h1 {
    color: white !important;
}

[data-theme="dark"] .hero-text p {
    color: rgba(255, 255, 255, 0.9) !important;
}

[data-theme="dark"] .feature-card {
    background: var(--bg-secondary, #1f2937) !important;
}

[data-theme="dark"] .feature-card h3,
[data-theme="dark"] .feature-card p {
    color: var(--text-primary, #f3f4f6) !important;
}

[data-theme="dark"] .card h2,
[data-theme="dark"] .card h3,
[data-theme="dark"] .card p {
    color: var(--text-primary, #f3f4f6) !important;
}

/* =============================================
   TEXT SAFETY — ensure visible colors on mobile
   ============================================= */

@media (max-width: 768px) {

    /* Hero text always white on green background */
    .hero-section h1,
    .hero-section .hero-text h1 {
        color: white !important;
    }

    .hero-section p,
    .hero-section .hero-text p {
        color: rgba(255, 255, 255, 0.92) !important;
    }

    /* Active page headings use theme primary */
    .page.active h1,
    .page.active h2,
    .page.active h3 {
        color: var(--text-primary, #111827);
    }

    .page.active p,
    .page.active li {
        color: var(--text-secondary, #4b5563);
    }
}