/* Faculty ERP — institutional UI.
 *
 * Section 49 is explicit: minimal, clear, professional. No gradients, no
 * glassmorphism, no animation, no neon. One accent colour, restrained
 * cards, readable tables. This file layers on Bootstrap rather than
 * fighting it.
 */

:root {
  --ink:        #1a1f27;
  --ink-2:      #4a5361;
  --ink-3:      #7a8494;
  --rule:       #dfe3e9;
  --rule-soft:  #edf0f4;
  --paper:      #f5f7f9;
  --card:       #ffffff;
  --accent:     #2d4a7c;
  --accent-soft:#eef2f8;

  /* Status colours. Never used alone — every badge carries text too
   * (Section 58, 86A.19), so colour-blind users lose nothing. */
  --st-verified:  #23694a;  --st-verified-bg:  #e7f1ec;
  --st-pending:   #8a5a12;  --st-pending-bg:   #f8f1e3;
  --st-correction:#983127;  --st-correction-bg:#f9eae8;
  --st-draft:     #5f6a79;  --st-draft-bg:     #eceff3;
  --st-archived:  #6b7280;  --st-archived-bg:  #eef0f3;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
}

/* ── navigation ───────────────────────────────────────────────── */
.app-nav {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  padding: .35rem 0;
}
.app-nav .navbar-brand { font-weight: 600; color: var(--accent); font-size: 1rem; }
.app-nav .nav-link { color: var(--ink-2); font-size: .9rem; }
.app-nav .nav-link:hover { color: var(--accent); }
.role-chip {
  font-size: .75rem !important;
  color: var(--accent) !important;
  background: var(--accent-soft);
  border-radius: 3px;
  padding: .2rem .5rem !important;
}

.app-main { max-width: 1400px; padding: 1.5rem 1.25rem 4rem; }

/* ── headings ─────────────────────────────────────────────────── */
.page-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.1rem; }
.section-title {
  font-size: .78rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 1.8rem 0 .7rem;
}
.note { font-size: .82rem; color: var(--ink-3); margin-top: .5rem; }

/* ── stat cards ───────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: .75rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .8rem .9rem;
}
.stat-n {
  font-size: 1.45rem; font-weight: 600; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-l { font-size: .76rem; color: var(--ink-3); margin-top: .15rem; }

/* ── tables ───────────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.table { margin-bottom: 0; font-size: .875rem; }
.table > thead th {
  font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
  border-bottom: 1px solid var(--rule); background: var(--paper);
}
.table > tbody td { border-color: var(--rule-soft); vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: .82rem; }

/* ── status badges ────────────────────────────────────────────── */
.status {
  display: inline-block; font-size: .72rem; font-weight: 600;
  padding: .15rem .45rem; border-radius: 3px; white-space: nowrap;
}
.status-verified, .status-active   { background: var(--st-verified-bg); color: var(--st-verified); }
.status-pending                    { background: var(--st-pending-bg); color: var(--st-pending); }
.status-correction                 { background: var(--st-correction-bg); color: var(--st-correction); }
.status-draft                      { background: var(--st-draft-bg); color: var(--st-draft); }
.status-archived, .status-inactive,
.status-resigned, .status-retired,
.status-transferred,
.status-contract_ended             { background: var(--st-archived-bg); color: var(--st-archived); }

/* ── filters & forms ──────────────────────────────────────────── */
.filter-row {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  margin-bottom: 1rem;
}
.filter-row .form-control, .filter-row .form-select { max-width: 260px; }
.inline-form { display: inline-block; margin: 0; }
.narrow-form { max-width: 460px; background: var(--card); padding: 1.25rem;
               border: 1px solid var(--rule); border-radius: 4px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ── profile ──────────────────────────────────────────────────── */
.profile-head {
  display: grid; gap: 1.25rem; align-items: start;
  grid-template-columns: 1fr;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: 4px; padding: 1.25rem; margin-bottom: 1.25rem;
}
@media (min-width: 820px) {
  .profile-head { grid-template-columns: 90px 1fr 220px; }
}
.photo-blank {
  width: 90px; height: 90px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 600;
}
.profile-facts { display: grid; grid-template-columns: auto 1fr; gap: .2rem .9rem;
                 margin: 0; font-size: .85rem; }
.profile-facts dt { color: var(--ink-3); font-weight: 500; }
.profile-facts dd { margin: 0; }
.completion-label { font-size: .76rem; color: var(--ink-3); margin-bottom: .3rem; }
.completion-pct { font-size: .8rem; color: var(--ink-2); margin-top: .25rem;
                  font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--rule-soft); }
.progress-bar { background: var(--accent); }

.profile-tabs { border-bottom: 1px solid var(--rule); margin-bottom: 1rem; flex-wrap: wrap; }
.profile-tabs .nav-link { font-size: .85rem; color: var(--ink-2); border: none;
                          border-bottom: 2px solid transparent; }
.profile-tabs .nav-link.active { color: var(--accent); border-bottom-color: var(--accent);
                                 background: none; }
.tab-body { background: var(--card); border: 1px solid var(--rule);
            border-radius: 4px; padding: 1.1rem; }

.two-col { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 820px) { .two-col { grid-template-columns: 1fr 1fr; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem;
      font-size: .875rem; margin: 0; }
.kv dt { color: var(--ink-3); font-weight: 500; }
.kv dd { margin: 0; }

/* ── activity feed ────────────────────────────────────────────── */
.activity { list-style: none; padding: 0; margin: 0;
            background: var(--card); border: 1px solid var(--rule); border-radius: 4px; }
.activity li { padding: .55rem .9rem; border-bottom: 1px solid var(--rule-soft);
               font-size: .86rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.activity li:last-child { border-bottom: none; }
.activity-time { color: var(--ink-3); font-variant-numeric: tabular-nums;
                 min-width: 96px; font-size: .8rem; }
.activity-actor { font-weight: 600; }
.activity-verb { color: var(--ink-2); }
.activity-detail { color: var(--ink-3); font-size: .82rem; }

/* ── empty states (Section 59) ────────────────────────────────── */
.empty-state {
  background: var(--card); border: 1px dashed var(--rule);
  border-radius: 4px; padding: 2rem 1.25rem; text-align: center;
}

/* ── login ────────────────────────────────────────────────────── */
.login-wrap { display: flex; justify-content: center; padding: 4rem 1rem; }
.login-card { background: var(--card); border: 1px solid var(--rule);
              border-radius: 4px; padding: 2rem; width: 100%; max-width: 380px; }

/* ── accessibility ────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #24406e; border-color: #24406e; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── reports ──────────────────────────────────────────────────── */
.report-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.report-card {
  display: block; background: var(--card); border: 1px solid var(--rule);
  border-radius: 4px; padding: .9rem 1rem; text-decoration: none; color: inherit;
}
.report-card:hover { border-color: var(--accent); }
.report-title { font-weight: 600; color: var(--accent); margin-bottom: .2rem; }
.report-desc { font-size: .82rem; color: var(--ink-3); }

.filter-panel {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end;
  background: var(--card); border: 1px solid var(--rule); border-radius: 4px;
  padding: .8rem .9rem; margin-bottom: 1rem;
}
.fl { display: flex; flex-direction: column; gap: .15rem; font-size: .76rem;
      color: var(--ink-3); }
.fl select, .fl input { min-width: 150px; }

.table-report { font-size: .82rem; white-space: nowrap; }
.table-report td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

.naac-grid { display: grid; gap: 1rem;
             grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.naac-card { background: var(--card); border: 1px solid var(--rule);
             border-radius: 4px; padding: 1rem 1.1rem; }

/* ── forms ────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 0 1rem;
             grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid > .mb-3:has(textarea) { grid-column: 1 / -1; }
.req { color: var(--st-correction); margin-left: .15rem; }
.field-error { color: var(--st-correction); font-size: .8rem; margin-top: .2rem; }
.has-error .form-control, .has-error .form-select { border-color: var(--st-correction); }
.correction-note { font-size: .8rem; color: var(--st-correction);
                   background: var(--st-correction-bg); border-radius: 3px;
                   padding: .3rem .5rem; margin-top: .3rem; }
.doc-chip { display: inline-block; font-size: .75rem; background: var(--accent-soft);
            color: var(--accent); border-radius: 3px; padding: .1rem .4rem;
            margin: .1rem .15rem .1rem 0; text-decoration: none; }
.shared-chip { color: var(--accent); }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-left: .2rem; }
.list-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start;
             justify-content: space-between; margin-bottom: 1rem; }
.dup-card { background: var(--paper); border: 1px solid var(--rule);
            border-radius: 3px; padding: .7rem .8rem; }

/* ── toasts ───────────────────────────────────────────────────── */
.toast-host { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080;
              display: flex; flex-direction: column; gap: .4rem; }
.app-toast { background: var(--ink); color: #fff; border-radius: 4px;
             padding: .55rem .8rem; font-size: .85rem; max-width: 340px; }

/* Counting policy — always shown beside an institutional figure, so a
   number is never presented without its definition. */
.policy-note {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 3px; padding: .6rem .8rem; margin-top: 1rem;
  font-size: .82rem; color: var(--ink-2); max-width: 80ch;
}
.policy-note strong { color: var(--accent); }

/* ── scrollable modals whose form wraps body + footer ─────────────
 * Bootstrap's .modal-dialog-scrollable puts overflow-y:auto on
 * .modal-body and expects it to be a direct flex child of
 * .modal-content. Our forms wrap the body and footer together, so the
 * <form> becomes the flex item instead: it cannot shrink, the body
 * never gets a bounded height, and overflow-y has nothing to act on.
 * On a phone that meant the fields below the fold — and the Save
 * button — were simply unreachable.
 *
 * min-height:0 is the load-bearing part. Flex items default to
 * min-height:auto, which refuses to shrink below content size.
 */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
/* Keep the actions reachable rather than scrolling away with the fields. */
.modal-dialog-scrollable .modal-content > form > .modal-footer {
  flex: 0 0 auto;
}

@media (max-width: 576px) {
  /* Use the full screen on a phone; a centred card wastes the height
     the form actually needs. */
  .modal-dialog { margin: .5rem; }
  .modal-dialog-scrollable { height: calc(100% - 1rem); }
  .modal-footer { position: sticky; bottom: 0; background: var(--card);
                  border-top: 1px solid var(--rule); }
  .modal-footer .btn { flex: 1 1 auto; }
}
