/* ==========================================================================
   RMU MOOC Report Page — Typography & Design System
   Fonts: Kanit (body) · Chonburi (headings)
   ========================================================================== */

/* --- CSS Custom Properties ----------------------------------------------- */
:root {
    /* Color palette */
    --rmu-purple: #662d91;
    --rmu-purple-dark: #55257a;
    --rmu-purple-light: #f0e6ff;
    --rmu-gold: #FFC107;
    --rmu-gold-dark: #92400e;
    --rmu-green: #28a745;
    --rmu-green-dark: #218838;
    --rmu-bg: #ffffff;
    --rmu-bg-alt: #f8fafc;
    --rmu-text: #1e293b;
    --rmu-text-muted: #64748b;
    --rmu-border: #cbd5e1;

    /* Typography */
    --font-heading: 'Chonburi', serif;
    --font-body: 'Kanit', sans-serif;
}

/* --- Base Typographic Resets --------------------------------------------- */
body {
    font-family: var(--font-body);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-heading);
}

.report-page h1,
.report-page h2,
.report-page h3 {
    font-family: var(--font-heading);
    color: var(--rmu-text);
}

.report-page p,
.report-page li,
.report-page td,
.report-page th {
    font-family: var(--font-body);
}

/* --- Utility: Backgrounds ------------------------------------------------ */
.bg-rmu-purple       { background-color: var(--rmu-purple) !important; }
.bg-rmu-purple-dark  { background-color: var(--rmu-purple-dark) !important; }
.bg-rmu-purple-light { background-color: var(--rmu-purple-light) !important; }
.bg-rmu-gold         { background-color: var(--rmu-gold) !important; }
.bg-rmu-gold-dark    { background-color: var(--rmu-gold-dark) !important; }
.bg-rmu-green        { background-color: var(--rmu-green) !important; }
.bg-rmu-green-dark   { background-color: var(--rmu-green-dark) !important; }
.bg-rmu-alt          { background-color: var(--rmu-bg-alt) !important; }

/* --- Utility: Text Colors ------------------------------------------------ */
.text-rmu-purple { color: var(--rmu-purple) !important; }
.text-rmu-gold   { color: var(--rmu-gold) !important; }
.text-rmu-green  { color: var(--rmu-green) !important; }

/* --- Utility: Borders ---------------------------------------------------- */
.border-rmu-purple { border-color: var(--rmu-purple) !important; }
.border-rmu-gold   { border-color: var(--rmu-gold) !important; }

/* --- Card Headers -------------------------------------------------------- */
.card-header-rmu {
    background-color: var(--rmu-purple);
    color: #fff;
    font-family: var(--font-body);
    font-weight: 600;
}

/* --- Badges -------------------------------------------------------------- */
.badge-rmu {
    background-color: var(--rmu-purple);
    color: #fff;
    border: 2px solid var(--rmu-purple);
}

.badge-rmu-outline {
    font-size: 12px;
    background-color: #fff;
    color: var(--rmu-purple);
    border: 2px solid var(--rmu-purple);
}

.badge-xs {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- Info Boxes ---------------------------------------------------------- */
.info-box-purple {
    background-color: var(--rmu-purple);
    border: 3px solid var(--rmu-purple-dark);
    border-radius: 0.25rem;
}

.info-box-green {
    background-color: var(--rmu-green);
    border: 3px solid var(--rmu-green-dark);
    border-radius: 0.25rem;
}

.info-box-gold {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border: 3px solid var(--rmu-gold-dark);
    border-radius: 0.25rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* --- Status Indicators --------------------------------------------------- */
.status-white {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    background-color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.status-gold {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    background-color: var(--rmu-gold);
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.8);
}

/* --- Objective Cards ----------------------------------------------------- */
.box-feat-obj {
    display: block;
    height: 100%;
    min-height: 260px;
}

.icon-obj,
.obj-icon {
    font-size: 40px;
    color: var(--rmu-purple);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.obj-icon svg {
    width: 40px;
    height: 40px;
    color: var(--rmu-purple);
}

.obj-title {
    font-size: 16px;
    color: #333;
}

.obj-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* --- Table Width Utilities ----------------------------------------------- */
.w-5  { width: 5% !important; }
.w-15 { width: 15% !important; }
.w-35 { width: 35% !important; }
.w-45 { width: 45% !important; }
.w-70 { width: 70% !important; }

/* --- Snapshot Summary Boxes ---------------------------------------------- */
.snapshot-box {
    background-color: #fff;
}

.snapshot-box-purple {
    border-color: var(--rmu-purple) !important;
}

.snapshot-box-gold {
    border-color: var(--rmu-gold) !important;
}

/* --- Iframe Container ---------------------------------------------------- */
.iframe-report {
    min-height: 600px;
}

.iframe-report iframe {
    width: 100%;
    min-height: 600px;
    border: 0;
}

/* ── Certificate preview: zoom-out iframe to fit without scrollbars ── */
/* ── Certificate preview: zoom-out iframe to fit without scrollbars ── */
.cert-preview-wrapper {
    overflow: hidden;
    width: 100%;
    background: #f8f9fa;
    border-radius: 8px;
}

.cert-preview-scaler {
    /* Render at native certificate width; CSS zoom handles the rest */
    width: 1123px;
    transform-origin: top left;
    /* Use CSS zoom (Chrome/Edge/Safari/Opera) — auto-handles height */
    zoom: 0.5;
    /* Firefox fallback: JS will set transform + wrapper height */
    transform: scale(var(--cert-scale, 0.5));
    transform-origin: top left;
}

/* Firefox doesn't support zoom, so we need transform + explicit height */
@supports not (zoom: 1) {
    .cert-preview-scaler {
        zoom: normal;
    }
}

.cert-preview-scaler iframe {
    display: block;
    width: 1123px;
    height: 794px;           /* A4 landscape @ 1123px wide */
    border: 0;
    pointer-events: none;
}

/* --- Overflow Utility ---------------------------------------------------- */
.overflow-x-auto {
    overflow-x: auto;
}

/* --- Canvas Constraints ------------------------------------------------- */
.canvas-chart-md {
    max-height: 400px;
}

.canvas-chart-lg {
    max-height: 450px;
}

/* --- Faculty Bar Chart Container ---------------------------------------- */
.faculty-chart-container {
    width: 100%;
    min-height: 400px;
    overflow: visible;
}

/* ==========================================================================
   Modern Table System
   ========================================================================== */

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-family: var(--font-body), 'Segoe UI', sans-serif;
    background: #fff;
    border: 1px solid var(--rmu-border);
}

.modern-table thead {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: var(--rmu-text);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modern-table thead th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-top: 1px solid #94a3b8;
    border-bottom: 3px solid #94a3b8;
    position: relative;
}

.modern-table thead th.text-center {
    text-align: center;
}

.modern-table thead th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(102, 45, 145, 0.2), transparent);
}

.modern-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(102, 45, 145, 0.08);
}

.modern-table tbody tr:nth-child(even) {
    background-color: var(--rmu-bg-alt);
}

.modern-table tbody tr:nth-child(odd) {
    background-color: #fff;
}

.modern-table tbody tr.highlight {
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border-left: 4px solid var(--rmu-gold);
}

.modern-table tbody tr.highlight:hover {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
}

.modern-table tbody tr:hover {
    background-color: #f1f5f9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 5;
    position: relative;
}

.modern-table tbody tr.highlight:hover {
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
    background-color: #fff3cd;
}

.modern-table tbody td {
    padding: 14px 20px;
    font-size: 14px;
    color: #333;
    border: none;
    vertical-align: middle;
}

.modern-table tbody td.text-center {
    text-align: center;
}

.modern-table tbody tr:last-child td {
    border-bottom: none;
}

/* Tfoot */
.modern-table tfoot tr {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    font-weight: 600;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    border-top: 3px solid #94a3b8;
}

.modern-table tfoot tr.highlight-footer {
    background: linear-gradient(135deg, #fff8e1 0%, #ffe69c 100%);
    color: #856404;
    border-top: 3px solid #d39e00;
}

.modern-table tfoot td {
    padding: 16px 20px;
    color: var(--rmu-text);
    font-size: 14px;
    border-top: 3px solid #94a3b8;
    border-right: 1px solid var(--rmu-border);
}

.modern-table tfoot td:last-child {
    border-right: none;
}

/* Compact variant */
.modern-table-sm {
    font-size: 13px;
}

.modern-table-sm thead th,
.modern-table-sm tbody td,
.modern-table-sm tfoot td {
    padding: 10px 14px;
}

/* Links in tables */
.modern-table a {
    color: var(--rmu-purple);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-block;
}

.modern-table a:hover {
    color: var(--rmu-purple-dark);
    text-decoration: underline;
    transform: translateX(2px);
}

.modern-table a.accent-link {
    color: #d39e00;
}

.modern-table a.accent-link:hover {
    color: var(--rmu-gold);
}

/* Badge hover in tables */
.modern-table .badge {
    transition: all 0.2s ease;
}

.modern-table .badge:hover {
    transform: scale(1.05);
}

/* Yellow accent badge */
.badge-yellow {
    background-color: var(--rmu-gold);
    color: #333;
    border: 2px solid var(--rmu-gold);
}

/* Empty state */
.modern-table tbody tr td:first-child:last-child {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-style: italic;
}

/* ==========================================================================
   Table Container (responsive scrolling)
   ========================================================================== */
.table-responsive {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--rmu-border);
}

.table-responsive::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #94a3b8 0%, #cbd5e1 100%);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
}

/* ==========================================================================
   Card Accents & Highlight Boxes
   ========================================================================== */
.card-accent-yellow {
    border-left: 4px solid var(--rmu-gold);
}

.card-accent-violet {
    border-left: 4px solid var(--rmu-purple);
}

.highlight-box {
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border: 2px solid var(--rmu-gold);
    border-radius: 8px;
    padding: 15px 20px;
}

.highlight-box-violet {
    background: linear-gradient(135deg, #f0e6ff 0%, #e8d5f7 100%);
    border: 2px solid var(--rmu-purple);
    border-radius: 8px;
    padding: 15px 20px;
}

/* ==========================================================================
   Status Indicators & Dividers
   ========================================================================== */
.icon-accent-yellow {
    color: var(--rmu-gold);
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-yellow {
    background-color: var(--rmu-gold);
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.6);
}

.status-violet {
    background-color: var(--rmu-purple);
    box-shadow: 0 0 8px rgba(102, 45, 145, 0.6);
}

.status-green {
    background-color: var(--rmu-green);
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
}

.section-divider {
    height: 3px;
    background: linear-gradient(90deg, var(--rmu-purple) 0%, var(--rmu-gold) 50%, var(--rmu-purple) 100%);
    margin: 20px 0;
    border-radius: 2px;
}

/* ==========================================================================
   Highlight Text
   ========================================================================== */
.text-highlight {
    color: #d39e00;
    font-weight: 600;
}

.text-highlight-violet {
    color: var(--rmu-purple);
    font-weight: 600;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-accent-yellow {
    background-color: var(--rmu-gold);
    color: #333;
    border: 2px solid var(--rmu-gold);
}

.btn-accent-yellow:hover {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #333;
}

.btn-outline-yellow {
    background-color: transparent;
    color: var(--rmu-gold);
    border: 2px solid var(--rmu-gold);
}

.btn-outline-yellow:hover {
    background-color: var(--rmu-gold);
    color: #333;
}

/* ==========================================================================
   Assessment Flowchart System
   ========================================================================== */

/* --- Desktop / Mobile Toggle --------------------------------------------- */
.flowchart-desktop {
    display: block;
}

.flowchart-mobile {
    display: none;
    text-align: left;
}

@media (max-width: 767.98px) {
    .flowchart-desktop {
        display: none;
    }

    .flowchart-mobile {
        display: block;
        padding: 8px 4px;
    }
}

/* --- Step Row ------------------------------------------------------------ */
.flow-step {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
}

/* --- Step Number Circle -------------------------------------------------- */
.flow-step-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--rmu-purple);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(102, 45, 145, 0.35);
    line-height: 1;
}

.flow-step-number.green {
    background: #1cc88a;
    box-shadow: 0 3px 8px rgba(28, 200, 138, 0.35);
}

.flow-step-number.gold {
    background: #f6c23e;
    color: #5a3e00;
    box-shadow: 0 3px 8px rgba(246, 194, 62, 0.4);
}

.flow-step-number.amber {
    background: #d97706;
    box-shadow: 0 3px 8px rgba(217, 119, 6, 0.35);
}

.flow-step-number.icon {
    background: transparent;
    border: 2px dashed var(--rmu-purple);
    color: var(--rmu-purple);
    box-shadow: none;
    font-size: 18px;
}

/* --- Step Card ----------------------------------------------------------- */
.flow-step-card {
    flex: 1;
    background: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    border-left: 4px solid var(--rmu-purple);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.flow-step-card:hover {
    box-shadow: 0 4px 16px rgba(102, 45, 145, 0.12);
    transform: translateY(-1px);
}

.flow-step-card h5 {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 15px;
    margin: 0 0 6px 0;
    color: var(--rmu-purple);
}

.flow-step-card p {
    font-size: 13px;
    color: #555;
    margin: 0;
    line-height: 1.55;
}

/* Card color variants */
.flow-step-card.green {
    border-left-color: #1cc88a;
    background: linear-gradient(135deg, #f0fdf9 0%, #e6f9f1 100%);
}

.flow-step-card.green h5 {
    color: #0e8a5e;
}

.flow-step-card.gold {
    border-left-color: #f6c23e;
    background: linear-gradient(135deg, #fffdf5 0%, #fff8e1 100%);
}

.flow-step-card.gold h5 {
    color: #92400e;
}

.flow-step-card.amber {
    border-left-color: #d97706;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.flow-step-card.amber h5 {
    color: #92400e;
}

/* Dashed variant for analytics */
.flow-step-card.dashed {
    border: 2px dashed var(--rmu-purple);
    border-left: 4px solid var(--rmu-purple);
    background: linear-gradient(135deg, var(--rmu-purple-light) 0%, #f5edff 100%);
}

/* --- Connector Arrow ----------------------------------------------------- */
.flow-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 28px;
    margin: 4px 0 4px 0;
    padding-left: 13px; /* center under the 40px circle: 40/2 - 1 = 19, but offset for flex */
}

.flow-connector .arrow-line {
    width: 2px;
    flex: 1;
    background: var(--rmu-purple);
    border-radius: 1px;
}

.flow-connector .arrow-head {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--rmu-purple);
}

.flow-connector.green .arrow-line {
    background: #1cc88a;
}

.flow-connector.green .arrow-head {
    border-top-color: #1cc88a;
}

/* --- Decision Block ------------------------------------------------------ */
.flow-decision {
    margin: 8px 0;
    padding: 16px 18px;
    background: #fff;
    border: 2px solid var(--rmu-purple);
    border-radius: 12px;
    position: relative;
    box-shadow: 0 3px 12px rgba(102, 45, 145, 0.1);
}

.flow-decision::before {
    content: '?';
    position: absolute;
    top: -14px;
    left: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--rmu-purple);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(102, 45, 145, 0.3);
}

.flow-decision h5 {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 15px;
    margin: 0 0 12px 0;
    color: var(--rmu-purple);
    text-align: center;
}

/* --- Branch Row ---------------------------------------------------------- */
.flow-branch {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.flow-branch-item {
    flex: 1;
    padding: 12px 14px;
    border-radius: 8px;
    text-align: center;
}

.flow-branch-item strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.flow-branch-item small {
    font-size: 12px;
    display: block;
    line-height: 1.4;
}

.flow-branch-item.pass {
    background: linear-gradient(135deg, #e6f9f1 0%, #d4f5e6 100%);
    border: 2px solid #1cc88a;
    color: #0e6b45;
}

.flow-branch-item.pass strong {
    color: #0e8a5e;
}

.flow-branch-item.fail {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 2px solid #ef4444;
    color: #991b1b;
}

.flow-branch-item.fail strong {
    color: #dc2626;
}

/* Loop-back indicator inside fail branch */
.flow-loop-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 3px 8px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 4px;
    font-size: 11px;
    color: #dc2626;
    font-weight: 500;
}

.flow-loop-back svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* --- Responsive tweaks for small screens --------------------------------- */
@media (max-width: 480px) {
    .flow-step {
        gap: 10px;
    }

    .flow-step-number {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .flow-step-card {
        padding: 12px 14px;
    }

    .flow-step-card h5 {
        font-size: 14px;
    }

    .flow-step-card p {
        font-size: 12px;
    }

    .flow-connector {
        padding-left: 10px;
        height: 24px;
    }

    .flow-branch {
        flex-direction: column;
        gap: 8px;
    }

    .flow-decision {
        padding: 14px 14px;
    }
}
