/* Core MVC — Frontend base styles for AJAX UI */
:root {
    color-scheme: light dark;
    --bg: #0b1220;
    --panel: #131c2e;
    --text: #e6edf7;
    --muted: #8a9ab8;
    --line: #2a3756;
    --accent: #4f8cff;
    --accent-2: #7c3aed;
    --error: #ef4444;
    --ok: #22c55e;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html, body { background: var(--bg); color: var(--text); margin: 0; }
body { padding: 28px 16px; }
.app-wrap { max-width: 720px; margin: 0 auto; }

h1 { margin: 0 0 6px; font-size: 24px; }
p.lead { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

.card {
    background: var(--panel);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
}

label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
    width: 100%; box-sizing: border-box;
    padding: 10px 12px; background: var(--bg); color: inherit;
    border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--error); }

small[data-error-for] {
    display: none; margin-top: 6px; color: #fda4a4; font-size: 12px;
}

button {
    margin-top: 18px; padding: 11px 16px;
    background: linear-gradient(180deg, var(--accent), #3a6fd8);
    color: #fff; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer;
}
button[disabled] { opacity: .55; cursor: progress; }
button.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); }

a { color: #8ab4ff; text-decoration: none; }
a:hover, a:focus, a:active { text-decoration: none; }

ul.files { list-style: none; margin: 18px 0 0; padding: 0; }
ul.files li {
    padding: 10px 0; border-top: 1px solid #1f2a44;
    display: flex; justify-content: space-between; gap: 12px; font-size: 13px;
}
ul.files li:first-child { border-top: 0; }
small.kbd { font-family: ui-monospace, monospace; color: var(--muted); }

.drop {
    border: 2px dashed var(--line); border-radius: 10px;
    padding: 28px; text-align: center; cursor: pointer; transition: .15s;
    display: block;
}
.drop.over { border-color: var(--accent); background: #182542; }
.drop input[type="file"] { display: none; }
.drop .meta { margin-top: 10px; color: var(--muted); font-size: 13px; }

[data-progress] {
    margin-top: 14px; height: 8px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
    overflow: hidden; display: none;
}
[data-progress-fill] {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .15s linear;
}
[data-progress-label] { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }

.row-links { margin-top: 14px; font-size: 13px; display: flex; justify-content: space-between; }

/* Top loading bar driven by api:loading / api:done */
html.api-loading::before {
    content: ""; position: fixed; left: 0; top: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    animation: api-bar 1s linear infinite;
    z-index: 99999;
}
@keyframes api-bar {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Pagination component */
.pager ul { list-style: none; display: flex; gap: 4px; padding: 0; margin: 18px 0 0; flex-wrap: wrap; }
.pager button {
    margin: 0; padding: 6px 11px; min-width: 36px; font-size: 13px; font-weight: 500;
    background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
}
.pager button:hover:not([disabled]):not(.is-active) { border-color: var(--accent); }
.pager button.is-active { background: var(--accent); border-color: var(--accent); cursor: default; }
.pager button[disabled] { opacity: .4; cursor: not-allowed; }
.pager-gap { padding: 6px 4px; color: var(--muted); align-self: center; }

[data-paginate] [data-loader]   { padding: 8px 0; color: var(--muted); font-size: 13px; }
[data-paginate] [data-error]    { padding: 8px 12px; margin: 8px 0; background: rgba(239,68,68,.1); border: 1px solid var(--error); border-radius: 6px; color: #fda4a4; font-size: 13px; }
[data-paginate] [data-empty]    { padding: 16px; color: var(--muted); text-align: center; }
[data-paginate].is-loading      { opacity: .85; }
[data-paginate] [data-load-more]{ display: block; margin: 14px auto; }

/* ---- Notification bell -------------------------------------------------- */
.notif-bell                     { position: relative; display: inline-block; }
.notif-bell__btn                { background: transparent; border: 1px solid var(--line); color: var(--text); width: 38px; height: 38px; border-radius: 8px; cursor: pointer; padding: 0; position: relative; }
.notif-bell__btn:hover          { background: var(--panel); }
.notif-bell__icon               { font-size: 18px; line-height: 1; }
.notif-bell__badge              { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.notif-bell__dropdown           { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.35); z-index: 1000; overflow: hidden; }
.notif-bell__head               { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif-bell__markall            { background: none; border: 0; color: var(--accent); font-size: 12px; cursor: pointer; padding: 4px 6px; }
.notif-bell__markall:hover      { text-decoration: none; }
.notif-bell__list               { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.notif-bell__empty              { padding: 16px; color: var(--muted); font-size: 13px; text-align: center; }
.notif-bell__foot               { border-top: 1px solid var(--line); padding: 8px 14px; text-align: center; }
.notif-bell__viewall            { font-size: 12px; color: var(--accent); text-decoration: none; }
.notif-bell__viewall:hover      { text-decoration: none; }
.notif-bell__badge--urgent      { background: #dc2626; box-shadow: 0 0 0 2px rgba(220,38,38,.35); animation: notif-pulse 1.6s ease-in-out infinite; }
@keyframes notif-pulse          { 0%,100% { box-shadow: 0 0 0 2px rgba(220,38,38,.35); } 50% { box-shadow: 0 0 0 6px rgba(220,38,38,.0); } }

.notif-item                     { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-item:last-child          { border-bottom: 0; }
.notif-item:hover               { background: rgba(79,140,255,.08); }
.notif-item.is-unread           { background: rgba(79,140,255,.05); }
.notif-item.is-unread .notif-item__title { font-weight: 700; }
.notif-item__head               { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.notif-item__time               { font-size: 11px; color: var(--muted); opacity: .8; }
.notif-item__type               { font-size: 11px; color: var(--muted); opacity: .7; }
.notif-item__title              { font-size: 13px; color: var(--text); }
.notif-item__body               { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-item__meta               { font-size: 11px; color: var(--muted); margin-top: 4px; opacity: .8; }
.notif-item__actions            { display: flex; gap: 10px; margin-top: 6px; }

/* Priority badges & rails */
.notif-priority                 { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.6; letter-spacing: .02em; }
.notif-priority--low            { background: rgba(148,163,184,.18); color: #94a3b8; }
.notif-priority--normal         { background: rgba(79,140,255,.18);  color: #93c5fd; }
.notif-priority--high           { background: rgba(245,158,11,.20);  color: #fbbf24; }
.notif-priority--urgent         { background: rgba(220,38,38,.22);   color: #fca5a5; }
.notif-item--urgent             { border-left: 3px solid #dc2626; }
.notif-item--high               { border-left: 3px solid #f59e0b; }
.notif-item--normal             { border-left: 3px solid transparent; }
.notif-item--low                { border-left: 3px solid transparent; opacity: .82; }

/* Notification Center page */
.notif-center                   { max-width: 880px; margin: 32px auto; padding: 0 18px; color: var(--text); }
.notif-center__head             { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.notif-center__head h1          { margin: 0 0 4px 0; font-size: 24px; }
.notif-center__sub              { margin: 0; color: var(--muted); font-size: 13px; }
.notif-center__actions .btn     { background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.notif-center__actions .btn:hover { background: rgba(79,140,255,.10); }
.notif-center__summary          { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.notif-pill                     { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.notif-pill b                   { color: var(--text); font-weight: 700; }
.notif-pill--urgent             { border-color: rgba(220,38,38,.4); }
.notif-pill--high               { border-color: rgba(245,158,11,.4); }
.notif-pill--total              { border-color: rgba(79,140,255,.5); }
.notif-center__filters          { display: flex; flex-wrap: wrap; gap: 14px 24px; margin-bottom: 14px; }
.notif-filter-group             { display: flex; flex-wrap: wrap; gap: 6px; }
.notif-filter, .notif-priority-filter {
    background: var(--panel); border: 1px solid var(--line); color: var(--muted);
    padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12px;
}
.notif-filter.is-active, .notif-priority-filter.is-active { background: rgba(79,140,255,.18); border-color: rgba(79,140,255,.5); color: var(--text); }
.notif-priority-filter--urgent.is-active { background: rgba(220,38,38,.20); border-color: rgba(220,38,38,.5); color: #fca5a5; }
.notif-priority-filter--high.is-active   { background: rgba(245,158,11,.20); border-color: rgba(245,158,11,.5); color: #fbbf24; }
.notif-center__list-wrap        { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.notif-center__list             { list-style: none; margin: 0; padding: 0; }
.notif-center__list .notif-item { padding: 14px 16px; }
.notif-center__empty            { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-center__footer           { padding: 12px; text-align: center; border-top: 1px solid var(--line); }
.btn-link                       { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; text-decoration: none; }
.btn-link:hover                 { text-decoration: none; }
.btn-link--danger               { color: #f87171; }

/* ===== Rendered prose (sanitized HTML preview / lesson body) ===== */
.lh-prose { color: inherit; line-height: 1.7; }
.lh-prose > :first-child { margin-top: 0; }
.lh-prose > :last-child { margin-bottom: 0; }
.lh-prose p { margin: 0 0 0.9em; }
.lh-prose h1, .lh-prose h2, .lh-prose h3, .lh-prose h4 { margin: 1.2em 0 0.4em; line-height: 1.3; font-weight: 600; }
.lh-prose h1 { font-size: 1.5em; }
.lh-prose h2 { font-size: 1.3em; }
.lh-prose h3 { font-size: 1.12em; }
.lh-prose ul, .lh-prose ol { margin: 0 0 0.9em; padding-left: 1.4em; }
.lh-prose li + li { margin-top: 0.2em; }
.lh-prose blockquote { margin: 0.9em 0; padding: 0.4em 0.9em; border-left: 3px solid rgba(129,140,248,0.6); background: rgba(129,140,248,0.08); border-radius: 0 8px 8px 0; }
.lh-prose code { background: rgba(255,255,255,0.08); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.92em; }
.lh-prose pre { background: rgba(0,0,0,0.35); padding: 12px 14px; border-radius: 10px; overflow: auto; }
.lh-prose pre code { background: transparent; padding: 0; }
.lh-prose hr { border: 0; border-top: 1px solid rgba(255,255,255,0.12); margin: 1.2em 0; }
.lh-prose a { color: #818cf8; text-underline-offset: 2px; }
.lh-prose img { max-width: 100%; height: auto; border-radius: 8px; }


/* ===== Global: never underline links in any state ===================
 * Enterprise hover affordance is delivered via color, background, transform,
 * and the native pointer cursor — never via underline. This rule wins over
 * .lh-prose, Tailwind preflight, and any per-page styles.
 * =================================================================== */
a,
a:link,
a:visited,
a:hover,
a:focus,
a:focus-visible,
a:active,
.lh-prose a,
.lh-prose a:hover,
.lh-prose a:focus,
.lh-prose a:active {
  text-decoration: none !important;
  text-decoration-line: none !important;
}
a { cursor: pointer; }

/* ============================================================
 * Permission lock — visual fade for actions the current user
 * lacks the permission to perform.
 *
 * Add via the PHP helper:  <button <?= Auth::lockAttr('edit_program') ?>>
 * The helper outputs class="is-locked" + aria-disabled + tooltip.
 *
 * The element stays in the DOM (so layouts don't shift), but it
 * is dimmed, shows a not-allowed cursor, and a global click
 * blocker (lock-blocker.js) cancels pointer + keyboard activation.
 * ============================================================ */
.is-locked,
[aria-disabled="true"][data-perm-lock] {
  opacity: .45 !important;
  filter: grayscale(35%);
  cursor: not-allowed !important;
  pointer-events: auto; /* keep tooltip on hover */
  position: relative;
}
.is-locked::after,
[aria-disabled="true"][data-perm-lock]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  cursor: not-allowed;
}
.is-locked:focus,
.is-locked:focus-visible,
[aria-disabled="true"][data-perm-lock]:focus,
[aria-disabled="true"][data-perm-lock]:focus-visible {
  outline: 2px dashed currentColor;
  outline-offset: 2px;
}

