/* Research Assessment Portal — application styles (Bootstrap 5.3 base) */
:root {
  --rap-sidebar-w: 260px;
  --rap-brand: #1f3a68;
  --rap-brand-2: #2d5597;
  --rap-accent: #f5c242;
  --bs-primary: #2d5597;
  --bs-primary-rgb: 45, 85, 151;
  --bs-link-color: #2d5597;
  --bs-link-color-rgb: 45, 85, 151;
  --bs-link-hover-color: #1f3a68;
}
body { background: #f4f6fa; min-height: 100vh; }
.btn-primary { --bs-btn-bg: #2d5597; --bs-btn-border-color: #2d5597; --bs-btn-hover-bg: #1f3a68; --bs-btn-hover-border-color: #1f3a68; --bs-btn-active-bg: #1a3159; --bs-btn-disabled-bg: #2d5597; --bs-btn-disabled-border-color: #2d5597; }
.btn-outline-primary { --bs-btn-color: #2d5597; --bs-btn-border-color: #2d5597; --bs-btn-hover-bg: #2d5597; --bs-btn-hover-border-color: #2d5597; --bs-btn-active-bg: #1f3a68; }
.text-bg-orange { color: #fff !important; background-color: #d9631e !important; }
.text-bg-purple { color: #fff !important; background-color: #6f42c1 !important; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 2000; }
.skip-link:focus { left: 1rem; top: 1rem; }

/* Layout */
.rap-sidebar { width: var(--rap-sidebar-w); --bs-offcanvas-bg: var(--rap-brand); --bs-offcanvas-color: #dfe6f3; --bs-offcanvas-width: var(--rap-sidebar-w); background-color: var(--rap-brand) !important; color: #dfe6f3; }
.rap-sidebar .brand { color: #fff; text-decoration: none; }
.rap-sidebar .brand img { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,.08); }
.rap-sidebar .brand-name { font-weight: 600; line-height: 1.15; font-size: .95rem; }
.rap-sidebar .brand-sub { font-size: .72rem; opacity: .75; }
.rap-sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6; padding: 1rem 1rem .35rem; }
.rap-sidebar .nav-link { color: #dfe6f3; border-radius: .5rem; padding: .5rem .85rem; margin: 1px .5rem; display: flex; align-items: center; gap: .65rem; }
.rap-sidebar .nav-link:hover, .rap-sidebar .nav-link:focus-visible { background: rgba(255,255,255,.09); color: #fff; }
.rap-sidebar .nav-link.active { background: #fff; color: var(--rap-brand); font-weight: 600; }
.rap-sidebar .nav-link .bi { font-size: 1.05rem; }
.rap-sidebar .nav-link .badge { margin-left: auto; }
/* Sidebar scrolling: the brand header stays put and the link list scrolls whenever it is taller than the
   screen (short laptop screens, phones, landscape, browser zoom). Works for the fixed desktop sidebar and the
   mobile off-canvas menu alike. */
.rap-sidebar { display: flex; flex-direction: column; overflow: hidden; }
.rap-sidebar-header { flex-shrink: 0; }
.rap-sidebar-body {
  position: relative; flex: 1 1 auto; min-height: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)) !important;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) transparent;
}
.rap-sidebar-body::-webkit-scrollbar { width: 8px; }
.rap-sidebar-body::-webkit-scrollbar-track { background: transparent; }
.rap-sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); border-radius: 8px; border: 2px solid var(--rap-brand); }
.rap-sidebar-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.45); }
/* Fade shadows hint that more links are hidden above / below. */
.rap-sidebar::before, .rap-sidebar::after { content: ""; position: absolute; left: 0; right: 0; height: 18px; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 2; }
.rap-sidebar::before { top: var(--rap-sidebar-head, 72px); background: linear-gradient(to bottom, rgba(10,22,45,.55), transparent); }
.rap-sidebar::after { bottom: 0; background: linear-gradient(to top, rgba(10,22,45,.6), transparent); }
.rap-sidebar.can-scroll-up::before, .rap-sidebar.can-scroll-down::after { opacity: 1; }
.rap-sidebar .nav-link { scroll-margin: 2.5rem 0; }
@media (min-width: 992px) {
  .rap-sidebar.offcanvas-lg { position: fixed; top: 0; bottom: 0; left: 0; height: 100vh; height: 100dvh; }
  .rap-main { margin-left: var(--rap-sidebar-w); }
}
@media (max-width: 991.98px) {
  .rap-sidebar.offcanvas-lg { top: 0; bottom: 0; height: 100vh; height: 100dvh; max-height: 100%; }
}
.rap-topbar { background: #fff; border-bottom: 1px solid #e3e7ef; position: sticky; top: 0; z-index: 1020; }
.rap-topbar .search { max-width: 420px; }
.rap-content { padding: 1.5rem; }
@media (max-width: 575.98px) { .rap-content { padding: 1rem .75rem; } }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--rap-brand-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar-student { background: #198754; }

/* Cards & stats */
.card { border: 1px solid #e3e7ef; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; font-weight: 600; }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: #6c757d; font-size: .85rem; }
.bg-soft-primary { background: #e7eefb; color: #2d5597; }
.bg-soft-success { background: #e3f4ea; color: #198754; }
.bg-soft-warning { background: #fff4d6; color: #a76c00; }
.bg-soft-danger { background: #fde6e6; color: #b42318; }
.bg-soft-info { background: #e1f3f8; color: #0b7285; }
.bg-soft-purple { background: #efe8fb; color: #6f42c1; }
.page-header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; margin: 0; font-weight: 650; }
.breadcrumb { font-size: .85rem; margin-bottom: .35rem; }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6475; background: #f8f9fc; white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #f5f8ff; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #6c757d; }
.empty-state .bi { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* Project header & tabs */
.project-header { background: #fff; border: 1px solid #e3e7ef; border-radius: .75rem; padding: 1.1rem 1.25rem .25rem; margin-bottom: 1.25rem; }
.project-header .nav-tabs { border-bottom: 0; margin-top: .85rem; flex-wrap: nowrap; overflow-x: auto; }
.project-header .nav-tabs .nav-link { border: 0; border-bottom: 3px solid transparent; color: #5b6475; white-space: nowrap; }
.project-header .nav-tabs .nav-link.active { color: var(--rap-brand); border-bottom-color: var(--rap-brand-2); background: transparent; font-weight: 600; }
.progress-thin { height: 6px; }

/* Timeline */
.timeline { list-style: none; padding-left: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px; width: 2px; background: #e3e7ef; }
.timeline li { position: relative; padding-left: 44px; padding-bottom: 1rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .tl-icon { position: absolute; left: 3px; top: 0; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid #c7d2e5; display: flex; align-items: center; justify-content: center; font-size: .75rem; color: #2d5597; }
.timeline .tl-time { font-size: .78rem; color: #6c757d; }
.timeline .tl-confidential .tl-icon { border-color: #dc3545; color: #dc3545; }

/* Milestones stepper */
.stepper { list-style: none; padding: 0; margin: 0; }
.stepper li { display: flex; gap: .75rem; padding: .55rem 0; border-bottom: 1px dashed #e3e7ef; }
.stepper li:last-child { border-bottom: 0; }
.stepper .dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #eef1f6; color: #6c757d; font-size: .85rem; }
.stepper .done .dot { background: #198754; color: #fff; }
.stepper .current .dot { background: #2d5597; color: #fff; }
.stepper .overdue .dot { background: #dc3545; color: #fff; }

/* Discussions / comments */
.comment { border: 1px solid #e3e7ef; border-radius: .75rem; background: #fff; padding: .9rem 1rem; }
.comment + .comment { margin-top: .75rem; }
.comment .replies { margin-top: .75rem; padding-left: 1rem; border-left: 3px solid #e7eefb; }
.comment .replies .comment { background: #fbfcfe; }
.comment-body { white-space: normal; word-wrap: break-word; }
.comment.withdrawn { background: #f8f9fa; color: #6c757d; font-style: italic; }
.visibility-confidential { border-left: 4px solid #dc3545 !important; }
.visibility-group { border-left: 4px solid #ffc107 !important; }
.visibility-feedback { border-left: 4px solid #0dcaf0 !important; }
.prose { white-space: pre-line; }
.topic-card { border-left: 4px solid #c7d2e5; }
.topic-card.status-approved { border-left-color: #198754; }
.topic-card.status-rejected { border-left-color: #dc3545; }
.review-card.decision-approved_next_stage, .review-card.decision-final_approval { border-left: 4px solid #198754; }
.review-card.decision-corrections_required, .review-card.decision-major_revision, .review-card.decision-resubmission_required { border-left: 4px solid #d9631e; }
.review-card.decision-rejected { border-left: 4px solid #dc3545; }

/* Notifications dropdown */
.notif-menu { width: min(380px, 92vw); max-height: 70vh; overflow-y: auto; }
.notif-item { white-space: normal; border-bottom: 1px solid #f0f2f6; }
.notif-item.unread { background: #f3f7ff; }
.notif-item .small { color: #6c757d; }

/* Uploads */
.upload-progress { display: none; }
.upload-progress.active { display: block; }
.dropzone-hint { border: 2px dashed #c7d2e5; border-radius: .75rem; padding: 1rem; background: #fbfcfe; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: linear-gradient(135deg, #1f3a68 0%, #2d5597 60%, #3d6fbf 100%); }
.auth-card { width: 100%; max-width: 440px; border: 0; border-radius: 1rem; box-shadow: 0 20px 50px rgba(10, 25, 60, .35); }
.auth-card .logo { width: 56px; height: 56px; object-fit: contain; }

/* PDF viewer */
.pdf-toolbar { position: sticky; top: 57px; z-index: 5; background: #fff; border-bottom: 1px solid #e3e7ef; }
.pdf-stage { background: #525659; padding: 1rem; min-height: 60vh; text-align: center; overflow: auto; }
.pdf-stage canvas { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4); max-width: 100%; height: auto; margin: 0 auto 1rem; display: block; }

/* Toasts */
.toast-container { z-index: 1090; }

/* Misc */
.min-w-0 { min-width: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.font-mono { font-family: var(--bs-font-monospace); font-size: .85em; }
.cursor-pointer { cursor: pointer; }
.loading { opacity: .55; pointer-events: none; transition: opacity .15s; }
.js-hidden { display: none !important; }
.w-0 { width: 0; }
@media print { .rap-sidebar, .rap-topbar, .no-print { display: none !important; } .rap-main { margin: 0 !important; } }
.min-w-160 { min-width: 160px; }
.settings-logo { max-height: 80px; }
.report-card { transition: box-shadow .15s ease, transform .15s ease; }
.report-card:hover, .report-card:focus-visible { box-shadow: 0 .5rem 1rem rgba(0,0,0,.08); transform: translateY(-1px); }
.notif-row.unread { background: #f3f7ff; }
.notif-item.unread .fw-semibold::before, .notif-row.unread .fw-semibold::before { content: ''; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--bs-primary); margin-right: .4rem; vertical-align: middle; }
.page-header h1 .badge, h1 .badge { font-size: .5em; vertical-align: middle; }
.btn-outline-warning { --bs-btn-color: #8a6100; --bs-btn-border-color: #e0a800; --bs-btn-hover-color: #000; }

/* ------------------------------------------------------------ bulk actions */
.bulk-col { width: 2.5rem; }
.bulk-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  padding: .6rem 1rem; border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-primary-bg-subtle); position: sticky; top: 0; z-index: 5;
}
.bulk-toolbar.d-none { display: none !important; }

/* Confirmation dialogs may contain several paragraphs (e.g. a deletion summary). */
#confirmModal .confirm-message { white-space: pre-line; }

/* ---------------------------------------------------- searchable selects */
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }
.ts-wrapper .ts-control { min-height: calc(1.5em + .75rem + 2px); }
.ts-wrapper.form-select-sm .ts-control { min-height: calc(1.5em + .5rem + 2px); font-size: .875rem; }
.ts-wrapper.is-invalid .ts-control { border-color: var(--bs-form-invalid-border-color); }
.ts-dropdown { z-index: 1060; }
.ts-dropdown .dropdown-input-wrap { padding: .375rem; }
.ts-dropdown .dropdown-input { border-radius: var(--bs-border-radius-sm); }
.ts-dropdown .optgroup-header { font-weight: 600; color: var(--bs-secondary-color); font-size: .8rem; }
.ts-dropdown .no-results { padding: .5rem .75rem; color: var(--bs-secondary-color); }
.input-group > .ts-wrapper { flex: 1 1 auto; width: 1%; min-width: 0; }
.ts-wrapper.single .ts-control { flex-wrap: nowrap; }
.ts-wrapper.single .ts-control > .item { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------------------------------------------------------------- Table sorting */
.th-sort-btn { border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; text-align: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; white-space: normal; }
.th-sort-btn i { white-space: nowrap; }
/* E-mail addresses wrap only after the @ sign (an explicit <wbr> follows the @). */
.email-wrap { overflow-wrap: normal; word-break: normal; }
.sv-table { font-size: .875rem; }
.sv-table td.small, .sv-table .small { font-size: inherit; }
.sv-topic { min-width: 15rem; }
.sv-supervisors { min-width: 11rem; }
.th-sort-btn:hover { text-decoration: underline; }
.th-sort-btn:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; border-radius: 2px; }
th[aria-sort] .th-sort-btn { font-weight: 700; }

/* ---------------------------------------------------------------- AI assistant */
.ai-score { display: inline-flex; gap: 2px; vertical-align: middle; }
.ai-score span { width: 10px; height: 10px; border-radius: 2px; background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color); }
.ai-score span.on { background: var(--bs-primary); border-color: var(--bs-primary); }
.ai-card .ai-improved { border-left: 4px solid var(--bs-success); }
.ai-disclaimer { font-size: .8rem; }

/* Footer version badge and legal links */
.app-version { font-size: .72rem; font-weight: 500; letter-spacing: .02em; color: var(--bs-secondary-color); }
.auth-legal { font-size: .78rem; }
.auth-legal a { color: inherit; }
/* Terms and privacy pages */
.legal-wrap { max-width: 880px; }
.legal-body h2 { font-size: 1.15rem; margin-top: 2rem; scroll-margin-top: 1rem; }
.legal-body h3 { font-size: 1rem; margin-top: 1.25rem; }
.legal-body li { margin-bottom: .3rem; }
.legal-toc a { text-decoration: none; }
.min-w-200 { min-width: 200px; }
.contact-links a { text-decoration: none; } .contact-links a:hover { text-decoration: underline; }

/* AI project report */
.report-label { font-size: .7rem; text-transform: uppercase; font-weight: 600; letter-spacing: .03em; color: var(--bs-secondary-color); }
.report-sheet { max-width: 860px; }
.report-section h3 { font-size: .95rem; margin-bottom: .25rem; }
.report-section p { margin-bottom: .75rem; text-align: justify; }
.word-meter.over { color: var(--bs-danger); font-weight: 600; }
.help-link { font-size: .85em; vertical-align: middle; text-decoration: none; }
.help-link:hover { color: var(--bs-primary) !important; }
.topic-cell { max-width: 22rem; }

/* User guide / knowledge base */
.kb-wrap { max-width: 1180px; }
.kb-toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.kb-toc a { text-decoration: none; display: block; padding: .15rem 0; }
.kb-toc .kb-toc-sub a { padding-left: .9rem; font-size: .82rem; color: var(--bs-secondary-color); }
.kb-body h2 { font-size: 1.3rem; margin-top: 2.25rem; padding-top: .25rem; scroll-margin-top: 1rem; border-bottom: 1px solid var(--bs-border-color); padding-bottom: .4rem; }
.kb-body h3 { font-size: 1.02rem; margin-top: 1.4rem; scroll-margin-top: 1rem; }
.kb-body li { margin-bottom: .3rem; }
.kb-item { scroll-margin-top: 1rem; }
.kb-nav a { text-decoration: none; }
.kb-path { font-family: var(--bs-font-monospace); font-size: .82em; background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: .25rem; padding: 0 .3rem; white-space: nowrap; }
mark.kb-hit { padding: 0; background: #fff3a3; }
.kb-body .kb-section:first-of-type > h2:first-child { margin-top: 0; padding-top: 0; }
.kb-body h3 { font-weight: 600; }
/* Google reCAPTCHA (invisible): the badge is replaced by the notice under the form, as Google permits. */
.grecaptcha-badge { visibility: hidden; }
.rc-holder { display: contents; }

/* Embedded videos (YouTube, Vimeo, ...; see App\Support\VideoEmbed) */
.video-embeds { display: flex; flex-direction: column; gap: .75rem; margin-top: .5rem; }
.video-embed { max-width: 720px; margin: 0; }
.video-embed .ratio { border-radius: .5rem; overflow: hidden; background: #000; }
.video-embed iframe { border: 0; }
.video-embed-vertical { max-width: 340px; }
.ratio-9x16 { --bs-aspect-ratio: 177.7778%; }
.prose .video-embeds, .prose .video-embed { white-space: normal; }
.guideline-video { max-width: 640px; }

/* ---- integrations & API (3.0.1) ---- */
.mapping-table th:nth-child(1) { min-width: 13rem; }
.mapping-table th:nth-child(2) { min-width: 12rem; }
.mapping-table th:nth-child(3) { min-width: 9rem; }
.mapping-table th:nth-child(4) { min-width: 11rem; }
.mapping-table th:nth-child(5) { min-width: 7rem; }
.wh-error { max-width: 16rem; }
.raw-json { max-height: 14rem; overflow: auto; font-size: .75rem; white-space: pre-wrap; word-break: break-word; }
.api-docs pre { background: #0f172a; color: #e2e8f0; border-radius: .5rem; padding: .85rem 1rem; font-size: .8rem; overflow-x: auto; }
.api-docs pre code { color: inherit; }
.api-docs .method { display: inline-block; min-width: 3.6rem; text-align: center; font-weight: 600; font-size: .72rem; border-radius: .3rem; padding: .15rem .35rem; color: #fff; }
.api-docs .method-get { background: #0d6efd; }
.api-docs .method-post { background: #198754; }
.api-docs .method-patch { background: #fd7e14; }
.api-docs .endpoint + .endpoint { border-top: 1px solid var(--bs-border-color); }
.api-docs .toc a { text-decoration: none; }

/* Multi-institution (owner console, billing, pricing) */
.progress-thin{height:6px}
.text-pre-wrap{white-space:pre-wrap}
