/*
Theme Name: Al-Maher Bi Al-Quran
Theme URI: https://almaher.academy
Description: Custom Islamic Quran Academy theme with bilingual support
Version: 1.0.0
Author: Al-Maher Academy
Text Domain: almaher
*/

:root {
    --primary-color: #004C54;
    --secondary-color: #D4AF37;
    --accent-color: #6B5B7B;
    --bg-color: #F8F7F2;
    --text-main: #333333;
    --text-light: #777777;
    --white: #FFFFFF;
    --border-color: #E2E8F0;
    --success-color: #48BB78;
    --warning-color: #ED8936;
    --danger-color: #F56565;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Naskh Arabic', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

img {
    max-width: 100%;
    height: auto;
}


/* ==========================================================================
   MASTER PUBLIC FRONTEND MOBILE RESPONSIVE & QUICK ACTION BAR (PHASE 2)
   ========================================================================== */
@media (max-width: 991px) {
    /* Viewport Safety */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    /* Fluid Typography Scaling */
    .hero-title {
        font-size: clamp(1.6rem, 5.5vw, 2.5rem) !important;
        line-height: 1.35 !important;
    }
    .hero-subtitle {
        font-size: clamp(0.95rem, 2.8vw, 1.15rem) !important;
    }
    .hero-card {
        padding: clamp(1.5rem, 5vw, 2.5rem) clamp(1rem, 4vw, 1.8rem) !important;
        margin: 0 10px;
    }
    .hero-cta {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 1rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Header Compact */
    .header {
        padding: 8px 0 !important;
    }
    .header-inner {
        padding: 0 14px !important;
    }
    .nav-trial-btn, .nav-dashboard-btn {
        display: none !important;
    }
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(255,255,255,0.15);
        border-radius: 10px;
        color: #fff;
        font-size: 1.2rem;
        cursor: pointer;
    }

    /* Off-Canvas Slide Drawer */
    .mobile-menu {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        width: 290px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        background: #0B1426 !important;
        border-left: 1px solid rgba(212, 175, 55, 0.3) !important;
        z-index: 999999 !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: -10px 0 35px rgba(0,0,0,0.8) !important;
        padding: 24px 20px !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .mobile-menu.active {
        transform: translateX(0) !important;
    }
    .mobile-menu-backdrop {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(11, 19, 43, 0.75) !important;
        backdrop-filter: blur(4px) !important;
        z-index: 999998 !important;
        display: none;
    }
    .mobile-menu-backdrop.active {
        display: block !important;
    }

    /* Free Trial Modal Bottom Sheet */
    #freeTrialModal {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    #freeTrialModal > div {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 22px 22px 0 0 !important;
        border-bottom: none !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        padding: 24px 18px 24px 18px !important;
        box-shadow: 0 -10px 35px rgba(0,0,0,0.7) !important;
    }

    /* Form Controls Font-size 16px to prevent iOS auto-zoom */
    input, select, textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 768px) {
    /* 2x2 Stats Grid */
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .stat-card {
        padding: 16px 10px !important;
        border-radius: 12px !important;
    }
    .stat-number {
        font-size: 1.4rem !important;
    }
    .stat-label {
        font-size: 0.78rem !important;
    }

    /* Features 1-col */
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    .feature-card {
        padding: 20px 16px !important;
        border-radius: 14px !important;
    }

    /* Mobile Quick Action Sticky Bar */
    .mobile-quick-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(11, 20, 38, 0.95);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(212, 175, 55, 0.3);
        padding: 8px 14px max(8px, env(safe-area-inset-bottom, 8px)) 14px;
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 99990;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }
    .quick-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        color: #fff;
        text-decoration: none;
        font-size: 0.72rem;
        font-weight: 700;
        padding: 6px 12px;
        border-radius: 10px;
        border: none;
        background: transparent;
        cursor: pointer;
        font-family: inherit;
    }
    .quick-btn i {
        font-size: 1.15rem;
    }
    .quick-whatsapp {
        color: #25D366;
    }
    .quick-trial {
        background: linear-gradient(135deg, var(--gold, #d4af37) 0%, #b8860b 100%);
        color: #000 !important;
        padding: 7px 16px;
        border-radius: 20px;
        box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
    }
    .quick-login {
        color: var(--gold, #d4af37);
    }
    body {
        padding-bottom: 70px !important;
    }
}

@media (min-width: 769px) {
    .mobile-quick-action-bar {
        display: none !important;
    }
}


/* Extra Mobile Polish for Billing & Forms */
@media (max-width: 600px) {
    .methods-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    .billing-status-card, .payment-instructions-card, .receipt-upload-card {
        padding: 20px 14px !important;
        border-radius: 12px !important;
    }
}


/* ==========================================================================
   STRICT GLOBAL MOBILE VIEWPORT & LAYOUT RESET (@media (max-width: 991px))
   ========================================================================== */
@media (max-width: 991px) {
    /* 1. منع أي تمرير أفقي عام يسبب زحف الشاشة */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
        display: block !important;
        box-sizing: border-box !important;
    }

    *, *::before, *::after {
        box-sizing: border-box !important;
    }

    /* 2. إلغاء نظام الـ Grid والـ Flex الخاص بالديسكتوب وتحويله إلى Block كامل */
    .dashboard-container,
    .dashboard-wrapper,
    .app-layout,
    .main-layout,
    .admin-wrapper,
    .student-dashboard,
    .teacher-dashboard,
    .supervisor-dashboard,
    .portal-container,
    .layout {
        display: block !important;
        grid-template-columns: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* 3. تصفير الهوامش المحجوزة للقائمة الجانبية لتأخذ المساحة كاملة */
    .main-content,
    .dashboard-content,
    .content-area,
    #admin-content,
    .dashboard-main,
    main.main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px 14px 60px 14px !important;
        box-sizing: border-box !important;
        float: none !important;
        flex-grow: 1 !important;
        overflow-x: hidden !important;
    }

    /* 4. إخراج القائمة الجانبية بالكامل من تدفق الـ DOM لتشغل 0 مساحة عند إغلاقها */
    #admin-sidebar,
    #teacher-sidebar,
    #student-sidebar,
    #supervisor-sidebar,
    .almaher-sidebar,
    .sidebar,
    .sidebar-wrapper,
    aside.sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        max-width: 82vw !important;
        height: 100vh !important;
        background: #111D35 !important;
        border-left: 1px solid rgba(212, 175, 55, 0.3) !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
        z-index: 999999 !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: -5px 0 25px rgba(0,0,0,0.7) !important;
        padding: 20px 16px !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }

    /* إظهار القائمة فقط عند التفعيل */
    #admin-sidebar.active,
    #admin-sidebar.open,
    #teacher-sidebar.active,
    #teacher-sidebar.open,
    #student-sidebar.active,
    #student-sidebar.open,
    #supervisor-sidebar.active,
    #supervisor-sidebar.open,
    .almaher-sidebar.active,
    .almaher-sidebar.open,
    .sidebar.active,
    .sidebar.open,
    aside.sidebar.active,
    aside.sidebar.open {
        transform: translateX(0) !important;
    }

    /* 5. انضباط البطاقات والكروت داخل حدود الشاشة بنسبة 100% */
    .card,
    .stat-card,
    .widget,
    .overview-card,
    .grid-item,
    .panel {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 6. كروت الإحصائيات (2x2 Grid) */
    .stats-grid, .kpi-grid, .overview-cards, .dashboard-stats-grid,
    .grid-4, .grid-3, .stats-row, .kpi-cards-container,
    .cards-grid, .gamification-stats, .badges-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
    }

    /* 7. الجداول (Kinetic Touch) */
    .table-responsive, .table-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box !important;
    }
}


@media (max-width: 991px) {
    .two-cols, .split-cols, .layout-2col {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 16px !important;
    }
    .two-cols > div, .split-cols > div, .layout-2col > div {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 991px) {

    /* ==========================================
       STUDENT SCHEDULE CALENDAR MOBILE OPTIMIZATION
       ========================================== */
    .calendar-navigation {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 12px 14px !important;
        background: var(--surface2, #141f36) !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important;
    }
    .calendar-navigation > div:first-child {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr !important;
        gap: 8px !important;
        width: 100% !important;
    }
    .calendar-navigation > div:first-child button {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
        border-radius: 8px !important;
    }
    #calendar-week-range {
        text-align: center !important;
        justify-content: center !important;
        font-size: 0.88rem !important;
        width: 100% !important;
        color: var(--gold, #d4af37) !important;
    }

    /* Smart Schedule Grid - 1 Column Stack (Saturday to Friday Full Visibility) */
    #smart-schedule-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 12px !important;
        margin-top: 10px !important;
        grid-template-columns: 1fr !important;
    }
    #smart-schedule-grid .day-grid-card {
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
        padding: 14px !important;
        border-radius: 12px !important;
        background: var(--surface2, #141f36) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
    }
    #smart-schedule-grid .day-grid-card .day-events-list {
        max-height: none !important;
        overflow-y: visible !important;
        gap: 8px !important;
    }

}

@media (max-width: 991px) {

    /* ==========================================
       STUDENT NOTIFICATION DROPDOWN MOBILE FIX
       ========================================== */
    .notif-dropdown {
        position: fixed !important;
        top: 70px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: 380px !important;
        margin: 0 auto !important;
        z-index: 99999999 !important;
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.75) !important;
        border: 1px solid rgba(212, 175, 55, 0.35) !important;
        border-radius: 14px !important;
        background-color: var(--surface2, #141f36) !important;
        max-height: 75vh !important;
        overflow-y: auto !important;
    }

}
