/* =====================================================================
   Pantexis LMS + Blocking Gate stylesheet.

   Conventions:
   - Reuses existing wt-* tokens from Pantexis.Rcl/wwwroot/css/app.css
     where possible (colors, typography), but namespaces LMS-specific
     layout under .lms-*. The blocking-gate UI is namespaced .wt-blocking-*
     because it lives in the topbar shell alongside the rest of wt-*.
   - All layout uses CSS grid / flex with sensible breakpoints down to
     360px so the orchestrator and player work on phones.
   - Color hex values intentionally avoid theming variables so this
     drops in standalone; promote them to CSS custom properties when
     branding tokens are extracted.
   ===================================================================== */

/* ---------- Common LMS scaffolding ---------- */

.wt-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wt-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

.wt-muted {
    color: #6b7280;
}

.wt-error {
    color: #b91c1c;
}

/* ---------- LMS form rows (label-above-input pairs) ----------
   Pantexis doesn't have a built-in "form row" class, so the LMS module
   ships its own. Keep this aligned with .wt-input padding so authoring
   forms feel native next to the rest of the app. */

.lms-form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    max-width: 560px;
}

/* Opts out of the 560px cap so the field stretches to its container.
   Used for the quiz "Question text" textarea, which should fill its card. */
.lms-form-row-full {
    max-width: none;
}

.lms-form-row > label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.lms-form-row-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.lms-form-row-inline > label {
    font-weight: 500;
    color: #374151;
}

/* Used inline inside lesson editor + media upload to keep buttons compact. */
.lms-btn-link {
    background: none;
    border: none;
    color: #1d4ed8;
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
    text-decoration: underline;
}

.lms-btn-link:hover { color: #1e40af; }
.lms-btn-link.danger { color: #b91c1c; }
.lms-btn-link.danger:hover { color: #991b1b; }

/* Two-column action row for headers (title + Save / Publish buttons). */
.lms-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.lms-action-row .lms-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- LMS catalog ---------- */

.lms-catalog-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.lms-catalog-toolbar input[type="search"] {
    flex: 1 1 240px;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
}

.lms-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.lms-catalog-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.lms-catalog-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.lms-catalog-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.lms-catalog-card-meta {
    font-size: 0.8rem;
    color: #6b7280;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lms-catalog-card-meta .pill {
    background: #f3f4f6;
    border-radius: 999px;
    padding: 2px 8px;
}

.lms-catalog-card-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
}

/* ---------- LMS course player ---------- */

.lms-player {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    align-items: flex-start;
}

.lms-player-sidebar {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

.lms-player-sidebar h4 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
}

.lms-lesson-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lms-lesson-list li {
    margin: 0;
}

.lms-lesson-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    color: #1f2937;
    font-size: 0.92rem;
    line-height: 1.25;
}

.lms-lesson-pill:hover {
    background: #f3f4f6;
}

.lms-lesson-pill.active {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #3730a3;
}

.lms-lesson-pill.locked {
    color: #9ca3af;
    cursor: not-allowed;
}

.lms-lesson-pill .status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #d1d5db;
    flex: 0 0 9px;
}

.lms-lesson-pill.complete .status-dot {
    background: #16a34a;
}

.lms-player-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (max-width: 800px) {
    .lms-player {
        grid-template-columns: 1fr;
    }
    .lms-player-sidebar {
        position: static;
        max-height: none;
    }
}

/* ---------- Lesson viewers ---------- */

.lms-video-viewer video {
    border-radius: 6px;
    outline: none;
}

.lms-pdf-scroll-host {
    height: 70vh;
    overflow-y: auto;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
}

/* ---------- Quiz UI ---------- */

.lms-quiz-taker {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lms-quiz-question {
    border-bottom: 1px dashed #e5e7eb;
    padding-bottom: 12px;
}

.lms-quiz-question:last-child {
    border-bottom: none;
}

.lms-quiz-result {
    border-radius: 6px;
    padding: 12px 16px;
    border: 1px solid transparent;
}

.lms-quiz-result.passed {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.lms-quiz-result.failed {
    background: #fef2f2;
    border-color: #fecaca;
}

/* ---------- Authoring (orchestrator) ---------- */

.lms-author-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lms-author-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.lms-author-header .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lms-lesson-editor {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lms-lesson-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.lms-lesson-editor-actions {
    display: inline-flex;
    gap: 6px;
}

.lms-lesson-editor-actions button {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
}

.lms-lesson-editor-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Media upload + progress ---------- */

.lms-media-upload {
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.lms-media-upload progress {
    width: 100%;
    height: 12px;
}

/* ---------- Quiz authoring ---------- */

.lms-quiz-author-question {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lms-quiz-author-answers {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 8px;
    border-left: 2px solid #e5e7eb;
}

.lms-quiz-author-answer {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* The answer text input takes all remaining row space so it reads roughly
   twice as wide as the default .wt-input intrinsic size, with a sane floor
   for narrow containers. */
.lms-quiz-author-answer-input {
    flex: 1 1 auto;
    min-width: 320px;
    width: auto;
}

/* =====================================================================
   Shared LMS status + due-date affordances
   Used by /lms/my, /lms/assign, and any future dashboard surface that
   needs to render an enrollment status or call out an overdue assignment.
   ===================================================================== */

.lms-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    white-space: nowrap;
}

.lms-status-pill.lms-status-none      { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.lms-status-pill.lms-status-notstarted{ background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.lms-status-pill.lms-status-inprogress{ background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.lms-status-pill.lms-status-completed { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.lms-status-pill.lms-status-failed    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.lms-due-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.78rem;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
}

.lms-due-badge.lms-due-soon     { background: #fef3c7; color: #92400e; }
.lms-due-badge.lms-due-overdue  { background: #fee2e2; color: #991b1b; font-weight: 600; }

/* Inline per-row outcome marker shown next to a user after a batch assign. */
.lms-row-outcome {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 600;
}
.lms-row-outcome.ok   { color: #047857; }
.lms-row-outcome.fail { color: #b91c1c; }

/* =====================================================================
   /lms/assign workspace
   Three-step manager workflow: pick course -> pick users -> review + submit.
   ===================================================================== */

.lms-assign-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.lms-assign-stepper {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.82rem;
    color: #6b7280;
    flex-wrap: wrap;
}

.lms-assign-stepper .step {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

.lms-assign-stepper .step.active {
    background: #eef2ff;
    color: #3730a3;
    border-color: #c7d2fe;
}

.lms-assign-stepper .step.complete {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.lms-assign-stepper .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid currentColor;
    font-size: 0.72rem;
    font-weight: 700;
}

/* Course-picker grid reuses lms-catalog-card visuals but adds an explicit
   selectable state so the manager sees what they're about to assign. */
.lms-assign-course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.lms-assign-course-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    text-align: left;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.lms-assign-course-card:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.lms-assign-course-card.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
    background: #eef2ff;
}

.lms-assign-course-card .title {
    font-weight: 600;
    color: #111827;
    line-height: 1.25;
}

.lms-assign-course-card .meta {
    font-size: 0.78rem;
    color: #6b7280;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lms-assign-course-card .meta .pill {
    background: #f3f4f6;
    border-radius: 999px;
    padding: 2px 8px;
}

.lms-assign-course-card .meta .pill.blocking {
    background: #fef3c7;
    color: #92400e;
}

/* Toolbar for the user-picker step. Puts the search field, hide-already
   toggle, and selection counter on one wrap-friendly row. */
.lms-assign-user-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.lms-assign-user-toolbar .grow { flex: 1 1 200px; }

.lms-assign-user-toolbar .selection-counter {
    background: #eef2ff;
    color: #3730a3;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Compact horizontal toggle/checkbox aligned with the search input. */
.lms-assign-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #374151;
    user-select: none;
}

/* Due-date row: native date input + one-click presets. */
.lms-assign-due-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.lms-assign-due-presets {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.lms-assign-due-preset {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
    cursor: pointer;
}

.lms-assign-due-preset:hover  { background: #e5e7eb; }
.lms-assign-due-preset.active { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }

/* Pre-submit "you are about to assign..." summary banner. */
.lms-assign-summary {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #6366f1;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.9rem;
    color: #1f2937;
    line-height: 1.45;
}

.lms-assign-summary .reuse-note {
    color: #6b7280;
    font-size: 0.82rem;
    margin-top: 2px;
}

.lms-assign-summary.no-target {
    border-left-color: #9ca3af;
    color: #6b7280;
}

/* Result banner shown after submit. Color tracks the success ratio. */
.lms-assign-result {
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid transparent;
    margin-top: 12px;
}

.lms-assign-result.ok      { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.lms-assign-result.partial { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.lms-assign-result.fail    { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Scrollable user-picker table */
.lms-assign-user-table {
    max-height: 360px;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.lms-assign-user-table table { width: 100%; }

.lms-assign-user-table thead th {
    position: sticky;
    top: 0;
    background: #f9fafb;
    z-index: 1;
    border-bottom: 1px solid #e5e7eb;
}

/* Two-column layout on wide screens: user-picker on left, current roster on right */
@media (min-width: 1100px) {
    .lms-assign-two-col {
        display: grid;
        grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
        gap: 16px;
        align-items: flex-start;
    }
}

/* =====================================================================
   Blocking gate UI
   ===================================================================== */

.wt-blocking-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    /* Override the .wt-topbar a, .wt-topbar button { color: white } from app.css */
    -webkit-text-fill-color: #92400e;
}

.wt-blocking-badge:hover {
    background: #fde68a;
}

.wt-blocking-badge-count {
    background: #b45309;
    color: #fff;
    -webkit-text-fill-color: #fff;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
    padding: 0 6px;
    font-size: 0.78rem;
}

.wt-blocking-badge-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- LMS inbox badge (mirrors blocking badge tokens, cooler palette) ---------- */
.wt-lms-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #075985;
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    -webkit-text-fill-color: #075985;
}

.wt-lms-badge:hover {
    background: #bae6fd;
}

.wt-lms-badge-count {
    background: #0369a1;
    color: #fff;
    -webkit-text-fill-color: #fff;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
    padding: 0 6px;
    font-size: 0.78rem;
}

.wt-lms-badge-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* On narrower phones, collapse LMS pill text first to preserve topbar width.
   At an even smaller width, hide Help so login controls remain visible. */
@media (max-width: 780px) {
    .wt-lms-badge {
        gap: 4px;
        padding: 4px 8px;
    }

    .wt-lms-badge-label {
        display: none;
    }
}

@media (max-width: 680px) {
    .wt-topbar-help-link {
        display: none;
    }
}

.wt-blocking-landing {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wt-blocking-landing-header h2 {
    margin: 0 0 6px 0;
}

.wt-blocking-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wt-blocking-item {
    background: #fff;
    border: 1px solid #fcd34d;
    border-left-width: 6px;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wt-blocking-item-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.78rem;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wt-blocking-item-due {
    background: #fef3c7;
    border-radius: 4px;
    padding: 1px 6px;
}

.wt-blocking-item-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
}

.wt-blocking-item-reason {
    color: #4b5563;
    line-height: 1.4;
}

.wt-blocking-item-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.wt-blocking-cleared {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.wt-blocking-footer {
    display: flex;
    justify-content: flex-end;
}
