/*
Theme Name: Educational Theme
Description: قالب ووردبريس تعليمي مخصص لعرض وتحميل نماذج الامتحانات والفروض، منظم حسب المراحل التعليمية والمستويات الدراسية والمواد.
Version: 1.0
Author: Educational Theme Developer
Text Domain: educational-theme
*/

/* إعادة تعيين الأساسيات */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Tajawal', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    direction: rtl;
    text-align: right;
}

/* متغيرات الألوان */
:root {
    /* Primary blue gradient and core colors */
    --primary-color: #0b6ebd; /* deep blue */
    --primary-gradient-start: #0b6ebd;
    --primary-gradient-end: #0b93d5;
    --secondary-color: #2aa248; /* keep as accent (green) for subject colors if needed */
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-color: #233b57; /* darker neutral text for body */
    --muted-text: #6b7a89;
    --card-bg: #ffffff;
    --card-elevation: rgba(11,110,189,0.06);
    --header-gradient: linear-gradient(180deg, rgba(8,57,102,0.95) 0%, rgba(11,110,189,0.95) 100%);
    --border-color: #e0e0e0;
}

/* الهيدر - تصميم احترافي مركزي */
.site-header {
    background: var(--header-gradient);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 1100;
    box-shadow: 0 8px 28px rgba(7,40,70,0.14);
}

.site-header .container { padding: 0 1.25rem; }

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.9rem 0;
}

/* Force the search toggle to visually appear on the left side (useful in RTL where layout may vary).
   We position it absolutely so it doesn't depend on source order; it's still keyboard-focusable. */
.site-header { position: sticky; }
.site-header .search-btn {
    position: absolute;
    left: 1.25rem; /* visual left */
    top: 50%;
    transform: translateY(-50%);
    z-index: 1150;
}

/* Ensure mobile menu button doesn't collide when search is absolute */
.site-header .mobile-menu-btn { margin-left: 3.25rem; }

.header-left, .header-right { display: flex; align-items: center; gap: 0.6rem; }
.header-center { display: flex; align-items: center; justify-content: center; flex: 1; }

.site-logo .logo-link { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; }
.site-title { font-size: 1.25rem; font-weight: 800; color: #fff; margin: 0; }
.site-tagline { font-size: 0.85rem; color: rgba(255,255,255,0.85); margin: 0; }

.main-navigation .main-menu { list-style: none; display: flex; gap: 1.2rem; margin: 0; padding: 0; }
.main-navigation .main-menu li { position: relative; }
.main-navigation .main-menu a { color: rgba(255,255,255,0.95); text-decoration: none; font-weight: 600; padding: 0.45rem 0.35rem; transition: color 0.18s ease, opacity 0.18s ease; }
.main-navigation .main-menu a:hover { color: var(--light-bg); opacity: 0.95; }

.mobile-menu-btn, .search-btn { background: transparent; border: none; color: rgba(255,255,255,0.95); font-size: 1.05rem; padding: 0.45rem; cursor: pointer; border-radius: 8px; }
.mobile-menu-btn:hover, .search-btn:hover { background: rgba(255,255,255,0.04); }

.search-box { display: none; border-top: 1px solid rgba(255,255,255,0.06); padding: 0.9rem 0; max-width: 1200px; margin: 0 auto; }
.search-box.active { display: block; }
.search-form { display: flex; gap: 0.6rem; }
.search-input { flex: 1; padding: 0.7rem 0.9rem; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.04); color: #fff; }
.search-input::placeholder { color: rgba(255,255,255,0.7); }
.search-submit { padding: 0.6rem 1rem; border-radius: 8px; background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end)); border: none; color: #fff; font-weight: 700; }

.mobile-menu { display: none; }

/* small screens: compact header */
@media (max-width: 900px) {
    .main-navigation { display: none; }
    .mobile-menu-btn { display: inline-flex; }
    .header-top { padding: 0.6rem 0; }
}

@media (max-width: 600px) {
    .search-form { flex-direction: column; }
    .search-input { width: 100%; }
}

/* mobile menu panel */
.mobile-menu {
    display: none;
    background: linear-gradient(180deg, rgba(11,110,189,0.98), rgba(11,147,213,0.95));
    padding: 0.75rem 1rem;
}
.mobile-menu.active { display: block; }
.mobile-menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.mobile-menu-list a { color: #fff; text-decoration: none; padding: 0.6rem 0.4rem; display: block; border-radius: 6px; }
.mobile-menu-list a:hover { background: rgba(255,255,255,0.04); }

/* show main nav on larger screens */
@media (min-width: 901px) {
    .mobile-menu, .mobile-menu-btn { display: none; }
    .main-navigation { display: block; }
}

/* accessible focus states */
.main-navigation .main-menu a:focus, .mobile-menu-list a:focus, .search-btn:focus, .mobile-menu-btn:focus { outline: 3px solid rgba(11,110,189,0.16); outline-offset: 3px; }

/* Breadcrumb styling - consistent across pages */
.breadcrumb { padding: 0.45rem 0; }
.breadcrumb .container { display: flex; }
.breadcrumb-list { display: flex; list-style: none; gap: 0; align-items: center; padding: .4rem .8rem; background: var(--white); border-radius: 8px; margin: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.04); }
.breadcrumb-list li { color: #000; font-size: .95rem; display: inline-flex; align-items: center; }
.breadcrumb-list li a { color: var(--primary-color); text-decoration: none; font-weight: 600; }
.breadcrumb-list li + li::before { content: "›"; margin: 0 .6rem; color: rgba(0,0,0,0.12); }
.breadcrumb-list li[aria-current="page"] span { color: #000; font-weight: 700; }

/* Compact horizontal level header to save vertical space */
.level-header {
    text-align: center !important;
    margin-bottom: 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 1rem !important;
    flex-wrap: wrap !important;
    padding: 0.4rem 0 !important;
}
.level-header .level-number {
    font-size: 2rem !important;
    font-weight: 700 !important;
    color: var(--secondary-color) !important;
    margin-bottom: 0 !important;
    line-height: 1 !important;
}
.level-header .page-title {
    margin: 0 !important;
    font-size: 1.35rem !important;
    font-weight: 700 !important;
    color: var(--text-dark);
}
.level-header .parent-stage {
    margin: 0 !important;
    font-size: 0.98rem !important;
}
    /* Modal for educational ZIP creation */
    .educ-modal { position: fixed; z-index: 12000; left: 0; top: 0; right:0; bottom:0; display:flex; align-items:center; justify-content:center; }
    .educ-modal-backdrop { position:absolute; left:0; top:0; right:0; bottom:0; background:rgba(0,0,0,0.45); }
    .educ-modal-panel { position:relative; z-index:12001; width: 520px; max-width:95%; background:#fff; border-radius:10px; box-shadow:0 10px 40px rgba(0,0,0,0.25); padding:20px; border:1px solid #e6e6e6; }
    .educ-modal-panel h3 { margin:0 0 12px; font-size:18px; }
    .educ-modal-body { display:flex; flex-direction:column; align-items:center; gap:12px; }
    .educ-spinner { width:48px; height:48px; border-radius:50%; border:5px solid #eee; border-top-color: var(--primary-gradient-start, #1976d2); animation:educ-spin 1s linear infinite; }
    @keyframes educ-spin { from { transform:rotate(0deg);} to{ transform:rotate(360deg);} }
    .educ-progress { width:100%; height:10px; background:#f1f3f5; border-radius:6px; overflow:hidden; }
    .educ-progress-bar { height:100%; background:linear-gradient(90deg,var(--primary-gradient-start,#1976d2), var(--primary-gradient-end,#4dabf7)); width:0%; transition:width 400ms ease; }
    .educ-modal-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:12px; }
    .educ-modal-panel p { margin:0; color:#444; }
    .educ-modal a { color:var(--primary-gradient-start,#1976d2); }

    /* Strong override: unify button appearance across level pages and other areas */
    .btn, a.button, .stage-link, .view-subject-btn, .download-btn, .search-submit, .wp-block-button__link {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.55rem !important;
        padding: 0.5rem 1rem !important;
        border-radius: 8px !important;
        font-weight: 700 !important;
        font-size: 0.95rem !important;
        text-decoration: none !important;
        color: #fff !important;
        background: linear-gradient(135deg, var(--primary-gradient-start,#1976d2), var(--primary-gradient-end,#4dabf7)) !important;
        border: none !important;
        box-shadow: 0 6px 18px rgba(7,40,70,0.12);
        transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    }
    .btn:focus, a.button:focus, .view-subject-btn:focus, .download-btn:focus, .wp-block-button__link:focus {
        outline: 3px solid rgba(25,118,210,0.18);
        outline-offset: 2px;
    }
    .btn:hover, a.button:hover, .view-subject-btn:hover, .download-btn:hover, .wp-block-button__link:hover {
        transform: translateY(-3px) !important;
        box-shadow: 0 16px 36px rgba(7,40,70,0.16) !important;
        filter: saturate(1.03);
    }
    .btn[disabled], a.button[disabled], .download-btn[disabled] {
        opacity: 0.6; transform: none; cursor: not-allowed; box-shadow: none;
    }

    /* make block-level buttons full width in card footers on small screens for better touch targets */
    @media (max-width:720px) {
        .subject-card .view-subject-btn, .stage-card .view-subject-btn, .exam-card .download-btn, .wp-block-button__link { width: 100%; }
    }

    /* ensure any earlier green hover in hierarchy is overridden */
    .hierarchy-item .btn:hover { background: linear-gradient(135deg, var(--primary-gradient-start,#1976d2), var(--primary-gradient-end,#4dabf7)) !important; color: #fff !important; }

    /* Make stage buttons match level buttons: same filled-rectangle style
       Buttons will inherit a per-card CSS variable --stage-color when available
       (set inline on the .stage-card element). This allows each card's buttons
       to match the card color without per-card CSS rules. */
    .stage-card { --stage-color: var(--stage-color, var(--primary-gradient-start)); }
    .stage-card .view-subject-btn,
    .stage-card .stage-link {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.55rem !important;
        padding: 0.5rem 1rem !important;
        border-radius: 8px !important;
        font-weight: 700 !important;
        font-size: 0.95rem !important;
        text-decoration: none !important;
        color: #fff !important;
        /* Use the card's --stage-color (fallback to primary start) plus a stable highlight color for the gradient end */
        background: linear-gradient(135deg, var(--stage-color), var(--primary-gradient-end)) !important;
        border: none !important;
        box-shadow: 0 6px 18px rgba(7,40,70,0.12) !important;
        transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    }
    .stage-card .view-subject-btn:hover, .stage-card .stage-link:hover {
        transform: translateY(-3px) !important;
        box-shadow: 0 16px 36px rgba(7,40,70,0.16) !important;
        filter: brightness(0.98);
    }

    @media (max-width:720px) {
        .stage-card .view-subject-btn, .stage-card .stage-link { width: 100%; }
    }

    /* RTL-safe icon spacing inside stage links */
    .stage-card .stage-link i, .stage-card .view-subject-btn i { margin-inline-end: 0.6rem; font-size: 1.05rem; }

/* Custom background for secondary stage cards as requested */
.stage-card.secondary {
    --stage-color: #c06457;
    background: linear-gradient(135deg, #c06457, rgba(255,200,30,0.53)) !important;
    color: #fff !important;
}
.stage-card.secondary .stage-link,
.stage-card.secondary .view-subject-btn {
    background: linear-gradient(135deg, #c06457, rgba(255,200,30,0.53)) !important;
    color: #fff !important;
}

/* Make stage card titles white for contrast */
.stage-card h2 { color: #fff !important; }

/* Styled links inside the homepage overview (SEO) section */
.site-overview {
    color: var(--text-color);
}
.site-overview a {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid rgba(11,110,189,0.10);
    padding-bottom: 2px;
    transition: color 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.site-overview a:hover,
.site-overview a:focus {
    color: var(--primary-gradient-end);
    border-color: rgba(11,110,189,0.3);
    transform: translateY(-1px);
    text-decoration: none;
}

/* Ensure internal blog/stage links are also accessible and clearly visible on light backgrounds */
.site-overview a:visited { color: var(--primary-color); opacity: 0.9; }

    /* Styles for site overview / SEO section on homepage */
    .site-overview { padding: 3rem 0; color: #222; }

    /* User-requested tweaks: download count color, preview button text color, compact numbers */
    .download-count {
        color: #dfdfdf !important;
        font-weight: 600;
        font-size: 0.95rem;
    }

    .preview-btn,
    .preview-btn * {
        color: #ffffff !important;
    }

    /* Slightly tighter number spacing to save horizontal space */
    .download-count, .likes-count {
        display: inline-block;
        min-width: 2.2ch;
        text-align: left;
    }

    /* Homepage - compact recent items (smaller cards and controls) */
    .home .exams-grid, .home .recent-exams {
        display: flex;
        flex-wrap: wrap;
        gap: 0.6rem;
    }
    .home .exams-grid .exam-card, .home .recent-exams .exam-card {
        padding: 0.6rem 0.7rem !important;
        border-radius: 8px !important;
        font-size: 0.92rem !important;
        max-width: 280px !important; /* reduce card width on desktop */
        width: calc(33.333% - 0.6rem) !important; /* 3-up grid */
        box-shadow: 0 6px 18px rgba(7,40,70,0.06) !important;
    }
    .home .exams-grid .exam-card .exam-title { font-size: 1rem; margin-bottom: 0.35rem; }
    .home .exams-grid .exam-card p, .home .exams-grid .exam-card .exam-meta { font-size: 0.82rem; }

    /* Smaller buttons inside compact cards */
    .home .exams-grid .exam-card .btn,
    .home .recent-exams .exam-card .btn {
        padding: 0.28rem 0.55rem !important;
        font-size: 0.82rem !important;
        border-radius: 6px !important;
    }

    /* Make the like button compact: circular icon-only button on homepage to save space */
    .home .exams-grid .exam-card .like-btn,
    .home .recent-exams .exam-card .like-btn {
        padding: 0.28rem !important;
        min-width: 36px !important;
        width: 36px !important;
        height: 36px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: transparent !important;
        box-shadow: none !important;
        color: var(--primary-color) !important;
    }
    .home .exams-grid .exam-card .like-btn i { font-size: 1.05rem !important; color: inherit !important; }
    /* hide the numeric count on the like button in compact view to save space; counts remain visible elsewhere */
    .home .exams-grid .exam-card .like-btn .likes-count,
    .home .recent-exams .exam-card .like-btn .likes-count { display: none !important; }

    /* On small screens use 2-up or full width */
    @media (max-width: 1000px) {
        .home .exams-grid .exam-card, .home .recent-exams .exam-card { width: calc(50% - 0.6rem) !important; }
    }
    @media (max-width: 640px) {
        .home .exams-grid .exam-card, .home .recent-exams .exam-card { width: 100% !important; }
        .home .exams-grid, .home .recent-exams { gap: 0.5rem; }
    }

    /* Bag panel styles */
    .bag-btn { background: transparent; border: none; color: rgba(255,255,255,0.95); font-size: 1.05rem; padding: 0.4rem; cursor: pointer; }
    .bag-btn .bag-count { vertical-align: middle; }
    .bag-panel { position: fixed; right: 1rem; top: 5.5rem; z-index: 13000; width: 360px; max-width: calc(100% - 2rem); background: var(--white); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.18); border: 1px solid var(--border-color); overflow: hidden; }
    .bag-panel-inner { padding: 0.8rem; }
    .bag-panel-header { display:flex; align-items:center; justify-content:space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
    .bag-items { max-height: 48vh; overflow:auto; display:flex; flex-direction:column; gap:8px; }
    .bag-item { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; padding:8px; border-radius:8px; background:var(--light-bg); }
    .bag-item-title { font-weight:700; font-size:0.95rem; }
    .bag-item-source { font-size:0.78rem; color:var(--muted-text); margin-top:4px; }
    .bag-item-actions { display:flex; gap:6px; align-items:center; }
    .bag-item .btn { padding:0.28rem 0.5rem; font-size:0.82rem; }
    .bag-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }
    .bag-panel p.empty { color:var(--muted-text); padding:8px; }

    /* Make bag panel buttons more compact */
    .bag-panel .btn,
    .bag-item .btn,
    .bag-actions .btn {
        padding: 0.18rem 0.42rem !important;
        font-size: 0.78rem !important;
        line-height: 1 !important;
        border-radius: 6px !important;
    }

    /* Reduce visual weight of actions and tighten gaps */

/* Ads: generic slots styling */
.edu-ad-slot { margin: 1.25rem 0; text-align: center; display: block; }
.edu-ad-slot img { max-width: 100%; height: auto; display: inline-block; }
.edu-ad-slot--home_below_stages, .edu-ad-slot--home_below_content { max-width: 1100px; margin-left: auto; margin-right: auto; }
/* Recommended fixed ad footprint matching card size on desktop: 300x250 (pixels).
    The ad will scale down on narrow screens to avoid layout breakage. */
.edu-ad-square { display: block; max-width: 100%; width: 100%; height: auto; box-sizing: border-box; margin: 0 auto; }

/* Place ad as a dedicated full-width row inside grids to avoid overlapping cards.
   The ad will be centered and its inner square will match typical card footprint. */
.stages-grid .edu-ad-slot,
.subjects-grid .edu-ad-slot,
.levels-grid .edu-ad-slot {
    /* behave like a normal grid item (card) — do NOT span multiple columns. */
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: var(--white);
    border-radius: 12px;
    padding: 0.8rem;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 6px 18px rgba(11,110,189,0.06);
    transition: box-shadow 200ms ease, transform 200ms ease;
    overflow: hidden;
}

.stages-grid .edu-ad-slot:hover,
.exams-grid .edu-ad-slot:hover,
.subjects-grid .edu-ad-slot:hover,
.levels-grid .edu-ad-slot:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 30px rgba(11,110,189,0.10);
}

/* Make the ad content (square) fit the card area and be responsive */
.stages-grid .edu-ad-slot .edu-ad-square,
.exams-grid .edu-ad-slot .edu-ad-square,
.subjects-grid .edu-ad-slot .edu-ad-square,
.levels-grid .edu-ad-slot .edu-ad-square {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 250px;
    margin: 0 auto;
}

/* Visible label for ad slots (placed inside HTML for editability) */
.edu-ad-label {
    font-size: 0.78rem;
    color: var(--muted-text);
    margin-bottom: 0.45rem;
    text-align: right; /* RTL */
}

.edu-ad-content { /* ensure ad content doesn't exceed container */
    width: 100%;
}

/* Make media inside ad content responsive */
.edu-ad-content img,
.edu-ad-content iframe,
.edu-ad-content ins,
.edu-ad-content > * {
    max-width: 100%;
    height: auto !important;
    display: block;
}

/* Larger screens: use 970x90 leaderboard where available */
@media (min-width: 1400px) {
    .exams-grid .edu-ad-slot .edu-ad-square {
        width: 970px;
        height: 90px;
    }
}

/* Fallback medium leaderboard on wide but not extra-wide screens */
@media (min-width: 1000px) and (max-width: 1399px) {
    .exams-grid .edu-ad-slot .edu-ad-square {
        width: 720px;
        height: 90px;
    }
}

    /* Place the vertical ad just outside the main centered container (assumed max-width:1200px)
       so it doesn't overlap the grid content. If your container max-width changes adjust the calc values. */
    #edu-vertical-ad[data-pos="left"] {
        left: calc(50% - 600px - 140px); /* 50% - half container - gap */
        right: auto;
    }
    #edu-vertical-ad[data-pos="right"] {
        right: calc(50% - 600px - 140px);
        left: auto;
    }

    /* Ensure vertical ad size is constrained and doesn't overlap on smaller screens */
    #edu-vertical-ad { width: 120px; max-width: 12vw; padding:6px; box-sizing: border-box; }

    @media (max-width: 1100px) {
        /* move vertical ad closer to edge as container shrinks */
        #edu-vertical-ad[data-pos="left"], #edu-vertical-ad[data-pos="right"] { display:none; }
    }

/* On very small screens reduce padding and label size */
@media (max-width: 640px) {
    .stages-grid .edu-ad-slot,
    .exams-grid .edu-ad-slot,
    .subjects-grid .edu-ad-slot,
    .levels-grid .edu-ad-slot {
        padding: 0.6rem;
    }
    .edu-ad-label { font-size: 0.72rem; margin-bottom: 0.35rem; }
}

/* Popup and vertical ad fallbacks - visibility handled by inline CSS injected in functions.php */
/* Ensure popup inner content is readable */
#edu-popup-ad .edu-popup-inner { box-shadow: 0 12px 36px rgba(0,0,0,0.18); }

/* Vertical ad spacing so it doesn't overlap page content on wide screens */
#edu-vertical-ad { padding: 6px; }

    .bag-item-actions { gap:6px; }
    .bag-item { padding:6px; }
    .bag-panel-inner { padding: 0.6rem; }
    .bag-panel { width: 320px; }

    /* Position add-to-bag button at the top-left corner of exam cards */
    .exam-card { position: relative; }
    .exam-card .add-to-bag-btn {
        position: absolute !important;
        top: 10px !important;
        left: 10px !important;
        padding: 0.35rem !important;
        width: 36px !important;
        height: 36px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
        background: rgba(255,255,255,0.95) !important;
        color: var(--primary-color) !important;
        box-shadow: 0 6px 14px rgba(7,40,70,0.06) !important;
        z-index: 30 !important;
    }
    .exam-card .add-to-bag-btn i.fa-plus { font-size: 0.8rem !important; margin-inline-start: 4px; }

    /* On small screens, place button on top-right to match RTL expectations */
    @media (max-width: 640px) {
        .exam-card .add-to-bag-btn { left: auto !important; right: 10px !important; }
    }
    .site-overview .overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; margin-top: 1.25rem; }
    .site-overview .overview-card { background: var(--light-bg); padding: 1.25rem; border-radius: 10px; box-shadow: 0 6px 20px rgba(7,40,70,0.04); border: 1px solid rgba(0,0,0,0.03); }
    .site-overview .overview-card h3 { margin-top: 0; color: var(--primary-color); font-size: 1.05rem; }
    .site-overview .feature-list { margin: 0.5rem 0 0 1rem; color: #333; line-height: 1.6; }
    .site-overview .feature-list li { margin-bottom: 0.45rem; }
    .site-overview .faq-block { margin-top: 1.75rem; }
    .site-overview .faq-item { margin-bottom: 1rem; background: #fff; padding: 0.9rem; border-radius: 8px; border: 1px solid rgba(0,0,0,0.04); }

    @media (max-width:720px) {
        .site-overview .overview-card { padding: 1rem; }
        .site-overview { padding: 2rem 0; }
    }

    /* stage thumbnail inside cards */
    .stage-thumb { width:72px; height:72px; object-fit:cover; border-radius:12px; display:block; margin:0 auto 0.6rem; }

    /* blog listing styles */
    .posts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap:1.25rem; margin-top:1.5rem; }
    .post-card { background: var(--white); border-radius:10px; padding:0.75rem; box-shadow:0 6px 18px rgba(7,40,70,0.06); display:flex; gap:0.75rem; align-items:flex-start; }
    .post-thumb img { width:120px; height:80px; object-fit:cover; border-radius:6px; }
    .post-body { flex:1; }
    .post-title { margin:0 0 0.45rem; font-size:1.05rem; }
    .post-excerpt { color:#555; font-size:0.95rem; margin-bottom:0.6rem; }
    .read-more { display:inline-block; color:var(--primary-color); font-weight:700; }
    .blog-pagination { margin-top:1rem; }
.level-header .level-description {
    font-size: 1rem !important;
    color: var(--text-light) !important;
    max-width: 860px !important;
    margin: 0 auto !important;
}

/* small horizontal accent under level header to visually separate and save space */
.level-header::after {
    content: "";
    display: block;
    width: 72px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-gradient-start), var(--primary-gradient-end));
    border-radius: 4px;
    margin: 0.5rem auto 0;
}

@media (max-width: 640px) {
    .level-header { gap: .5rem !important; padding: .35rem 0 !important; }
    .level-header .level-number { font-size: 1.6rem !important; }
    .level-header .page-title { font-size: 1.1rem !important; }
}

/* Reduce top spacing under header: make first section more compact */
.main-content > section:first-child { padding-top: 1.25rem !important; }
.main-content > section { padding-top: 1.75rem; }

/* Buttons: ensure primary buttons use header/footer gradient and good contrast */
.btn,
.stage-link,
.view-subject-btn,
.download-btn,
.search-submit { display: inline-flex; align-items: center; gap: 0.5rem; background: var(--header-gradient); color: #fff !important; padding: 0.55rem 0.95rem; border-radius: 8px; text-decoration: none; font-weight: 600; border: none; }
.btn i, .download-btn i, .search-submit i { font-size: 1rem; }

.btn:hover, .download-btn:hover, .search-submit:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(7,40,70,0.18); }

/* الحاوي الرئيسي */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* تخطيط الشبكة */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.25rem;
}

/* حاويات البطاقات الرئيسية: مراحل، نماذج، مواد
   تُحوّل العرض إلى شبكة مرنة/متجاوبة بدلاً من تكديس عمودي */
.stages-grid,
.exams-grid,
.subjects-grid {
    display: grid;
    /* 1-col on small, 2 on tablet, 3 on wide screens */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    align-items: stretch;
    margin-top: 1.5rem;
}

/* اجعل البطاقات تملأ الخلية وتصبح عمودية من الداخل ليكون المحتوى مرتباً */
.stages-grid .stage-card,
.exams-grid .exam-card,
.subjects-grid .subject-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}


/* ارتفاع افتراضي بسيط لتوحيد المظهر عند وجود عناوين قصيرة */
.stage-card, .exam-card {
    min-height: 140px;
}

/* البطاقات الأساسية */
.stage-card, .level-card, .subject-card {
    background: var(--white);
    border-radius: 12px;
    /* padding handled by grid child rules to keep consistency */
    text-align: center;
    box-shadow: 0 6px 18px rgba(11,110,189,0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid rgba(0,0,0,0.04);
}

.stage-card:hover, .level-card:hover, .subject-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 30px rgba(11,110,189,0.12);
    border-color: rgba(11,110,189,0.12);
}


/* تصميم خاص لبطاقات المواد */
.subject-card {
    position: relative;
    overflow: hidden;
    /* allow per-subject override via --subject-color (set on .subject-card) */
    border: 2px solid var(--subject-color, var(--border-color));
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-gradient-start), var(--primary-gradient-end));
    z-index: 1;
}


.subject-card .subject-icon {
    font-size: 1.4rem; /* icon font-size */
    width: 40px;
    height: 40px;
    margin: 0 auto 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    /* remove forced background and color so icons use default system/icon color */
    background: transparent;
    color: inherit;
}

.subject-card .subject-icon i {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", sans-serif !important;
    font-weight: 900 !important;
    font-style: normal !important;
    display: inline-block !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
    font-size: 20px;
    color: inherit; /* inherit subject color */
}

.subject-card .subject-title {
    color: #233b57;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.subject-card .exams-count {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.subject-card .subject-description {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.subject-card .view-subject-btn,
.subject-card .subject-link {
    /* unified filled-rectangle style for action links inside subject cards */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.45rem 0.95rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    border: none;
    color: #fff !important;
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end)) !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.subject-card .view-subject-btn:hover,
.subject-card .subject-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(11,110,189,0.12);
}

/* Make links inside level cards match subject-link / view-subject-btn style */
.level-card a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.6rem !important;
    padding: 0.45rem 0.95rem !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    text-decoration: none !important;
    border: none !important;
    color: #fff !important;
    background: linear-gradient(135deg, var(--primary-gradient-start,#1976d2), var(--primary-gradient-end,#4dabf7)) !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.level-card a:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 10px 24px rgba(11,110,189,0.12) !important;
}

@media (max-width:720px) {
    .level-card a { width: 100%; display: inline-flex; }
}

/* ensure any inline background-color set by template (subject_color) does not break the unified style */
.subject-card .subject-link[style] {
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end)) !important;
    color: #fff !important;
}

/* بطاقات المراحل */
.stage-card.primary {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: var(--white);
}

.stage-card.middle {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: var(--white);
}

.stage-card.secondary {
    /* ثانوي - لون برتقالي مميز */
    background: linear-gradient(135deg, #ff7a00, #ffb347);
    color: var(--white);
}

/* Ensure homepage stages grid secondary card uses orange even with inline or other lower-specificity styles */
.stages-grid .stage-card.secondary { background: linear-gradient(135deg, #ff7a00, #ffb347); }

.stage-card h2, .level-card h2, .subject-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Level card title color as requested */
.level-card h2 {
    /* use per-card CSS variable if provided, otherwise fall back to the requested color */
    color: var(--level-color, #2264ad) !important;
    font-weight: 700;
}

/* Responsive tweaks: slightly larger and bolder titles on tablets and mobile for better readability */
@media (max-width: 1024px) and (min-width: 721px) {
    .level-card h2 { font-size: 1.6rem; font-weight: 800; }
}
@media (max-width: 720px) {
    .level-card h2 { font-size: 1.7rem; font-weight: 800; }
}

.stage-card p, .level-card p, .subject-card p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.stage-card a, .level-card a {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    color: inherit;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.level-card a {
    background: var(--secondary-color);
    color: var(--white);
}

.stage-card a:hover, .level-card a:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* صفحة المادة ونظام الفلترة */
.filters-section {
    background: var(--white);
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Restyle filter UI: white bar with black text buttons at top */
.filters-section {
    background: var(--white);
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.filters-section h3 { margin: 0; color: var(--text-dark); font-size: 1rem; font-weight: 700; }
.filter-group { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.filter-label { font-weight: 700; color: #222; margin-right: 0.25rem; }
.filter-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.filter-btn {
    background: #fff;
    color: #000;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.filter-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(11,110,189,0.06); }
.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    color: #fff;
    border-color: transparent;
}

@media (max-width: 640px) {
    .filters-section { padding: 0.5rem; }
    .filter-group { flex-direction: column; align-items: stretch; }
    .filter-buttons { justify-content: flex-start; }
}

.filter-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group label {
    font-weight: bold;
    margin-left: 0.5rem;
}

.filter-group select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    min-width: 150px;
}

/* قائمة النماذج */
.exams-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.exam-card {
    background: var(--white);
    border-radius: 10px;
    /* padding handled by grid child rules */
    box-shadow: 0 4px 14px rgba(11,110,189,0.06);
    transition: transform 0.2s ease;
}

.exam-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(11,110,189,0.10);
}

.exam-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.6rem;
    font-size: 1rem;
}

.exam-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.download-btn {
    background: linear-gradient(135deg, #2ebf7f, #27ae60);
    color: var(--white);
    padding: 0.45rem 0.9rem;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 700;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: inline-block;
    font-size: 0.85rem;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(34,153,84,0.12);
    text-decoration: none;
    color: var(--white);
}

/* الفوتر - تصميم جديد وأنيق */
.site-footer {
    background: var(--header-gradient);
    color: var(--white);
    padding: 2.25rem 0 1.25rem;
    margin-top: 2.5rem;
    font-size: 0.95rem;
}

.site-footer .footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-footer .footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem 2rem;
    align-items: start;
    margin-bottom: 1.25rem;
}

.site-footer .footer-col {
    color: rgba(255,255,255,0.95);
}

.site-footer h3 {
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
    color: #ffffff;
}

.site-footer p { color: rgba(255,255,255,0.85); line-height:1.6; }

.site-footer .social-links {
    margin-top: 0.8rem;
    display: flex;
    gap: 0.6rem;
}

.site-footer .social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: var(--white);
    text-decoration: none;
    transition: transform 0.18s ease, background 0.18s ease;
    font-size: 1rem;
}

/* Stage icon and header styles (stage pages + homepage cards) */
.stage-icon { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 10px; background: linear-gradient(135deg, rgba(11,110,189,0.10), rgba(11,147,213,0.04)); color: var(--primary-color); font-size: 1.6rem; }
.stage-top { display: flex; align-items: center; gap: 1rem; justify-content: center; }
.stage-top .page-title { margin: 0; font-size: 2rem; }
.stages-grid .stage-card .stage-icon { margin: 0 auto 1rem; width: 72px; height: 72px; font-size: 2rem; border-radius: 12px; }

/* ensure FA icons are properly centered and scaled */
.stage-icon i { line-height: 1; }

/* Subject top (icon + title in one row) */
.subject-top { display: flex; align-items: center; gap: 1rem; justify-content: center; }
.subject-top .subject-icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 10px; background: linear-gradient(135deg, rgba(11,110,189,0.08), rgba(11,147,213,0.04)); color: var(--primary-color); font-size: 1.6rem; }
.subject-top .page-title { margin: 0; font-size: 1.8rem; }

/* Reduce vertical spacing around subject header to save space */
.subject-header { margin-bottom: 1.2rem; padding-top: 0.4rem; }
.subject-top .page-title { font-size: 1.6rem; }

.site-footer .social-links a:hover { transform: translateY(-4px); background: rgba(255,255,255,0.12); }

.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer ul li { margin-bottom: 0.5rem; }
.site-footer a { color: rgba(255,255,255,0.92); text-decoration: none; }
.site-footer a:hover { color: var(--light-bg); opacity: 0.95; }

.site-footer .contact-list li { display: flex; gap: 0.6rem; align-items: center; }
.site-footer .contact-list i { width: 20px; text-align: center; color: rgba(255,255,255,0.9); }

.site-footer .footer-stats { margin-top: 1rem; background: rgba(255,255,255,0.05); padding: 0.75rem; border-radius: 8px; }
.site-footer .footer-stats h4 { margin: 0 0 0.5rem 0; color: rgba(255,255,255,0.95); font-size: 0.95rem; }
.site-footer .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; text-align: center; }
.site-footer .stats-grid div { font-size: 0.95rem; color: rgba(255,255,255,0.95); }
.site-footer .stats-grid div strong { display: block; font-size: 1.05rem; }

.site-footer .footer-bottom { border-top: 1px solid rgba(255,255,255,0.06); padding-top: 1rem; }
.site-footer .footer-bottom-inner { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.site-footer .footer-bottom .copyright { color: rgba(255,255,255,0.75); font-size: 0.92rem; }
.site-footer .footer-bottom .dev-note { color: rgba(255,255,255,0.75); font-size: 0.92rem; }
.site-footer .footer-bottom .dev-note .heart { color: #ff6b6b; margin: 0 0.25rem; }

.footer-menu-list { display: flex; list-style: none; gap: 1rem; margin: 0; padding: 0; align-items: center; }
.footer-menu-list li a { color: rgba(255,255,255,0.92); text-decoration: none; font-size: 0.92rem; }
.footer-menu-list li a:hover { color: var(--secondary-color); }

/* back-to-top button */
.back-to-top {
    position: fixed;
    bottom: 1.6rem;
    left: 1.6rem;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: none;
    background: var(--secondary-color);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: all 0.28s ease;
    z-index: 1000;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top:hover { transform: translateY(-4px); background: var(--primary-color); }

@media (max-width: 900px) {
    .site-footer .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
    .site-footer .footer-bottom-inner { justify-content: center; text-align: center; gap: 0.5rem; }
    .footer-menu-list { justify-content: center; flex-wrap: wrap; }
    .site-footer .stats-grid { grid-template-columns: 1fr; }
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 0.6rem;
    }
    
    nav ul {
        flex-direction: column;
        gap: 0.8rem;
        align-items: center;
    }
    
    .grid,
    .stages-grid,
    .exams-grid,
    .subjects-grid,
    .exams-list {
        grid-template-columns: 1fr;
        gap: 0.9rem;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .exam-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .subject-card {
        padding: 0.9rem;
    }
    .subject-card .subject-icon {
        width: 44px;
        height: 44px;
    }
}

/* legacy header/menu styles moved from header.php to central stylesheet */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.main-menu li {
    position: relative;
}

.main-menu a {
    text-decoration: none;
    color: rgba(255,255,255,0.95); /* menu links on header should be white */
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem 0;
    display: block;
}

.main-menu a:hover {
    color: rgba(255,255,255,0.95);
    opacity: 0.9;
}

/* القوائم الفرعية */
.menu-item-has-children .sub-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    border-radius: 5px;
    padding: 1rem;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    list-style: none;
}

.menu-item-has-children:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sub-menu li { margin-bottom: 0.5rem; }
.sub-menu a { padding: 0.5rem; border-radius: 3px; transition: background 0.3s ease; }
.sub-menu a:hover { background: var(--light-bg); }

/* responsive header/menu */
@media (max-width: 768px) {
    .main-navigation { display: none; }
    .mobile-menu-toggle { display: block !important; }
    .header-content { flex-direction: row; justify-content: space-between; align-items: center; }
    .mobile-menu-list { list-style: none; padding: 0; margin: 0; }
    .mobile-menu-list li { border-bottom: 1px solid var(--border-color); padding: 0.5rem 0; }
    .mobile-menu-list a { color: var(--text-dark); text-decoration: none; display: block; padding: 0.5rem; }
}
/* إضافات Font Awesome */
.fa, .fas, .far, .fal, .fab {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", sans-serif !important;
    font-weight: 900 !important;
    font-style: normal !important;
    display: inline-block !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
}

/* تحسينات إضافية للأيقونات */
i.fa, i.fas, i.far, i.fal, i.fab {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", sans-serif !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    line-height: 1 !important;
}

/* دعم اللون الأخضر للأيقونات */
.gradient-icon {
    color: var(--secondary-color);
}

/* فئة عامة لتطبيق اللون الأخضر على النصوص */
.gradient-text {
    color: var(--secondary-color);
}

/* تطبيق اللون الأساسي الأزرق على جميع العناوين الرئيسية */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
}

/* إصلاح التدرج في Safari */
@supports (-webkit-background-clip: text) {
    .gradient-icon {
        background-clip: text;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

/* احتياطي للمتصفحات القديمة */
@supports not (-webkit-background-clip: text) {
    .gradient-icon {
        color: #2aa248;
    }
    
    .gradient-text {
        color: #2aa248;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #2aa248;
    }
    
    body {
        color: #2aa248;
    }
    
    .subject-card .subject-title {
        color: #2aa248;
    }
    
    .exam-card h3 {
        color: #2aa248;
    }
    
    .hierarchy-item h3 {
        color: #2aa248;
    }
}

/* التسلسل الهرمي */
.hierarchy-item {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.hierarchy-item:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.hierarchy-item .icon {
    color: var(--secondary-color);
    font-size: 1.5rem;
    margin-left: 0.5rem;
}

.hierarchy-item .icon i {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", sans-serif !important;
    font-weight: 900 !important;
    font-style: normal !important;
}

.hierarchy-item h3 {
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.hierarchy-item p {
    color: #666;
    margin-bottom: 1rem;
}

.hierarchy-item .btn {
    background: var(--secondary-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.hierarchy-item .btn:hover {
    background: #228a3b;
    text-decoration: none;
    color: var(--white);
}

/* unified full rectangle button style */
.btn,
.stage-link,
.view-subject-btn,
.download-btn,
.search-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--header-gradient);
    color: #fff !important;
    padding: 0.55rem 0.95rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: none;
}
.stage-link:hover,
.view-subject-btn:hover,
.download-btn:hover,
.search-submit:hover,
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(7,40,70,0.18);
}

/* Page content and headings: apply primary gradient accents */
.section-intro .page-title,
.section-title,
h1.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    background: linear-gradient(90deg, var(--primary-gradient-start), var(--primary-gradient-end));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.section-intro p,
.section-desc {
    color: var(--muted-text);
    margin-bottom: 1rem;
}

/* Subject page layout: main content + right sidebar for filters/stats */
.subject-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.25rem;
    align-items: start;
    margin-top: 1rem;
}
.subject-sidebar {
    position: relative;
}

/* make sidebar sticky on larger screens */
@media (min-width: 981px) {
    .subject-sidebar { position: sticky; top: 1.25rem; align-self: start; }
}

/* exam card select checkbox */
.exam-card { position: relative; }
.exam-card .exam-select input.select-exam { width: 18px; height: 18px; }

/* sidebar toolbar small tweaks */
.sidebar-toolbar .filter-btn { padding: 0.4rem 0.6rem; }
.sidebar-toolbar #download-status { display: none; }

@media (max-width: 980px) {
    .subject-layout { grid-template-columns: 1fr; }
    .subject-sidebar { order: 2; }
}

/* Card design refinement (consistent card surface using primary subtle elevation) */
.stage-card, .level-card, .subject-card, .exam-card {
    background: linear-gradient(180deg, var(--card-bg) 0%, #f7fbff 100%);
    border: 1px solid rgba(11,110,189,0.06);
    box-shadow: 0 10px 30px var(--card-elevation);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
}

.stage-card::before, .exam-card::before {
    content: '';
    display: block;
    height: 4px;
    width: 100%;
    margin-bottom: 0.6rem;
    background: linear-gradient(90deg, var(--primary-gradient-start), var(--primary-gradient-end));
    border-radius: 4px;
}

.stage-card h2, .level-card h2, .subject-card .subject-title, .exam-card h3 {
    color: var(--primary-color);
    font-weight: 700;
    margin: 0.45rem 0 0.6rem;
}

.card-meta, .exams-count { color: var(--muted-text); font-size: 0.92rem; }

/* reduce vertical space and make buttons inline */
.subject-card .view-subject-btn, .exam-card .download-btn { margin-top: 0.5rem; }

/* Subject page: compact, unified action buttons (download / preview) */
.exams-grid .exam-card .exam-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.exams-grid .exam-card .exam-actions .download-btn,
.exams-grid .exam-card .exam-actions .preview-btn,
.exams-grid .exam-card .exam-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

/* Primary action: download — use theme header gradient to match footer/header */
.exams-grid .exam-card .exam-actions .download-btn {
    background: var(--header-gradient);
    color: #fff !important;
    box-shadow: 0 8px 18px rgba(11,110,189,0.08);
}
.exams-grid .exam-card .exam-actions .download-btn i { font-size: 0.98rem; }
.exams-grid .exam-card .exam-actions .download-btn:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(11,110,189,0.12); }

/* Secondary action: preview — outlined style to reduce emphasis but keep alignment */
.exams-grid .exam-card .exam-actions .preview-btn {
    background: rgba(255,255,255,0.98);
    color: var(--primary-color) !important;
    border: 1px solid rgba(11,110,189,0.12);
    font-weight: 700;
}
.exams-grid .exam-card .exam-actions .preview-btn i { color: var(--primary-color); }
.exams-grid .exam-card .exam-actions .preview-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(11,110,189,0.06); }

/* ensure spacing when template had inline margins — override safely */
.exams-grid .exam-card .exam-actions .preview-btn[style],
.exams-grid .exam-card .exam-actions .download-btn[style] { margin: 0 !important; }

/* make headings stand out with small accent underline */
.section-title::after, .page-title::after {
    content: '';
    display: block;
    width: 64px;
    height: 4px;
    margin-top: 0.5rem;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary-gradient-start), var(--primary-gradient-end));
}

@media (max-width: 768px) {
    .section-intro .page-title { font-size: 1.3rem; }
    .stage-card, .exam-card { padding: 0.9rem; }
}

/* Compact section title with icon for levels/stages */
.section-title {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    color: var(--primary-color);
    font-weight: 700;
}
.section-title .section-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    color: #fff;
    font-size: 1rem;
}
.section-title .section-text { display: inline-block; }

/* Educational theme inline notices (toasts) */
.edu-notice-wrap {
    position: fixed;
    z-index: 99999;
    right: 1rem;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}
.edu-notice {
    pointer-events: auto;
    min-width: 220px;
    max-width: 420px;
    background: #fff;
    color: #222;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    box-shadow: 0 8px 24px rgba(16,24,40,0.12);
    border-left: 4px solid var(--primary-color, #2264ad);
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform-origin: top right;
    animation: edu-notice-in 260ms ease-out;
}
.edu-notice__icon { font-size: 18px; width: 22px; text-align: center; }
.edu-notice__text { flex: 1; }
.edu-notice__close { cursor: pointer; background: transparent; border: none; color: inherit; font-weight: 700; }

.edu-notice--success { border-left-color: #28a745; background: #f3fff6; }
.edu-notice--error { border-left-color: #dc3545; background: #fff6f6; }
.edu-notice--info { border-left-color: #2264ad; background: #f4f8ff; }

@keyframes edu-notice-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes edu-notice-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

/* small responsive tweak */
@media (max-width: 600px) {
    .edu-notice-wrap { left: 0.6rem; right: 0.6rem; top: 0.6rem; }
    .edu-notice { max-width: calc(100% - 1.2rem); }
}

/* For the exams listing grid we want the ad to occupy a full row under a completed row of cards
   (e.g. 3 cards per row). Make the ad span the grid and center the ad content so it doesn't
   overlap neighboring cards and clearly sits on its own row. */
.exams-grid .edu-ad-slot {
    grid-column: 1 / -1; /* span full row */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.8rem 0;
    background: transparent; /* keep transparent so it reads as an inserted row */
    box-shadow: none;
    border: none;
}

.exams-grid .edu-ad-slot .edu-ad-square {
    /* Horizontal leaderboard above cards: 720x90 on desktop, scale down on smaller viewports */
    width: 720px;
    height: 90px;
    max-width: 100%;
    box-sizing: border-box;
}