/**
 * EDUHD QA User Manual Stylesheet
 * System: ระบบประกันคุณภาพการศึกษา คณะครุศาสตร์และการพัฒนามนุษย์ มหาวิทยาลัยราชภัฏร้อยเอ็ด
 * Path: manual/css/manual.css
 */

:root {
    --primary-color: #1e3a8a;
    --primary-dark: #0f172a;
    --primary-light: #3b82f6;
    --primary-subtle: #eff6ff;
    --accent-color: #0284c7;
    --accent-emerald: #059669;
    --accent-amber: #d97706;
    --accent-rose: #e11d48;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-page: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --sidebar-width: 290px;
    --font-thai: 'Sarabun', 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    font-family: var(--font-thai);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.65;
    font-size: 15px;
    scroll-behavior: smooth;
}

/* ============================================================
   Header & Toolbar
============================================================ */
.manual-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    z-index: 1020;
}

.manual-logo-img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.role-switcher-btn {
    border-radius: 30px;
    font-size: 13.5px;
    font-weight: 600;
    padding: 6px 16px;
    transition: all 0.2s ease;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
}

.role-switcher-btn:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.role-switcher-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25);
}

.action-btn-print {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    border: none;
    border-radius: 30px;
    padding: 7px 18px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
}

.action-btn-print:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
    color: #ffffff;
}

.action-btn-pdf {
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff;
    border: none;
    border-radius: 30px;
    padding: 7px 18px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
    transition: all 0.2s ease;
}

.action-btn-pdf:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
    color: #ffffff;
}

/* ============================================================
   Sidebar (Table of Contents)
============================================================ */
.manual-sidebar {
    width: var(--sidebar-width);
    position: sticky;
    top: 76px;
    height: calc(100vh - 86px);
    overflow-y: auto;
    padding-right: 15px;
}

.manual-sidebar::-webkit-scrollbar {
    width: 6px;
}
.manual-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.toc-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.02);
    padding: 18px;
}

.toc-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 12px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-link {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    font-size: 13.5px;
    color: #475569;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.toc-link i {
    width: 18px;
    margin-right: 8px;
    font-size: 12px;
    opacity: 0.7;
}

.toc-link:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.toc-link.active {
    background: var(--primary-subtle);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

.toc-group-title {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    margin-top: 14px;
    margin-bottom: 4px;
    padding-left: 8px;
    text-transform: uppercase;
}

/* ============================================================
   Main Manual Content
============================================================ */
.manual-content {
    flex: 1;
    min-width: 0;
}

.manual-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.02);
    padding: 32px 36px;
    margin-bottom: 30px;
    transition: box-shadow 0.2s ease;
}

.manual-section:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.04);
}

.section-header {
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.section-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.section-desc {
    color: var(--text-muted);
    font-size: 15px;
    margin: 0;
}

/* ============================================================
   Step Cards & Process
============================================================ */
.process-step-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 18px;
    position: relative;
    transition: all 0.2s ease;
}

.process-step-card:hover {
    border-color: #cbd5e1;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.03);
}

.step-number-badge {
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--primary-color);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.3);
}

.step-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin-top: 4px;
    margin-bottom: 8px;
}

/* ============================================================
   Form Field Reference Tables
============================================================ */
.form-field-table {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    margin: 20px 0;
}

.form-field-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
    font-size: 13.5px;
    padding: 12px 16px;
    border-bottom: 2px solid #e2e8f0;
}

.form-field-table td {
    padding: 12px 16px;
    font-size: 14px;
    vertical-align: top;
    border-bottom: 1px solid #f1f5f9;
}

.form-field-table tr:last-child td {
    border-bottom: none;
}

.badge-required {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.badge-optional {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.field-name-label {
    font-weight: 700;
    color: var(--primary-color);
}

.field-code-badge {
    font-family: Consolas, Monaco, monospace;
    font-size: 11.5px;
    background: #f1f5f9;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ============================================================
   Callout Alert Boxes
============================================================ */
.manual-callout {
    border-radius: 12px;
    padding: 16px 20px;
    margin: 20px 0;
    border-left: 4px solid;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.manual-callout-icon {
    font-size: 20px;
    line-height: 1;
    margin-top: 2px;
}

.manual-callout-body {
    flex: 1;
    font-size: 14px;
}

.manual-callout-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 15px;
}

.callout-tip {
    background: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
}
.callout-tip .manual-callout-icon { color: #10b981; }

.callout-info {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1e40af;
}
.callout-info .manual-callout-icon { color: #3b82f6; }

.callout-warning {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}
.callout-warning .manual-callout-icon { color: #f59e0b; }

.callout-danger {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}
.callout-danger .manual-callout-icon { color: #ef4444; }

/* ============================================================
   UI Mockup Containers & Callouts
============================================================ */
.ui-mockup-card {
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.04);
    margin: 24px 0;
}

.ui-mockup-header {
    background: #f1f5f9;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.mockup-window-controls {
    display: flex;
    gap: 6px;
}

.mockup-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
}
.mockup-dot.red { background: #ef4444; }
.mockup-dot.yellow { background: #f59e0b; }
.mockup-dot.green { background: #10b981; }

.mockup-address-bar {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 2px 14px;
    font-size: 11.5px;
    color: #64748b;
    max-width: 450px;
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-mockup-body {
    padding: 24px;
    background: #f8fafc;
    position: relative;
}

.mock-window-content {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

/* Callout pin */
.callout-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #e11d48;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.4);
    vertical-align: middle;
    margin-right: 6px;
    user-select: none;
}

.mockup-legend {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 14px 20px;
    font-size: 13px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px 16px;
}

.mockup-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
}

/* ============================================================
   Cover Page (Print & Screen)
============================================================ */
.manual-cover-page {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 60%, #0369a1 100%);
    color: #ffffff;
    border-radius: 20px;
    padding: 50px 40px;
    margin-bottom: 35px;
    box-shadow: 0 12px 32px rgba(30, 58, 138, 0.18);
    position: relative;
    overflow: hidden;
}

.cover-decor-circle {
    position: absolute;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 70%);
    top: -100px;
    right: -100px;
    pointer-events: none;
}

.cover-title {
    font-size: 30px;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 12px;
}

.cover-subtitle {
    font-size: 18px;
    color: #cbd5e1;
    margin-bottom: 20px;
    font-weight: 400;
}

.cover-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 13.5px;
    color: #e2e8f0;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 20px;
    margin-top: 24px;
}

.cover-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Quick Jump Pills */
.quick-jump-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.jump-pill {
    background: rgba(255,255,255,0.15);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    text-decoration: none;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.jump-pill:hover {
    background: rgba(255,255,255,0.3);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Search Box */
.manual-search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.manual-search-input {
    border-radius: 20px;
    padding-left: 36px;
    font-size: 13.5px;
    border: 1px solid #cbd5e1;
}

.manual-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 13px;
}

/* Back to Top button */
.btn-back-to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    box-shadow: 0 6px 16px rgba(30, 58, 138, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

.btn-back-to-top.show {
    opacity: 1;
    pointer-events: auto;
}

.btn-back-to-top:hover {
    transform: translateY(-2px);
    background: var(--primary-light);
}

/* ============================================================
   Print Media Styling (A4 Optimization)
============================================================ */
@page {
    size: A4 portrait;
    margin: 15mm 12mm 15mm 12mm;
}

@media print {
    /* Base resets */
    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }

    /* Hide Screen-Only Components */
    .no-print,
    .manual-navbar,
    .manual-sidebar,
    .role-switcher-container,
    .action-btn-print,
    .action-btn-pdf,
    .manual-search-box,
    .btn-back-to-top,
    .quick-jump-pills,
    .toast,
    .btn-close {
        display: none !important;
    }

    .container-fluid, .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .manual-content {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Show all sections regardless of role filter when printing full */
    .manual-section {
        display: block !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        border-radius: 0 !important;
        margin-bottom: 20pt !important;
        padding: 16pt !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Cover page printing */
    .manual-cover-page {
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #1e3a8a !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        padding: 40pt 25pt !important;
        margin-bottom: 30pt !important;
        page-break-after: always;
        break-after: page;
    }

    .manual-cover-page * {
        color: #ffffff !important;
    }

    /* Force Page Break for Major Chapters */
    .chapter-break {
        page-break-before: always;
        break-before: page;
    }

    /* Prevent awkward element splitting */
    .process-step-card,
    .form-field-table,
    .ui-mockup-card,
    .manual-callout {
        page-break-inside: avoid;
        break-inside: avoid;
        box-shadow: none !important;
    }

    /* Tables in Print */
    .form-field-table {
        width: 100% !important;
        border: 1px solid #999 !important;
    }
    .form-field-table th {
        background: #f0f0f0 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        border-bottom: 1px solid #999 !important;
    }
    .form-field-table td {
        border-bottom: 1px solid #ddd !important;
    }

    /* Callouts in Print */
    .manual-callout {
        border: 1px solid #999 !important;
        border-left: 4px solid #333 !important;
        background: #f9f9f9 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* UI Mockups in Print */
    .ui-mockup-card {
        border: 1px solid #999 !important;
    }
    .ui-mockup-header {
        background: #e5e5e5 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Links in Print */
    a {
        text-decoration: none !important;
        color: #000 !important;
    }
    a[href^="http"]:after {
        content: "" !important; /* avoid printing full long urls unless helpful */
    }

    .print-footer {
        display: block !important;
        text-align: center;
        font-size: 9pt;
        color: #666;
        border-top: 1px solid #ccc;
        padding-top: 6pt;
        margin-top: 20pt;
    }
}

.print-footer {
    display: none;
}
