/* App-wide look and feel, layered over Bootstrap 5.3. Colours come from the
   university crest: deep blue (primary), laurel green, gold (accent). */

:root {
    --ulk-blue: #1d4f91;
    --ulk-blue-dark: #12335f;
    --ulk-blue-soft: #e8eff9;
    --ulk-green: #2f7d3a;
    --ulk-gold: #f2b807;
    --ulk-ink: #1f2937;
    --ulk-muted: #667085;
    --ulk-line: #e4e8ef;
    --ulk-surface: #ffffff;
    --ulk-radius: 0.75rem;
    --ulk-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
    --ulk-shadow-lift: 0 4px 6px rgba(16, 24, 40, 0.05), 0 12px 24px rgba(16, 24, 40, 0.1);

    --bs-primary: var(--ulk-blue);
    --bs-primary-rgb: 29, 79, 145;
    --bs-link-color: var(--ulk-blue);
    --bs-link-color-rgb: 29, 79, 145;
    --bs-link-hover-color: var(--ulk-blue-dark);
    --bs-link-hover-color-rgb: 18, 51, 95;
    --bs-body-bg: #f3f5f9;
    --bs-body-color: var(--ulk-ink);
    --bs-secondary-color: var(--ulk-muted);
    --bs-border-color: var(--ulk-line);
    --bs-border-radius: 0.6rem;
    --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: 0.95rem;
}

html { scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
main.app-main { flex: 1 0 auto; }

/* ---- headings -------------------------------------------------------- */
h1, .h1, h2, .h2, h3, .h3 { color: var(--ulk-blue-dark); letter-spacing: -0.01em; }
h1.h3 { font-weight: 700; }
.page-subtitle { color: var(--ulk-muted); margin-bottom: 1.25rem; }

/* ---- navbar ---------------------------------------------------------- */
.app-nav {
    background: linear-gradient(180deg, #16407a 0%, var(--ulk-blue-dark) 100%);
    border-bottom: 3px solid var(--ulk-gold);
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.15);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.app-nav .navbar-brand { display: flex; align-items: center; gap: 0.65rem; font-weight: 650; font-size: 1rem; line-height: 1.15; color: #fff; max-width: 22rem; white-space: normal; }
.app-nav .brand-logo { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
.app-nav .nav-link { color: rgba(255, 255, 255, 0.78); font-weight: 500; padding: 0.5rem 0.85rem; border-radius: 0.5rem; transition: background 0.15s, color 0.15s; }
.app-nav .nav-link:hover, .app-nav .nav-link:focus { color: #fff; background: rgba(255, 255, 255, 0.1); }
.app-nav .nav-link.active { color: #fff; background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 -2px 0 var(--ulk-gold); }
.app-nav .navbar-toggler { border-color: rgba(255, 255, 255, 0.4); }
.user-chip { display: inline-flex; align-items: center; gap: 0.5rem; color: #fff; background: rgba(255, 255, 255, 0.1); border: 0; border-radius: 999px; padding: 0.25rem 0.75rem 0.25rem 0.3rem; font-weight: 500; }
.user-chip:hover, .user-chip:focus, .user-chip.show { background: rgba(255, 255, 255, 0.2); color: #fff; }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ulk-gold); color: var(--ulk-blue-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; }
.dropdown-menu { border: 0; border-radius: var(--ulk-radius); box-shadow: var(--ulk-shadow-lift); padding: 0.4rem; }
.dropdown-item { border-radius: 0.45rem; }

/* ---- cards ----------------------------------------------------------- */
.card { border: 0; border-radius: var(--ulk-radius); box-shadow: var(--ulk-shadow); background: var(--ulk-surface); }
.card-body { padding: 1.25rem 1.35rem; }
.card-title { font-weight: 650; color: var(--ulk-blue-dark); }
.card .card { box-shadow: none; border: 1px solid var(--ulk-line); }
.card h2.h6.card-title { display: flex; align-items: center; gap: 0.4rem; font-size: 1rem; }
.card h2.h6.card-title::before { content: ""; width: 4px; height: 1.05em; border-radius: 2px; background: var(--ulk-gold); display: inline-block; }
.card-link-tile { transition: transform 0.15s, box-shadow 0.15s; color: inherit; text-decoration: none; display: block; height: 100%; }
.card-link-tile:hover { transform: translateY(-2px); box-shadow: var(--ulk-shadow-lift); color: inherit; }

/* ---- buttons --------------------------------------------------------- */
.btn { font-weight: 550; border-radius: 0.6rem; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { --bs-btn-bg: var(--ulk-blue); --bs-btn-border-color: var(--ulk-blue); --bs-btn-hover-bg: var(--ulk-blue-dark); --bs-btn-hover-border-color: var(--ulk-blue-dark); --bs-btn-active-bg: var(--ulk-blue-dark); --bs-btn-active-border-color: var(--ulk-blue-dark); --bs-btn-disabled-bg: var(--ulk-blue); --bs-btn-disabled-border-color: var(--ulk-blue); --bs-btn-focus-shadow-rgb: 29, 79, 145; box-shadow: 0 1px 2px rgba(18, 51, 95, 0.25); }
.btn-outline-primary { --bs-btn-color: var(--ulk-blue); --bs-btn-border-color: #b4c7e3; --bs-btn-hover-bg: var(--ulk-blue); --bs-btn-hover-border-color: var(--ulk-blue); --bs-btn-active-bg: var(--ulk-blue-dark); --bs-btn-active-border-color: var(--ulk-blue-dark); --bs-btn-focus-shadow-rgb: 29, 79, 145; --bs-btn-disabled-color: var(--ulk-blue); --bs-btn-disabled-border-color: #b4c7e3; }
.btn-outline-secondary { --bs-btn-color: #475467; --bs-btn-border-color: #d0d5dd; --bs-btn-hover-bg: #f2f4f7; --bs-btn-hover-color: var(--ulk-ink); --bs-btn-hover-border-color: #b8bfca; --bs-btn-active-bg: #e4e7ec; --bs-btn-active-color: var(--ulk-ink); --bs-btn-active-border-color: #b8bfca; }
.btn-link { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.btn.is-busy { opacity: 0.7; pointer-events: none; }
.btn.is-busy::after { content: ""; display: inline-block; width: 0.85em; height: 0.85em; margin-left: 0.5em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -0.1em; animation: ulk-spin 0.7s linear infinite; }
@keyframes ulk-spin { to { transform: rotate(360deg); } }

/* ---- forms ----------------------------------------------------------- */
.form-label { font-weight: 550; color: #344054; margin-bottom: 0.3rem; }
.form-control, .form-select { background-color: #fff; border-color: #d0d5dd; border-radius: 0.6rem; padding: 0.55rem 0.8rem; }
.form-control-sm, .form-select-sm { padding: 0.3rem 0.6rem; border-radius: 0.5rem; }
.form-control:focus, .form-select:focus { border-color: #6b93c7; box-shadow: 0 0 0 0.22rem rgba(29, 79, 145, 0.15); }
.form-control::placeholder { color: #98a2b3; }
.form-text { color: var(--ulk-muted); }
.form-check-input:checked { background-color: var(--ulk-blue); border-color: var(--ulk-blue); }
textarea.form-control { min-height: 5rem; }
/* Green "valid" ticks on every untouched filter box are noise - only errors get decoration. */
.form-control.is-valid, .form-select.is-valid { border-color: #d0d5dd; background-image: none; padding-right: 0.8rem; }
.form-select.is-valid { background-image: var(--bs-form-select-bg-img); padding-right: 2.25rem; }
.form-control.is-valid:focus, .form-select.is-valid:focus { border-color: #6b93c7; box-shadow: 0 0 0 0.22rem rgba(29, 79, 145, 0.15); }
.valid-feedback { display: none !important; }
/* Filter bars: compact, one tidy row where there is room. */
form.row-cols-lg-auto { --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.6rem; }
form.row-cols-lg-auto .mb-3 { margin-bottom: 0 !important; }
form.row-cols-lg-auto .form-label { font-size: 0.78rem; margin-bottom: 0.15rem; color: var(--ulk-muted); }
form.row-cols-lg-auto .form-control, form.row-cols-lg-auto .form-select { padding: 0.35rem 0.6rem; font-size: 0.86rem; }

/* ---- tables ---------------------------------------------------------- */
.table-responsive { border-radius: var(--ulk-radius); box-shadow: var(--ulk-shadow); background: var(--ulk-surface); margin-bottom: 1rem; }
.table-responsive > .table { margin-bottom: 0; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f6f9fe; font-size: 0.9rem; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 0.7rem 0.85rem; border-color: var(--ulk-line); }
.table thead th { background: #eef2f8; color: #475467; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #d9e0ec; white-space: nowrap; }
.table-bordered > :not(caption) > * { border-width: 0 0 1px; }
.table-bordered > :not(caption) > * > * { border-width: 0; border-bottom: 1px solid var(--ulk-line); }
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table > tbody > tr { transition: background 0.1s; }
.table > tbody > tr:hover > * { background: #f6f9fe; }
.table-sm > :not(caption) > * > * { padding: 0.45rem 0.65rem; }

/* ---- badges, alerts, misc --------------------------------------------- */
.badge { font-weight: 600; letter-spacing: 0.01em; border-radius: 999px; padding: 0.4em 0.75em; }
.badge.text-bg-secondary { background-color: #e9edf4 !important; color: #3b4a63 !important; }
.badge.text-bg-success { background-color: #dff3e3 !important; color: #1e6b2c !important; }
.badge.text-bg-warning { background-color: #fdf0c7 !important; color: #7a5a00 !important; }
.badge.text-bg-danger { background-color: #fbe0de !important; color: #a1261b !important; }
.badge.text-bg-info { background-color: #dcecfb !important; color: #14507f !important; }
.badge.text-bg-primary { background-color: var(--ulk-blue-soft) !important; color: var(--ulk-blue-dark) !important; }

.alert { border: 0; border-left: 4px solid; border-radius: 0.65rem; box-shadow: var(--ulk-shadow); }
.alert-success { background: #eaf7ed; border-left-color: var(--ulk-green); color: #1e5a2a; }
.alert-danger { background: #fdeceb; border-left-color: #d92d20; color: #8a1f17; }
.alert-warning { background: #fff7e0; border-left-color: var(--ulk-gold); color: #6b4e00; }
.alert-info { background: var(--ulk-blue-soft); border-left-color: var(--ulk-blue); color: var(--ulk-blue-dark); }
.alert-secondary { background: #f2f4f7; border-left-color: #98a2b3; color: #344054; }
.messages-stack { margin-top: 1rem; }

dl.row dt { color: var(--ulk-muted); font-weight: 550; }
hr { border-color: var(--ulk-line); opacity: 1; }
.text-muted { color: var(--ulk-muted) !important; }
.pagination { --bs-pagination-active-bg: var(--ulk-blue); --bs-pagination-active-border-color: var(--ulk-blue); --bs-pagination-color: var(--ulk-blue); }
a:focus-visible, button:focus-visible, .btn:focus-visible { outline: 3px solid rgba(242, 184, 7, 0.65); outline-offset: 2px; }

/* ---- footer ---------------------------------------------------------- */
.app-footer { flex-shrink: 0; margin-top: 3rem; padding: 1.25rem 0; border-top: 1px solid var(--ulk-line); color: var(--ulk-muted); font-size: 0.82rem; background: rgba(255, 255, 255, 0.6); }

/* ---- home dashboard --------------------------------------------------- */
.hero { background: linear-gradient(120deg, var(--ulk-blue-dark) 0%, #1d4f91 60%, #2c6bb5 100%); color: #fff; border-radius: 1rem; padding: 1.75rem 1.75rem; position: relative; overflow: hidden; box-shadow: var(--ulk-shadow-lift); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 70%); }
.hero h1 { color: #fff; font-weight: 700; margin-bottom: 0.25rem; }
.hero p { color: rgba(255, 255, 255, 0.82); margin-bottom: 0.75rem; }
.hero .badge { background: rgba(255, 255, 255, 0.16) !important; color: #fff !important; font-weight: 550; }
.section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ulk-muted); margin: 1.75rem 0 0.75rem; }

.attention-card { display: flex; align-items: center; gap: 0.9rem; padding: 1rem 1.1rem; border-radius: var(--ulk-radius); background: #fff; box-shadow: var(--ulk-shadow); text-decoration: none; color: inherit; border-left: 4px solid var(--ulk-gold); transition: transform 0.15s, box-shadow 0.15s; height: 100%; }
.attention-card:hover { transform: translateY(-2px); box-shadow: var(--ulk-shadow-lift); color: inherit; }
.attention-card .count { font-size: 1.75rem; font-weight: 750; line-height: 1; color: var(--ulk-blue-dark); min-width: 2.2rem; text-align: center; }
.attention-card .what { font-weight: 600; line-height: 1.25; }
.attention-card .hint { color: var(--ulk-muted); font-size: 0.82rem; }
.attention-card .bi-chevron-right { margin-left: auto; color: #98a2b3; }
.all-clear { background: #eaf7ed; border-radius: var(--ulk-radius); color: #1e5a2a; padding: 1rem 1.25rem; display: flex; gap: 0.75rem; align-items: center; }

.tile { padding: 1.25rem; }
.tile .tile-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--ulk-blue-soft); color: var(--ulk-blue); font-size: 1.35rem; margin-bottom: 0.75rem; }
.tile h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: 0.2rem; }
.tile p { color: var(--ulk-muted); font-size: 0.86rem; margin-bottom: 0.9rem; }
.tile-green .tile-icon { background: #e2f3e5; color: var(--ulk-green); }
.tile-gold .tile-icon { background: #fdf0c7; color: #8a6500; }

.workspace-list { list-style: none; padding: 0; margin: 0; }
.workspace-list li { padding: 0.3rem 0; border-bottom: 1px dashed var(--ulk-line); }
.workspace-list li:last-child { border-bottom: 0; }

/* ---- sign-in pages ----------------------------------------------------- */
body.auth-page { background: radial-gradient(1200px 500px at 50% -10%, #dce8f8 0%, rgba(243, 245, 249, 0) 70%), var(--bs-body-bg); }
.auth-card { background: #fff; border-radius: 1.1rem; padding: 2rem 2rem 1.75rem; box-shadow: var(--ulk-shadow-lift); margin-top: 1.5rem; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand img { height: 84px; width: auto; margin-bottom: 0.6rem; }
.auth-brand .org { font-weight: 700; color: var(--ulk-blue-dark); line-height: 1.2; }
.auth-brand .app { color: var(--ulk-muted); font-size: 0.85rem; }
.auth-card h1 { font-size: 1.25rem; text-align: center; margin-bottom: 1rem; }
.auth-card .btn-primary { width: 100%; padding: 0.6rem; }

@media (max-width: 575.98px) {
    /* filter bars: two fields per row on a phone instead of one long column */
    form.row-cols-lg-auto > * { flex: 0 0 auto; width: 50%; }
    form.row-cols-lg-auto > *:last-child { width: 100%; }
    .app-nav .navbar-brand { max-width: 15rem; font-size: 0.88rem; }
    .app-nav .brand-logo { height: 34px; }
    .hero { padding: 1.25rem; }
    .card-body { padding: 1rem; }
    .auth-card { padding: 1.5rem 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print { .app-nav, .app-footer { display: none; } body { background: #fff; } }


/* ======================================================================
   Small screens: phones (< 768px), tablets (768-991px), small laptops
   (992-1199px). Mobile-first fixes layered on the base look above.
   ====================================================================== */
[id] { scroll-margin-top: 84px; }  /* anchors land below the sticky bar */
img, svg, video { max-width: 100%; height: auto; }
.card-body, dd, .alert, .form-text { overflow-wrap: anywhere; }  /* long names/emails never push the page wide */
/* Table cells use break-word, not anywhere: "anywhere" lets the browser shrink a
   column below its longest word, so a wide table squeezed words apart
   ("Main Ware house") instead of scrolling sideways inside .table-responsive. */
.table td, .table th { overflow-wrap: break-word; }

/* Small laptops: 6 links + the user chip must still fit on one line. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-nav .navbar-brand { max-width: 12.5rem; font-size: 0.85rem; }
    .app-nav .brand-logo { height: 34px; }
    .app-nav .nav-link { padding: 0.5rem 0.5rem; font-size: 0.86rem; white-space: nowrap; }
    .app-nav .nav-link i { display: none; }
    /* the name moves into the menu; the round initial stays as the button */
    .app-nav .user-chip > span:last-child { display: none; }
    .app-nav .user-chip { padding-right: 0.5rem; }
}

/* Tablets and phones: the menu opens as a tidy panel. */
@media (max-width: 991.98px) {
    .app-nav .navbar-collapse { padding: 0.5rem 0 0.75rem; }
    .app-nav .navbar-nav { gap: 0.15rem; }
    .app-nav .nav-link { padding: 0.65rem 0.85rem; }
    .app-nav .dropdown { margin-top: 0.5rem; padding-top: 0.6rem; border-top: 1px solid rgba(255, 255, 255, 0.18); }
    .app-nav .user-chip { width: 100%; justify-content: flex-start; }
    .app-nav .dropdown-menu { width: 100%; }
}

/* Phones and portrait tablets */
@media (max-width: 767.98px) {
    /* 16px+ text in fields stops iOS from zooming the page when one is tapped */
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px !important; }

    /* Filter bars fold away behind a button (see app.js) */
    form.filters-collapsed { display: none !important; }
    .filter-toggle + form { margin-top: 1rem; }

    /* Pagination / export bars wrap instead of squeezing */
    .pagination { flex-wrap: wrap; }
    .hero h1 { font-size: 1.35rem; }
    h1.h3 { font-size: 1.4rem; }
    .btn-lg { width: 100%; }
    dl.row dt { margin-top: 0.5rem; }
    dl.row dd { margin-bottom: 0.15rem; }
}

/* Touch screens (any width): comfortable tap targets */
@media (pointer: coarse) {
    .btn-sm { --bs-btn-padding-y: 0.5rem; --bs-btn-padding-x: 0.85rem; --bs-btn-font-size: 0.9rem; }
    .btn-link.btn-sm, .btn.p-0 { padding: 0.35rem 0.25rem !important; }
    .form-control-sm, .form-select-sm { min-height: 42px; padding: 0.45rem 0.7rem; }
    .dropdown-item { padding: 0.65rem 0.9rem; }
    .page-link { padding: 0.55rem 0.85rem; }
    .form-check-input { width: 1.3em; height: 1.3em; }
    .workspace-list li { padding: 0.5rem 0; }
}

.filter-toggle { display: flex; align-items: center; }
@media (min-width: 768px) { .filter-toggle { display: none; } }

/* Tablets and phones: list tables become cards */
@media (max-width: 991.98px) {
    /* List tables turn into one card per row (two across on a tablet), labelled from the column headers (see app.js) */
    .table-responsive.has-cards { box-shadow: none; background: transparent; overflow: visible; border-radius: 0; }
    table.table.table-cards, table.table.table-cards tbody, table.table.table-cards tr, table.table.table-cards td { display: block; width: 100%; }
    table.table.table-cards thead { display: none; }
    table.table.table-cards { background: transparent !important; }
    table.table.table-cards tr { background: #fff; border-radius: var(--ulk-radius); box-shadow: var(--ulk-shadow); margin-bottom: 0.8rem; padding: 0.35rem 0; }
    table.table.table-cards > tbody > tr > td { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 0.4rem 1rem; border: 0; text-align: right; background: transparent; }
    table.table.table-cards > tbody > tr > td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; color: var(--ulk-muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 0.25rem; }
    table.table.table-cards > tbody > tr > td:not([data-label])::before, table.table.table-cards > tbody > tr > td[colspan]::before { display: none; }
    table.table.table-cards > tbody > tr > td[colspan] { display: block; text-align: left; }
    table.table.table-cards .cell-value { display: block; flex: 1 1 auto; min-width: 0; }
    table.table.table-cards > tbody > tr:hover > * { background: transparent; }
    table.table.table-cards > tbody > tr > td:first-child { padding-top: 0.6rem; }
    table.table.table-cards > tbody > tr > td:last-child { padding-bottom: 0.6rem; }

    table.table.table-cards > tbody { display: grid; grid-template-columns: 1fr; gap: 0.8rem; }
    table.table.table-cards > tbody > tr { margin-bottom: 0; }
    table.table.table-cards > tbody > tr:has(> td[colspan]) { grid-column: 1 / -1; }
}
@media (min-width: 576px) and (max-width: 991.98px) {
    table.table.table-cards > tbody { grid-template-columns: 1fr 1fr; }
    /* Filter bars: three across rather than one long column */
    form.row-cols-lg-auto > * { flex: 0 0 auto; width: 33.333%; }
    form.row-cols-lg-auto > *:last-child { width: 100%; }
}

/* Actions card: the one place a decision is made, so it carries a coloured edge
   and its buttons are full-size (see core_tags.action_class for the colours). */
.actions-card { border-left: 4px solid var(--ulk-blue); }
.actions-card .btn { min-height: 44px; }
@media (max-width: 575.98px) { .actions-card .btn { flex: 1 1 100%; } }
