/* ============================================================
   DYNAMIC SECTION BUILDER - UNIFIED STYLES
   Premium design system for all section types
   ============================================================ */

:root {
    --section-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --section-font-serif: 'Merriweather', 'Georgia', serif;
    --section-font-mono: 'Fira Code', 'Consolas', monospace;
    --section-radius-sm: 0.5rem;
    --section-radius-md: 0.75rem;
    --section-radius-lg: 1rem;
    --section-radius-xl: 1.25rem;
    --section-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --section-shadow-md: 0 4px 14px rgba(0,0,0,0.1);
    --section-shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --section-primary: #0d6efd;
    --section-primary-dark: #0a58ca;
    --section-secondary: #6c757d;
    --section-success: #198754;
    --section-warning: #ffc107;
    --section-danger: #dc3545;
    --section-info: #0dcaf0;
    --section-dark: #1a1a2e;
    --section-light: #f8f9fa;
    --section-border: #e9ecef;
    --section-text: #4a4a4a;
    --section-text-light: #6c757d;
    --section-bg: #ffffff;
}

/* ─── Container ──────────────────────────────────────────────── */
.dynamic-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.dynamic-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    position: relative;
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Imported HTML/JSON content must remain inside the post column on every
   screen size. These rules also protect older content with inline widths. */
.dynamic-section :where(.row, [class*="col-"]) {
    min-width: 0;
    max-width: 100%;
}

.dynamic-section :where(img, svg, video, iframe, embed, object) {
    display: block;
    max-width: 100% !important;
    height: auto;
}

.dynamic-section :where(iframe, embed, object) {
    width: 100%;
    min-height: 220px;
    border: 0;
}

.dynamic-section :where(table) {
    display: block;
    width: 100% !important;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
}

.dynamic-section :where(th, td) {
    min-width: 7rem;
    overflow-wrap: anywhere;
}

.dynamic-section :where(pre, code) {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.dynamic-section :where(a) {
    overflow-wrap: anywhere;
}

.dynamic-section [style*="width"] {
    max-width: 100% !important;
}

/* The same protection applies to module descriptions and eligibility fields
   rendered outside the dynamic section builder. */
.rich-text-content,
.job-rich-copy,
.post-rich-content {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.rich-text-content :where(img, svg, video, iframe, embed, object),
.job-rich-copy :where(img, svg, video, iframe, embed, object),
.post-rich-content :where(img, svg, video, iframe, embed, object) {
    display: block;
    max-width: 100% !important;
    height: auto;
}

.rich-text-content :where(table),
.job-rich-copy :where(table),
.post-rich-content :where(table) {
    display: block;
    width: 100% !important;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.rich-text-content :where(pre, code),
.job-rich-copy :where(pre, code),
.post-rich-content :where(pre, code) {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 767.98px) {
    .dynamic-sections {
        gap: 1rem;
    }

    .dynamic-section {
        padding-inline: 0;
    }

    .dynamic-section :where(h1, h2, h3, h4, h5, h6) {
        max-width: 100%;
        font-size: clamp(1rem, 5vw, 1.45rem);
        line-height: 1.35;
    }

    .dynamic-section :where(p, li, td, th) {
        font-size: .94rem;
        line-height: 1.7;
    }

    .dynamic-section :where(.card, .card-body, .section-card-premium) {
        max-width: 100%;
        padding: 1rem !important;
    }

    .dynamic-section :where(.row) {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: .75rem;
    }

    .dynamic-section :where(iframe, embed, object) {
        min-height: 180px;
    }
}

/* Admin builder */
.section-builder-wrapper {
    background: #fff;
    border: 1px solid #e6edf5;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, .06);
}

.section-add-menu__panel {
    width: min(360px, 92vw);
    max-height: 520px;
    overflow-y: auto;
}

.section-add-menu__group + .section-add-menu__group {
    border-top: 1px solid #edf2f7;
}

.section-card {
    border-color: #e5ecf4 !important;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .05);
}

.section-card .card-header {
    min-height: 52px;
}

.section-card--featured {
    border-color: #f6c453 !important;
}

.drag-handle {
    cursor: grab;
}

.sortable-drag {
    opacity: .72;
    box-shadow: 0 14px 36px rgba(37, 99, 235, .18);
}

.section-preview {
    max-width: 100%;
    overflow-x: auto;
}

.section-builder-wrapper .ck-editor__editable,
.ck-editor__editable {
    min-height: 220px;
}

.section-builder-wrapper .ck.ck-editor {
    max-width: 100%;
}

.admin-content .ck.ck-editor,
.admin-content .ck.ck-toolbar,
.admin-content .ck-editor__main,
.admin-content .ck-editor__editable {
    position: relative;
    pointer-events: auto;
}

.admin-content .ck.ck-editor {
    z-index: 1;
}

.admin-content .ck.ck-toolbar {
    z-index: 2;
}

.admin-content .ck-editor__editable[contenteditable="true"] {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.section-code-editor {
    min-height: 180px;
    padding: 1rem;
    border-color: #cbd5e1;
    background: #0f172a;
    color: #e2e8f0;
    font: 500 .86rem/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    tab-size: 2;
    resize: vertical;
}

.section-code-editor:focus {
    border-color: #60a5fa;
    background: #0b1220;
    color: #f8fafc;
    box-shadow: 0 0 0 .2rem rgba(59, 130, 246, .2);
}

.admin-editor-plain-fallback {
    display: block !important;
    min-height: 180px;
    pointer-events: auto !important;
    cursor: text;
}

.section-builder-wrapper .ck-content img,
.section-builder-wrapper .ck-content iframe,
.section-builder-wrapper .ck-content video {
    max-width: 100%;
    height: auto;
}

/* ─── Card Base ──────────────────────────────────────────────── */
.section-card-premium {
    background: var(--section-bg);
    border: 1px solid var(--section-border);
    border-radius: var(--section-radius-lg);
    box-shadow: var(--section-shadow-sm);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.section-card-premium:hover {
    box-shadow: var(--section-shadow-md);
    transform: translateY(-2px);
}

/* ─── Headings ───────────────────────────────────────────────── */
.section-heading {
    font-family: var(--section-font-sans);
    font-weight: 700;
    color: var(--section-dark);
    line-height: 1.3;
    margin-bottom: 1rem;
}

.section-heading--h1 { font-size: 2.5rem; }
.section-heading--h2 { font-size: 2rem; }
.section-heading--h3 { font-size: 1.75rem; }
.section-heading--h4 { font-size: 1.5rem; }
.section-heading--h5 { font-size: 1.25rem; }
.section-heading--h6 { font-size: 1.1rem; }

.section-heading__accent {
    display: inline-block;
    border-left: 4px solid var(--section-primary);
    padding-left: 1rem;
}

/* ─── Rich Text / HTML ───────────────────────────────────────── */
.section-rich-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--section-text);
}

.section-rich-text h2 { font-size: 1.75rem; margin-top: 2rem; margin-bottom: 1rem; color: var(--section-dark); }
.section-rich-text h3 { font-size: 1.5rem; margin-top: 1.75rem; margin-bottom: 0.875rem; color: var(--section-dark); }
.section-rich-text h4 { font-size: 1.25rem; margin-top: 1.5rem; margin-bottom: 0.75rem; color: var(--section-dark); }
.section-rich-text p { margin-bottom: 1rem; }
.section-rich-text a { color: var(--section-primary); text-decoration: underline; }
.section-rich-text a:hover { color: var(--section-primary-dark); }

.section-rich-text blockquote {
    border-left: 4px solid var(--section-primary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
}

/* ============================================================
   SECTION TEXT - JUSTIFIED ALIGNMENT (desktop + mobile)
   Applies justify to all section & overview text while keeping
   headings, buttons, badges, and centered/right-aligned
   elements intact.
   ============================================================ */

/* Dynamic rich-html / rich-text content */
.section-rich-html-scope,
.section-rich-html,
.section-rich-text,
.section-rich-html .rich-text-content,
.section-rich-text .rich-text-content {
    text-align: justify;
    text-justify: inter-word;
}

/* Ensure paragraphs, lists, and blockquotes in rich content are justified */
.section-rich-html p,
.section-rich-text p,
.section-rich-html li,
.section-rich-text li,
.section-rich-html blockquote,
.section-rich-text blockquote {
    text-align: justify;
    text-justify: inter-word;
}

/* Paragraph section type */
.section-paragraph {
    text-align: justify;
    text-justify: inter-word;
}

/* Quote section type */
.section-quote blockquote {
    text-align: justify;
    text-justify: inter-word;
}

/* Accordion + FAQ section types (bodies hold rich HTML) */
.section-accordion .accordion-body,
.section-faq .accordion-body,
.section-accordion .accordion-body p,
.section-faq .accordion-body p,
.section-accordion .accordion-body li,
.section-faq .accordion-body li {
    text-align: justify;
    text-justify: inter-word;
}

/* Descriptive text inside other structured section types */
.section-timeline p,
.section-cards p,
.section-icon-list p,
.section-feature-grid p,
.section-notice p,
.section-info-box p,
.section-eligibility p,
.section-steps p,
.section-checklist p,
.section-tabs p,
.section-columns p,
.section-comparison-table p,
.section-cta p,
.section-alert-box p,
.section-download-box p,
.section-important-dates p,
.section-hero-block p,
.section-button-group p,
.section-related-posts p,
.section-latest-posts p,
.section-hero-block .lead,
.section-cards .card-text,
.section-comparison-table td {
    text-align: justify;
    text-justify: inter-word;
}

/* "Other sections" text rendered on detail pages (overview etc.) */
.rich-text-content,
.rich-text-content p,
.rich-text-content li,
.rich-text-content blockquote,
.accordion-body,
.accordion-body p,
.accordion-body li {
    text-align: justify;
    text-justify: inter-word;
}

/* Keep headings, buttons, badges, and explicitly aligned elements readable */
.dynamic-section .section-heading,
.dynamic-section h1, .dynamic-section h2,
.dynamic-section h3, .dynamic-section h4,
.dynamic-section h5, .dynamic-section h6,
.section-rich-html h1, .section-rich-html h2,
.section-rich-html h3, .section-rich-html h4,
.section-rich-html h5, .section-rich-html h6,
.section-rich-text h1, .section-rich-text h2,
.section-rich-text h3, .section-rich-text h4,
.section-rich-text h5, .section-rich-text h6,
.btn, .btn a, .badge, .breadcrumb,
.section-heading__accent {
    text-align: inherit;
}
.section-rich-html .text-center,
.section-rich-html .text-center *,
.section-rich-html .text-end,
.section-rich-html .text-end *,
.rich-text-content .text-center,
.rich-text-content .text-center *,
.rich-text-content .text-end,
.rich-text-content .text-end * {
    text-align: left;
}
.section-rich-html .text-center,
.rich-text-content .text-center {
    text-align: center !important;
}
.section-rich-html .text-end,
.rich-text-content .text-end {
    text-align: right !important;
}

/* ============================================================
   PUBLIC DYNAMIC SECTIONS — PREMIUM CONTENT SYSTEM
   Shared by Jobs, Results, Admit Cards, Answer Keys, Syllabus,
   Admissions, Study Notes, Exam Calendar and related public modules.
   ============================================================ */
.dynamic-sections {
    --dynamic-ink: #172b4d;
    --dynamic-copy: #465a73;
    --dynamic-line: #dce6f2;
    --dynamic-soft: #f5f8fd;
    --dynamic-brand: #2563eb;
    --dynamic-radius: 20px;
    gap: 1.35rem;
}

.dynamic-sections > .dynamic-section {
    scroll-margin-top: calc(var(--gnu-sticky-offset, 76px) + 1.25rem);
}

.dynamic-sections > .dynamic-section :where(h2, h3, h4, h5) {
    color: var(--dynamic-ink);
    font-weight: 800;
    letter-spacing: -.015em;
    line-height: 1.28;
}

.dynamic-sections > .dynamic-section :where(p, li) {
    color: var(--dynamic-copy);
    line-height: 1.8;
}

.dynamic-sections > .dynamic-section :where(a:not(.btn)) {
    color: #1d4ed8;
    font-weight: 700;
    text-decoration-color: rgba(29, 78, 216, .35);
    text-underline-offset: .16em;
}

.dynamic-section--rich-html,
.dynamic-section--paragraph,
.dynamic-section--quote,
.dynamic-section--table,
.dynamic-section--important-dates,
.dynamic-section--eligibility,
.dynamic-section--steps,
.dynamic-section--checklist,
.dynamic-section--accordion,
.dynamic-section--faq,
.dynamic-section--cards,
.dynamic-section--feature-grid,
.dynamic-section--icon-list,
.dynamic-section--timeline,
.dynamic-section--button-group,
.dynamic-section--download-box,
.dynamic-section--notice,
.dynamic-section--alert-box {
    padding: clamp(1rem, 2.3vw, 1.8rem);
    border: 1px solid var(--dynamic-line);
    border-radius: var(--dynamic-radius);
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .055);
}

.dynamic-section--featured {
    border-color: rgba(245, 158, 11, .48);
    box-shadow: 0 16px 38px rgba(245, 158, 11, .11);
}

.section-rich-html__title,
.dynamic-section__title,
.section-important-dates > h4 {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: 0 0 1.15rem;
    color: var(--dynamic-ink);
    font-size: clamp(1.22rem, 1vw + 1rem, 1.65rem);
    font-weight: 850;
}

.section-rich-html__title::before,
.dynamic-section__title::before,
.section-important-dates > h4::before {
    width: .35rem;
    align-self: stretch;
    min-height: 1.4rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #2563eb, #14b8a6);
    content: "";
}

.section-rich-html :where(ul, ol),
.section-rich-text :where(ul, ol) {
    padding-left: 1.35rem;
}

.section-rich-html li + li,
.section-rich-text li + li { margin-top: .42rem; }

.section-rich-html blockquote,
.section-rich-text blockquote,
.dynamic-section blockquote {
    margin: 1.25rem 0;
    padding: .9rem 1.1rem;
    border: 0;
    border-left: 4px solid #2563eb;
    border-radius: 0 14px 14px 0;
    background: #eff6ff;
    color: #294563;
}

.dynamic-sections .table-responsive {
    margin: .25rem 0;
    border: 1px solid var(--dynamic-line);
    border-radius: 14px;
}

.dynamic-sections .table {
    margin: 0;
    color: #40536d;
}

.dynamic-sections .table > :not(caption) > * > * {
    padding: .9rem 1rem;
    border-color: #e6edf6;
    vertical-align: middle;
}

.dynamic-sections .table thead th {
    border-bottom-width: 1px;
    color: #17335f;
    background: #edf4ff;
    font-size: .78rem;
    font-weight: 850;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.dynamic-sections .table tbody tr:nth-child(even) > * { background: #fbfdff; }

.dynamic-sections .badge {
    padding: .42rem .62rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.dynamic-sections .timeline-dates > div {
    margin-bottom: .7rem !important;
    padding: .9rem !important;
    border: 1px solid #dfeaf7 !important;
    border-left: 4px solid #2563eb !important;
    border-radius: 14px !important;
    background: #f8fbff !important;
}

.dynamic-sections .timeline-dates > div:last-child { margin-bottom: 0 !important; }

.dynamic-sections .accordion-item {
    margin-bottom: .7rem;
    overflow: hidden;
    border: 1px solid var(--dynamic-line);
    border-radius: 14px !important;
    box-shadow: none;
}

.dynamic-sections .accordion-item:last-child { margin-bottom: 0; }

.dynamic-sections .accordion-button {
    gap: .75rem;
    padding: 1rem 1.1rem;
    color: var(--dynamic-ink);
    background: #fff;
    font-weight: 800;
    box-shadow: none;
}

.dynamic-sections .accordion-button:not(.collapsed) {
    color: #1d4ed8;
    background: #eff6ff;
}

.dynamic-sections .accordion-button:focus { box-shadow: inset 0 0 0 2px rgba(37, 99, 235, .2); }
.dynamic-sections .accordion-body { padding: 1rem 1.1rem 1.15rem; color: var(--dynamic-copy); }

.dynamic-sections :where(.btn, .section-button, .section-button-group a) {
    min-height: 44px;
    border-radius: 12px;
    font-weight: 800;
    box-shadow: 0 7px 16px rgba(37, 99, 235, .12);
}

.dynamic-sections :where(.card) {
    border-color: var(--dynamic-line);
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .045);
}

.dynamic-sections :where(.card-body) { padding: 1.1rem; }

/* Download-box content used to inherit a horizontal Bootstrap flex layout on
   phones. When a long title and button competed for space, its text column
   could collapse to a few pixels and render one character per line. */
.dynamic-sections .section-download-box {
    width: 100%;
    min-width: 0;
    border-color: #d8e5f3 !important;
    border-radius: 16px !important;
    background: linear-gradient(135deg, #f8fbff, #ffffff);
}

.dynamic-sections .section-download-box .flex-grow-1 {
    min-width: 0;
}

.dynamic-sections .section-download-box h5 {
    color: var(--dynamic-ink);
    font-weight: 850;
    overflow-wrap: anywhere;
    word-break: normal;
}

@media (min-width: 768px) {
    .dynamic-section--rich-html,
    .dynamic-section--paragraph,
    .dynamic-section--quote,
    .dynamic-section--table,
    .dynamic-section--important-dates,
    .dynamic-section--eligibility,
    .dynamic-section--steps,
    .dynamic-section--checklist,
    .dynamic-section--accordion,
    .dynamic-section--faq,
    .dynamic-section--cards,
    .dynamic-section--feature-grid,
    .dynamic-section--icon-list,
    .dynamic-section--timeline,
    .dynamic-section--button-group,
    .dynamic-section--download-box,
    .dynamic-section--notice,
    .dynamic-section--alert-box {
        transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
    }

    .dynamic-section--rich-html:hover,
    .dynamic-section--paragraph:hover,
    .dynamic-section--table:hover,
    .dynamic-section--important-dates:hover,
    .dynamic-section--eligibility:hover,
    .dynamic-section--steps:hover,
    .dynamic-section--checklist:hover,
    .dynamic-section--accordion:hover,
    .dynamic-section--faq:hover {
        border-color: #c6d8f0;
        box-shadow: 0 18px 42px rgba(15, 23, 42, .075);
        transform: translateY(-2px);
    }
}

@media (max-width: 767.98px) {
    .dynamic-sections { gap: 1rem; }

    .dynamic-section--rich-html,
    .dynamic-section--paragraph,
    .dynamic-section--quote,
    .dynamic-section--table,
    .dynamic-section--important-dates,
    .dynamic-section--eligibility,
    .dynamic-section--steps,
    .dynamic-section--checklist,
    .dynamic-section--accordion,
    .dynamic-section--faq,
    .dynamic-section--cards,
    .dynamic-section--feature-grid,
    .dynamic-section--icon-list,
    .dynamic-section--timeline,
    .dynamic-section--button-group,
    .dynamic-section--download-box,
    .dynamic-section--notice,
    .dynamic-section--alert-box {
        padding: 1rem;
        border-radius: 16px;
        box-shadow: 0 7px 20px rgba(15, 23, 42, .045);
    }

    .section-rich-html__title,
    .dynamic-section__title,
    .section-important-dates > h4 { margin-bottom: .9rem; font-size: 1.18rem; }
    .dynamic-sections .table > :not(caption) > * > * { min-width: 7.5rem; padding: .72rem; }
    .dynamic-sections .accordion-button { padding: .9rem; font-size: .94rem; }
    .dynamic-sections .accordion-body { padding: .9rem; }
    .dynamic-sections :where(.btn, .section-button, .section-button-group a) { width: 100%; }

    .dynamic-sections .section-download-box {
        display: grid !important;
        grid-template-columns: 42px minmax(0, 1fr);
        align-items: start !important;
        gap: .75rem !important;
        padding: .9rem !important;
    }

    .dynamic-sections .section-download-box > .flex-shrink-0:first-child {
        width: 42px;
        text-align: center;
    }

    .dynamic-sections .section-download-box > .flex-shrink-0:first-child i {
        font-size: 1.75rem !important;
    }

    .dynamic-sections .section-download-box > a.btn {
        grid-column: 1 / -1;
        width: 100%;
        min-height: 46px;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dynamic-section--rich-html,
    .dynamic-section--paragraph,
    .dynamic-section--table,
    .dynamic-section--important-dates,
    .dynamic-section--eligibility,
    .dynamic-section--steps,
    .dynamic-section--checklist,
    .dynamic-section--accordion,
    .dynamic-section--faq { transition: none; }
}
