/**
 * UniHouse console skin
 * =====================
 * The look shared by the admin area and the agent / landlord area. Loaded
 * after dashboard.css on those pages only (the student and union areas keep
 * their own look), and scoped under body.console-shell: that keeps it out of
 * the other areas even if linked by mistake, and gives it enough weight to win
 * over the per-page <style> blocks that still hard-code the old ink colours.
 *
 * Colour comes from the UniHouse mark: its blue carries actions and focus,
 * its orange is kept for the few things that should catch the eye. Cards and
 * icon tiles rotate through a set of tones so a screen of them reads as
 * distinct things rather than one grey grid.
 *
 * The sidebar (.console-side) is rendered by UniHouseUI.sideNav in js/ui.js.
 */

body.console-shell {
  --a-blue: #2563eb;
  --a-blue-600: #1d4ed8;
  --a-blue-50: #eff6ff;
  --a-blue-100: #dbeafe;
  --a-orange: #f59e0b;
  --a-navy: #0f172a;
  --a-navy-2: #16213b;
  --a-ink: #0f172a;
  --a-text: #334155;
  --a-muted: #64748b;
  --a-line: #e6eaf2;
  --a-line-soft: #eef1f7;
  --a-bg: #f4f6fb;
  --a-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
  --a-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.02);
  --a-shadow-2: 0 10px 30px -14px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.04);
  --a-shadow-3: 0 22px 44px -20px rgba(37, 99, 235, 0.35), 0 4px 12px rgba(15, 23, 42, 0.06);
  --side-w: 240px;

  /* Default tone; cards override it by position. */
  --tone: #2563eb;
  --tone-soft: #eff6ff;

  background:
    radial-gradient(1200px 420px at 100% -10%, rgba(37, 99, 235, 0.07), transparent 60%),
    radial-gradient(900px 380px at -10% 0%, rgba(245, 158, 11, 0.05), transparent 55%),
    var(--a-bg);
  background-attachment: fixed;
  color: var(--a-ink);
}

/* ---------- Tones ----------
   Eight, in an order where neighbours never share a hue. */
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 1) { --tone: #2563eb; --tone-soft: #eff6ff; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 2) { --tone: #059669; --tone-soft: #ecfdf5; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 3) { --tone: #d97706; --tone-soft: #fffbeb; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 4) { --tone: #7c3aed; --tone-soft: #f5f3ff; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 5) { --tone: #0891b2; --tone-soft: #ecfeff; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 6) { --tone: #e11d48; --tone-soft: #fff1f2; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 7) { --tone: #ea580c; --tone-soft: #fff7ed; }
body.console-shell :is(.stat-grid > .stat-card, .action-grid > .action-card):nth-child(8n + 8) { --tone: #4f46e5; --tone-soft: #eef2ff; }

/* ---------- Top bar ---------- */
body.console-shell .dash-nav {
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--a-line);
}

body.console-shell .dash-role-tag {
  background: linear-gradient(135deg, var(--a-blue), var(--a-blue-600));
  border-radius: 6px;
  padding: 0.18rem 0.45rem;
  box-shadow: 0 4px 10px -4px rgba(37, 99, 235, 0.6);
}

/* ---------- Tab strip (tablet widths, before the sidebar takes over) ---------- */
body.console-shell .dash-tabs {
  background: rgba(255, 255, 255, 0.92);
  border-bottom-color: var(--a-line);
}
body.console-shell .dash-tab { color: var(--a-muted); }
body.console-shell .dash-tab:hover { color: var(--a-blue); }
body.console-shell .dash-tab.active { color: var(--a-blue); }
body.console-shell .uh-tab-underline { background: var(--a-blue); height: 3px; border-radius: 3px 3px 0 0; }
body.console-shell .dash-tab-badge { background: #e11d48; }

/* ---------- Sidebar ----------
   Rendered by UniHouseUI.sideNav for the admin and agent / landlord shells:
   every screen, grouped, one click away. The layout rules key off
   .has-console-side (set in those pages' markup, so nothing jumps when the
   sidebar arrives), which lets the student area use this skin without one. */
.console-side { display: none; }

@media (min-width: 1100px) {
  body.has-console-side .console-side {
    position: fixed;
    top: var(--uh-nav-h, 62px);
    bottom: 0;
    left: 0;
    z-index: 990;
    width: var(--side-w);
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0.85rem 1rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    background:
      radial-gradient(420px 260px at 0% 0%, rgba(37, 99, 235, 0.28), transparent 70%),
      linear-gradient(180deg, var(--a-navy-2), var(--a-navy));
    color: rgba(255, 255, 255, 0.78);
  }

  body.has-console-side .dash-tabs { display: none !important; }
  body.has-console-side .dash-nav-inner { max-width: none; }

  body.has-console-side .dash-main {
    max-width: none;
    margin-left: var(--side-w);
    padding-left: clamp(1.5rem, 2.6vw, 2.75rem) !important;
    padding-right: clamp(1.5rem, 2.6vw, 2.75rem) !important;
  }

  /* Keep very wide screens from stretching tables into a single line. */
  body.has-console-side .dash-main > * { max-width: 1320px; }

  /* Row buttons stay on one line; a narrow table scrolls instead. */
  body.console-shell .row-actions { flex-wrap: nowrap; }
}

@media (min-width: 1440px) {
  body.console-shell { --side-w: 268px; }
}

.console-side-group + .console-side-group { margin-top: 1.1rem; }

.console-side-title {
  padding: 0 0.75rem 0.4rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.console-side a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border-radius: 11px;
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  transition: background 0.16s, color 0.16s;
}

.console-side a i {
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.16s;
}

.console-side a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.console-side a:hover i { color: #fff; }

.console-side a.is-active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(37, 99, 235, 0.95));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 22px -12px rgba(59, 130, 246, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.console-side a.is-active i { color: #fff; }

.console-side a:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

.console-side-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--a-orange);
  color: #1a1206;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.console-side-foot {
  margin-top: auto;
  padding-top: 1rem;
}

.console-side-card {
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.6);
}

.console-side-card strong { display: block; margin-bottom: 0.15rem; color: #fff; font-size: 0.84rem; }

.console-side .console-side-card a {
  min-height: 0;
  margin-top: 0.6rem;
  padding: 0.45rem 0.7rem;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}
.console-side .console-side-card a:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- Page heading ---------- */
body.console-shell .dash-head { margin-bottom: 1.75rem; }

body.console-shell .dash-head h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.05rem);
  letter-spacing: -0.035em;
  color: var(--a-ink);
}

body.console-shell .dash-head p { color: var(--a-muted); }

/* Dashboard welcome banner */
body.console-shell .dash-head.console-hero {
  position: relative;
  overflow: hidden;
  align-items: center;
  padding: clamp(1.4rem, 3vw, 2.1rem) clamp(1.25rem, 3vw, 2.25rem);
  border-radius: 22px;
  background:
    radial-gradient(520px 260px at 92% 10%, rgba(245, 158, 11, 0.32), transparent 62%),
    radial-gradient(620px 300px at 0% 120%, rgba(59, 130, 246, 0.55), transparent 60%),
    linear-gradient(120deg, #0f172a 0%, #1e3a8a 58%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 24px 50px -28px rgba(30, 58, 138, 0.75);
}

/* Faint house outline - the mark, abstracted. */
body.console-shell .dash-head.console-hero::after {
  content: '';
  position: absolute;
  right: -40px;
  bottom: -70px;
  width: 280px;
  height: 280px;
  border: 26px solid rgba(255, 255, 255, 0.06);
  border-radius: 48px;
  transform: rotate(45deg);
  pointer-events: none;
}

body.console-shell .dash-head.console-hero > * { position: relative; z-index: 1; }
body.console-shell .dash-head.console-hero h1 { color: #fff; font-size: clamp(1.7rem, 3vw, 2.4rem); }
body.console-shell .dash-head.console-hero p { color: rgba(255, 255, 255, 0.78); max-width: 560px; }

.console-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fde68a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.console-shell .dash-head.console-hero .btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
body.console-shell .dash-head.console-hero .btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
  border-color: #fff;
}

/* ---------- Stat cards ---------- */
body.console-shell .stat-grid { gap: 1.1rem; }

body.console-shell .stat-card {
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: 18px;
  padding: 1.3rem 1.35rem 1.25rem;
  box-shadow: var(--a-shadow-2);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

body.console-shell .stat-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--tone) 28%, var(--a-line));
  box-shadow: 0 20px 40px -22px color-mix(in srgb, var(--tone) 55%, transparent), 0 2px 6px rgba(15, 23, 42, 0.05);
}

body.console-shell .stat-card::before {
  height: 4px;
  background: linear-gradient(90deg, var(--tone), color-mix(in srgb, var(--tone) 35%, transparent) 70%, transparent);
}

body.console-shell .stat-card::after {
  background: radial-gradient(circle, color-mix(in srgb, var(--tone) 14%, transparent), transparent 68%);
}

body.console-shell .stat-label { color: var(--a-muted); letter-spacing: 0.06em; }

body.console-shell .stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--tone-soft);
  color: var(--tone);
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 18%, transparent);
}

body.console-shell .stat-value {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--a-ink);
  letter-spacing: -0.04em;
}

body.console-shell .stat-card.loading .stat-value {
  color: transparent;
  -webkit-text-fill-color: transparent;
  background: linear-gradient(90deg, #eef1f7 25%, #e3e8f1 37%, #eef1f7 63%);
  background-size: 400% 100%;
}

body.console-shell .stat-sub { color: var(--a-muted); }

/* ---------- Panels ---------- */
body.console-shell .panel {
  border-color: var(--a-line);
  border-radius: 20px;
  box-shadow: var(--a-shadow-2);
}

body.console-shell .panel-head {
  padding: 1.05rem 1.4rem;
  border-bottom-color: var(--a-line-soft);
  background: linear-gradient(180deg, #fbfcfe, #fff);
}

body.console-shell .panel-head h2 { color: var(--a-ink); font-size: 1rem; }

body.console-shell .panel-head h2 i {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--a-blue-50);
  color: var(--a-blue);
  font-size: 0.8rem;
}

/* ---------- Quick actions ---------- */
body.console-shell .action-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
}

body.console-shell .action-card {
  background: #fff;
  border-color: var(--a-line);
  border-radius: 16px;
  padding: 1.1rem 1.1rem 1.15rem;
  box-shadow: var(--a-shadow-1);
}

body.console-shell .action-card:hover {
  border-color: color-mix(in srgb, var(--tone) 45%, var(--a-line));
  box-shadow: 0 18px 36px -20px color-mix(in srgb, var(--tone) 60%, transparent), 0 2px 6px rgba(15, 23, 42, 0.05);
}

body.console-shell .action-card i {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--tone-soft);
  color: var(--tone);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 18%, transparent);
  transition: transform 0.2s, background 0.2s, color 0.2s;
}

body.console-shell .action-card:hover i { background: var(--tone); color: #fff; }

body.console-shell .action-card strong { color: var(--a-ink); font-weight: 700; }
body.console-shell .action-card span { color: var(--a-muted); line-height: 1.45; }
body.console-shell .action-card strong .pill { color: #b91c1c; }

/* ---------- Tables ---------- */
body.console-shell .dash-table th {
  background: #f8fafc;
  color: var(--a-muted);
  border-bottom: 1px solid var(--a-line);
  letter-spacing: 0.06em;
}

body.console-shell .dash-table td { border-bottom-color: var(--a-line-soft); color: var(--a-text); }
body.console-shell .dash-table tbody tr:hover { background: #f7faff; }
body.console-shell .cell-main { color: var(--a-ink); }
body.console-shell .cell-sub { color: var(--a-muted); }

/* ---------- Pills: a dot makes status scannable at a glance ---------- */
body.console-shell .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

body.console-shell :is(.dash-table, .req-card, .kv) .pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

body.console-shell .pill.green { background: #ecfdf5; color: #047857; }
body.console-shell .pill.amber { background: #fffbeb; color: #b45309; }
body.console-shell .pill.red { background: #fff1f2; color: #be123c; }
body.console-shell .pill.blue { background: var(--a-blue-50); color: var(--a-blue-600); }

/* ---------- Buttons ---------- */
body.console-shell .btn {
  border-color: var(--a-line);
  border-radius: 11px;
  color: var(--a-text);
  background: #fff;
  font-weight: 600;
}

body.console-shell .btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--a-blue) 45%, var(--a-line));
  color: var(--a-blue-600);
  background: #fbfcff;
}

body.console-shell .btn.primary {
  background: linear-gradient(135deg, #3b82f6, var(--a-blue-600));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(37, 99, 235, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

body.console-shell .btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  border-color: transparent;
}

body.console-shell .btn.danger { color: #be123c; border-color: #fecdd3; background: #fff; }
body.console-shell .btn.danger:hover:not(:disabled) { color: #fff; background: #e11d48; border-color: #e11d48; }

/* ---------- Filters and search ---------- */
body.console-shell .filter-chip {
  border-color: var(--a-line);
  background: #fff;
  color: var(--a-muted);
}

body.console-shell .filter-chip:hover { border-color: var(--a-blue); color: var(--a-blue-600); }

body.console-shell .filter-chip.active {
  background: var(--a-ink);
  border-color: var(--a-ink);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(15, 23, 42, 0.7);
}

body.console-shell .search-box input {
  border-color: var(--a-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--a-shadow-1);
}

body.console-shell .search-box input:focus { border-color: var(--a-blue); box-shadow: var(--a-ring); }

/* ---------- Forms ---------- */
body.console-shell .field label { color: var(--a-text); }

body.console-shell .field input,
body.console-shell .field select,
body.console-shell .field textarea {
  border-color: var(--a-line);
  background: #fbfcfe;
  color: var(--a-ink);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

body.console-shell .field input:hover,
body.console-shell .field select:hover,
body.console-shell .field textarea:hover { border-color: #cbd5e1; }

body.console-shell .field input:focus,
body.console-shell .field select:focus,
body.console-shell .field textarea:focus {
  border-color: var(--a-blue);
  background: #fff;
  box-shadow: var(--a-ring);
}

body.console-shell .field .help,
body.console-shell .help { color: var(--a-muted); }

body.console-shell .check-row input,
body.console-shell input[type="checkbox"],
body.console-shell input[type="radio"] { accent-color: var(--a-blue); }

body.console-shell .chip-pick.on { background: var(--a-blue); border-color: var(--a-blue); }

/* ---------- Notices and empty states ---------- */
body.console-shell .notice { border-radius: 14px; }
body.console-shell .notice.blue { background: var(--a-blue-50); border-color: var(--a-blue-100); color: var(--a-blue-600); }

body.console-shell .state i {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.9rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--a-blue-50);
  color: #93c5fd;
  font-size: 1.5rem;
}

body.console-shell .state h3 { color: var(--a-ink); }
body.console-shell .state p { color: var(--a-muted); }

/* ---------- Focus ---------- */
body.console-shell :focus-visible { outline-color: var(--a-blue); }

@media (prefers-reduced-motion: reduce) {
  body.console-shell .stat-card,
  body.console-shell .stat-card:hover,
  body.console-shell .action-card i { transition: none; transform: none; }
}

/* ---------- Phone drawer (built by js/nav.js from the same groups) ---------- */
body.console-shell .uh-drawer nav a.is-active {
  background: var(--a-blue-50);
  border-left-color: var(--a-blue);
  color: var(--a-blue-600);
}
body.console-shell .uh-drawer nav a.is-active i { color: var(--a-blue); }

/* The banner's main action stays solid so it reads first on the dark ground. */
body.console-shell .dash-head.console-hero .btn.primary {
  background: #fff;
  border-color: #fff;
  color: var(--a-navy);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.5);
}
body.console-shell .dash-head.console-hero .btn.primary:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #eef2ff;
  color: var(--a-navy);
}
