/* === MonBac.ma Design Tokens === */
:root {
    --bg: #fafafa;
    --bg-card: #fff;
    --fg: #1a1a2e;
    --fg-secondary: #555;
    --fg-tertiary: #888;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --accent-dark: #1d4ed8;
    --green: #059669;
    --green-light: #d1fae5;
    --coral: #e74c3c;
    --coral-light: #fef2f2;
    --orange: #f59e0b;
    --orange-light: #fef3c7;
    --border: #e5e7eb;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --max-w: 1100px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === NAV === */
.mb-nav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.mb-nav__inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mb-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--fg);
}
.mb-logo__mark {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .9rem;
}
.mb-nav__links { display: flex; gap: 16px; align-items: center; }
.mb-nav__link {
    font-size: .85rem;
    color: var(--fg-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.mb-nav__link:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }

/* === WRAP === */
.mb-wrap {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 32px 20px 60px;
}

/* === HERO === */
.mb-hero {
    text-align: center;
    padding: 48px 20px 40px;
}
.mb-hero__title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800;
    line-height: 1.2;
    color: var(--fg);
    margin-bottom: 12px;
}
.mb-hero__title span { color: var(--accent); }
.mb-hero__sub {
    font-size: 1.05rem;
    color: var(--fg-secondary);
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.7;
}

/* === STATS BAR === */
.mb-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 32px;
}
.mb-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: .82rem;
    color: var(--fg-secondary);
}
.mb-stat b { color: var(--fg); }
.mb-stat--accent { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.mb-stat--accent b { color: var(--accent-dark); }

/* === FILIERE CARDS === */
.mb-filieres {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.mb-filiere {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    transition: border-color .2s, box-shadow .2s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.mb-filiere:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.mb-filiere__icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 1.3rem;
}
.mb-filiere__icon--sm  { background: #dbeafe; color: #2563eb; }
.mb-filiere__icon--pc  { background: #d1fae5; color: #059669; }
.mb-filiere__icon--svt { background: #fef3c7; color: #d97706; }
.mb-filiere__name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.mb-filiere__name-ar {
    font-size: .9rem;
    color: var(--fg-tertiary);
    direction: rtl;
    margin-bottom: 10px;
}
.mb-filiere__meta {
    font-size: .82rem;
    color: var(--fg-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.mb-filiere__count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* === BREADCRUMB === */
.mb-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: .84rem;
    color: var(--fg-tertiary);
    margin-bottom: 24px;
}
.mb-breadcrumb a { color: var(--fg-secondary); }
.mb-breadcrumb__sep { color: var(--border); }

/* === MATIERE LIST === */
.mb-matieres {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.mb-matiere {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
    color: inherit;
    transition: border-color .2s, box-shadow .2s;
}
.mb-matiere:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.mb-matiere__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.mb-matiere__name { font-weight: 600; font-size: .95rem; }
.mb-matiere__count { font-size: .8rem; color: var(--fg-tertiary); }

/* === MATIERE SWITCHER TABS === */
.mb-matiere-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.mb-matiere-tab {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: .84rem;
    font-weight: 600;
    color: var(--fg-secondary);
    background: #fff;
    border: 1.5px solid var(--border);
    text-decoration: none;
    transition: all .15s;
}
.mb-matiere-tab:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.mb-matiere-tab.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* === EXAM TABLE === */
.mb-exam-table {
    width: 100%;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 32px;
}
.mb-exam-table th,
.mb-exam-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}
.mb-exam-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--fg-secondary);
}
.mb-exam-table tr:last-child td { border-bottom: none; }
.mb-exam-table tr:hover td { background: #f8fafc; }

.mb-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
    border: none;
    cursor: pointer;
}
.mb-btn--primary { background: var(--accent); color: #fff; }
.mb-btn--primary:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.mb-btn--outline { background: #fff; border: 1.5px solid var(--border); color: var(--fg-secondary); }
.mb-btn--outline:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.mb-btn--green { background: var(--green); color: #fff; }
.mb-btn--green:hover { background: #047857; text-decoration: none; color: #fff; }

/* === PDF VIEWER === */
.mb-pdf-viewer {
    width: 100%;
    height: 80vh;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.mb-pdf-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
}
.mb-pdf-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.mb-pdf-tab {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--fg-secondary);
    transition: all .15s;
}
.mb-pdf-tab.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.mb-pdf-tab:hover:not(.is-active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* === EXAM DETAIL (tile layout) === */
.mb-exam-detail { text-align: center; padding: 40px 0 20px; }
.mb-exam-detail__title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.mb-exam-detail__sub {
    font-size: .9rem;
    color: var(--fg-secondary);
    margin-bottom: 40px;
}

.mb-tiles {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}
.mb-tile {
    width: 200px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 20px 30px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: all .2s;
    cursor: pointer;
    display: block;
}
.mb-tile:hover {
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.mb-tile--sujet .mb-tile__icon { color: #2563eb; }
.mb-tile--sujet:hover { border-color: #2563eb; }
.mb-tile--corrige .mb-tile__icon { color: #059669; }
.mb-tile--corrige:hover { border-color: #059669; }
.mb-tile--disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}
.mb-tile__icon {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}
.mb-tile__label {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .05em;
    margin-bottom: 6px;
}
.mb-tile__hint {
    font-size: .78rem;
    color: var(--fg-tertiary);
    line-height: 1.4;
}

@media (max-width: 640px) {
    .mb-tiles { gap: 16px; }
    .mb-tile { width: 100%; max-width: 280px; padding: 32px 16px 24px; }
}

/* === LANDING HERO === */
.mb-landing-hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    padding: 80px 20px 60px;
    text-align: center;
}
.mb-landing-hero__inner { max-width: 760px; margin: 0 auto; }
.mb-landing-hero__title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 18px;
    color: #fff;
}
.mb-landing-hero__title span { color: #60a5fa; }
.mb-landing-hero__sub {
    font-size: 1.05rem;
    color: rgba(255,255,255,.75);
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto 28px;
}
.mb-landing-hero__sub strong { color: #fbbf24; }
.mb-landing-hero__cta { margin-bottom: 32px; }
.mb-landing-hero__stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}
.mb-landing-stat {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: .82rem;
    color: rgba(255,255,255,.7);
}
.mb-landing-stat b { color: #fff; font-size: 1.1rem; }
.mb-landing-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: .92rem;
    font-weight: 700;
    text-decoration: none;
    transition: all .2s;
    border: none;
    cursor: pointer;
}
.mb-landing-btn--primary { background: #2563eb; color: #fff; }
.mb-landing-btn--primary:hover { background: #1d4ed8; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(37,99,235,.35); text-decoration: none; color: #fff; }

/* === FEATURES GRID === */
.mb-features { padding: 48px 0 40px; }
.mb-features__title {
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 32px;
}
.mb-features__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 48px;
}
.mb-feature {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
}
.mb-feature h3 { font-size: .95rem; font-weight: 700; margin-bottom: 8px; }
.mb-feature p { font-size: .84rem; color: var(--fg-secondary); line-height: 1.6; }
.mb-feature__icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
.mb-feature__icon--blue   { background: #dbeafe; color: #2563eb; }
.mb-feature__icon--green  { background: #d1fae5; color: #059669; }
.mb-feature__icon--orange { background: #fef3c7; color: #d97706; }
.mb-feature__icon--purple { background: #e9d5ff; color: #7c3aed; }
.mb-feature__icon--red    { background: #fef2f2; color: #dc2626; }
.mb-feature__icon--teal   { background: #ccfbf1; color: #0d9488; }

/* === LANDING FILIERES === */
.mb-landing-filieres { padding: 0 0 40px; }

/* === LANDING CTA === */
.mb-landing-cta {
    text-align: center;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 48px 24px;
    border-radius: var(--radius);
    margin-bottom: 40px;
}
.mb-landing-cta h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 8px; }
.mb-landing-cta p { color: rgba(255,255,255,.7); font-size: .92rem; margin-bottom: 24px; }
.mb-landing-cta .mb-landing-btn--primary { background: #fff; color: #1a1a2e; }
.mb-landing-cta .mb-landing-btn--primary:hover { background: #e5e7eb; box-shadow: 0 8px 24px rgba(0,0,0,.2); color: #1a1a2e; }

/* === SEO BLOCK === */
.mb-seo-block {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    margin-bottom: 32px;
}
.mb-seo-block h2 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.mb-seo-block p { font-size: .88rem; color: var(--fg-secondary); margin-bottom: 12px; line-height: 1.6; }
.mb-seo-block ul { font-size: .86rem; color: var(--fg-secondary); padding-left: 20px; list-style: disc; }
.mb-seo-block li { margin-bottom: 4px; }

/* === ESPACE (member nav) === */
.mb-espace {
    max-width: 820px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}
.mb-espace__header {
    text-align: center;
    padding: 32px 0 28px;
}
.mb-espace__title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.mb-espace__sub {
    font-size: .92rem;
    color: var(--fg-secondary);
}

/* Section per filiere */
.mb-section {
    margin-bottom: 32px;
}
.mb-section__head {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}
.mb-section__kicker {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--fg-tertiary);
    margin-bottom: 4px;
}
.mb-section__title {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 2px;
}
.mb-section__ar {
    font-size: .85rem;
    color: var(--fg-tertiary);
    direction: rtl;
}

/* Color accents per filiere */
.mb-section--blue .mb-section__head  { border-bottom-color: #2563eb; }
.mb-section--blue .mb-section__title { color: #1d4ed8; }
.mb-section--green .mb-section__head  { border-bottom-color: #059669; }
.mb-section--green .mb-section__title { color: #047857; }
.mb-section--orange .mb-section__head  { border-bottom-color: #d97706; }
.mb-section--orange .mb-section__title { color: #b45309; }

.mb-section__grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Tile (row-style like concoursmedecine) */
.mb-espace-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color .2s, box-shadow .2s, transform .15s;
}
.mb-espace-tile:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
    text-decoration: none;
}
.mb-espace-tile__icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.mb-section--blue .mb-espace-tile__icon   { background: #dbeafe; color: #2563eb; }
.mb-section--green .mb-espace-tile__icon  { background: #d1fae5; color: #059669; }
.mb-section--orange .mb-espace-tile__icon { background: #fef3c7; color: #d97706; }

.mb-espace-tile__body { flex: 1; min-width: 0; }
.mb-espace-tile__name { font-weight: 700; font-size: .95rem; margin-bottom: 2px; }
.mb-espace-tile__meta { font-size: .8rem; color: var(--fg-tertiary); margin-bottom: 6px; }
.mb-espace-tile__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mb-espace-tile__chev {
    color: var(--fg-tertiary);
    flex-shrink: 0;
    transition: transform .15s;
}
.mb-espace-tile:hover .mb-espace-tile__chev { transform: translateX(3px); color: var(--accent); }

/* Chips */
.mb-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
}
.mb-chip--coeff  { background: #f0f0f0; color: #555; }
.mb-chip--duree  { background: #f0f0f0; color: #555; }
.mb-chip--free   { background: #dbeafe; color: #1d4ed8; }
.mb-chip--corrige { background: #d1fae5; color: #047857; }

/* Nav active */
.mb-nav__link--active {
    background: var(--accent-light);
    color: var(--accent);
}

/* === FOOTER === */
.mb-footer {
    text-align: center;
    padding: 40px 20px;
    font-size: .82rem;
    color: var(--fg-tertiary);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
    .mb-hero { padding: 32px 12px 28px; }
    .mb-hero__title { font-size: 1.5rem; }
    .mb-filieres { grid-template-columns: 1fr; }
    .mb-matieres { grid-template-columns: 1fr; }
    .mb-nav__links { gap: 8px; }
    .mb-nav__link { font-size: .78rem; padding: 4px 8px; }
    .mb-exam-table th:last-child,
    .mb-exam-table td:last-child { display: none; }
    .mb-pdf-viewer { height: 60vh; }
    .mb-landing-hero { padding: 48px 16px 40px; }
    .mb-features__grid { grid-template-columns: 1fr; }
    .mb-espace-tile__icon { width: 36px; height: 36px; }
    .mb-espace-tile { padding: 14px 16px; gap: 12px; }
    .mb-espace-tile__chips { display: none; }
}
