/* ============================================================
   Logical View Solutions — CPD & Training Platform
   Design system: deep petrol + gold, IBM Plex + Bricolage
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --petrol:    #0D2B3E;
  --petrol-2:  #14425E;
  --petrol-3:  #1B5578;
  --gold:      #E8A33D;
  --gold-soft: #F7E3C2;
  --paper:     #F3F4F2;
  --card:      #FFFFFF;
  --line:      #DEE4E7;
  --ink:       #15252F;
  --muted:     #5C6F7B;
  --danger:    #C03E2E;
  --danger-bg: #FAE9E6;
  --green:     #2E7D5B;
  --green-bg:  #E4F2EB;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(13,43,62,.06), 0 8px 24px rgba(13,43,62,.07);
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-disp: 'Bricolage Grotesque', var(--font-body);
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--petrol-2); }

h1, h2, h3, .display {
  font-family: var(--font-disp);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--petrol);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

.mono { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .02em; }
.muted { color: var(--muted); }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- App shells ---------- */
.shell { display: flex; min-height: 100vh; }

/* Admin sidebar */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--petrol);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 1.5rem 1rem;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  font-family: var(--font-disp); font-weight: 700; font-size: 1.05rem;
  color: #fff; text-decoration: none; line-height: 1.3;
  padding: 0 .75rem 1.25rem; display: block;
  border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 1.25rem;
}
.sidebar .brand small {
  display: block; font-family: var(--font-mono); font-weight: 400;
  font-size: .68rem; color: var(--gold); letter-spacing: .14em;
  text-transform: uppercase; margin-top: .3rem;
}
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar nav a {
  color: rgba(255,255,255,.78); text-decoration: none;
  padding: .6rem .75rem; border-radius: 8px;
  font-size: .92rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active {
  background: rgba(255,255,255,.1); color: #fff;
  border-left-color: var(--gold);
}
.sidebar .who {
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 1rem; margin-top: 1rem;
}
.sidebar .who .name { font-size: .88rem; font-weight: 600; color: #fff; }
.sidebar .who .role { font-family: var(--font-mono); font-size: .68rem; color: var(--gold); letter-spacing: .1em; text-transform: uppercase; }

.main { flex: 1; padding: 2rem 2.25rem 4rem; min-width: 0; }

/* User topbar */
.topbar {
  background: var(--petrol); color: #fff;
  padding: .8rem 1.5rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.topbar .brand { font-family: var(--font-disp); font-weight: 700; color: #fff; text-decoration: none; }
.topbar .brand small { font-family: var(--font-mono); font-size: .65rem; color: var(--gold); letter-spacing: .14em; text-transform: uppercase; display: block; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a {
  color: rgba(255,255,255,.8); text-decoration: none; font-size: .9rem; font-weight: 500;
  padding: .45rem .8rem; border-radius: 8px;
}
.topbar nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }
.topbar .who { display: flex; align-items: center; gap: .8rem; font-size: .88rem; }

.page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ---------- Page headers ---------- */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head .eyebrow {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gold); font-weight: 500; margin-bottom: .35rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .card-body { padding: 1.25rem; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; max-width: 640px; margin: 0 auto; }

/* Course cards */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.course-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  position: relative; transition: transform .15s, box-shadow .15s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(13,43,62,.08), 0 16px 36px rgba(13,43,62,.12); }
.course-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--gold); z-index: 1;
}
.course-card .cover { height: 160px; background: var(--petrol-2); }
.course-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.course-card .body { padding: 1.1rem 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.course-card .title { font-family: var(--font-disp); font-weight: 600; font-size: 1.05rem; color: var(--petrol); }
.course-card .desc { font-size: .88rem; color: var(--muted); flex: 1; }
.course-card .meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-family: var(--font-mono); font-size: .74rem; color: var(--muted); }
.course-card .meta strong { color: var(--ink); font-weight: 500; }

.chip {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em;
  background: var(--petrol); color: var(--gold);
  border-radius: 5px; padding: .2rem .5rem; align-self: flex-start;
}

/* capacity bar */
.cap { height: 5px; background: var(--line); border-radius: 99px; overflow: hidden; }
.cap > span { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.cap.full > span { background: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--font-body); font-weight: 600; font-size: .88rem;
  border: 1px solid transparent; border-radius: 8px;
  padding: .55rem 1.1rem; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-2); }
.btn-gold { background: var(--gold); color: var(--petrol); }
.btn-gold:hover { background: #f0b258; }
.btn-ghost { background: transparent; color: var(--petrol); border-color: var(--line); }
.btn-ghost:hover { background: #fff; border-color: var(--petrol-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a8331f; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: var(--petrol); }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.form-control, select.form-control {
  width: 100%; font: inherit; font-size: .92rem;
  padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--petrol-2); box-shadow: 0 0 0 3px rgba(20,66,94,.14); }

/* ---------- Tables ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; font-family: var(--font-mono); font-weight: 500; font-size: .68rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: #FAFBFA;
  white-space: nowrap;
}
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #F7F9F9; }
.table .thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; }

.badge {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em;
  padding: .2rem .55rem; border-radius: 99px; white-space: nowrap;
}
.badge-admin { background: var(--gold-soft); color: #8a5a10; }
.badge-user  { background: #E2ECF2; color: var(--petrol-2); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red   { background: var(--danger-bg); color: var(--danger); }

/* ---------- Alerts / empty states ---------- */
.alert { border-radius: var(--radius); padding: .85rem 1.1rem; font-size: .9rem; margin-bottom: 1.25rem; border: 1px solid; }
.alert-danger  { background: var(--danger-bg); color: var(--danger); border-color: #efc9c2; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: #c4e2d3; }
.alert-info    { background: #E7F0F5; color: var(--petrol-2); border-color: #c9dde8; }

.empty {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); background: #FBFCFB;
}
.empty .mono { color: var(--gold); display: block; margin-bottom: .4rem; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.stat .num { font-family: var(--font-disp); font-weight: 700; font-size: 1.7rem; color: var(--petrol); line-height: 1.1; }
.stat .lbl { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- Search ---------- */
.search-bar { display: flex; gap: .5rem; max-width: 560px; margin-bottom: 1.75rem; }
.search-bar .form-control { flex: 1; }

/* ---------- Section labels ---------- */
.section-label {
  display: flex; align-items: center; gap: .75rem;
  margin: 2.25rem 0 1rem;
}
.section-label h2 { white-space: nowrap; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-label .count { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }

/* ---------- Login ---------- */
.auth-layout { display: grid; grid-template-columns: minmax(380px, 480px) 1fr; min-height: 100vh; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; background: var(--paper); }
.auth-form .inner { width: 100%; max-width: 360px; }
.auth-panel {
  background:
    radial-gradient(circle at 78% 30%, rgba(232,163,61,.16) 0, rgba(232,163,61,0) 26%),
    linear-gradient(160deg, var(--petrol-2) 0%, var(--petrol) 65%);
  color: #fff; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; padding: 4rem;
}
/* aperture rings — the "view" in Logical View */
.auth-panel::before, .auth-panel::after {
  content: ""; position: absolute; border-radius: 50%;
  border: 1.5px solid rgba(232,163,61,.45);
}
.auth-panel::before { width: 520px; height: 520px; top: -120px; right: -120px; }
.auth-panel::after  { width: 340px; height: 340px; top: -30px; right: -30px; border-color: rgba(255,255,255,.22); }
.auth-panel .tagline { max-width: 30rem; position: relative; z-index: 1; }
.auth-panel .tagline .mono { color: var(--gold); letter-spacing: .16em; text-transform: uppercase; }
.auth-panel .tagline h2 { color: #fff; font-size: 2rem; margin: .6rem 0 .8rem; }
.auth-panel .tagline p { color: rgba(255,255,255,.75); font-size: .95rem; }

/* ---------- Detail (course join) ---------- */
.detail { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.detail .cover { min-height: 320px; background: var(--petrol-2); }
.detail .cover img { width: 100%; height: 100%; object-fit: cover; }
.detail .info { padding: 2rem; display: flex; flex-direction: column; gap: .9rem; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1.2rem; font-size: .9rem; }
.detail dt { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-top: .15rem; }
.detail dd { font-weight: 500; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .9rem 1rem; }
  .sidebar .brand { border: none; padding: 0 .5rem 0 0; margin: 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { border-left: none; border-bottom: 2px solid transparent; }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--gold); }
  .sidebar .who { border: none; margin: 0; padding: 0; margin-left: auto; display: flex; align-items: center; gap: .8rem; }
  .main { padding: 1.5rem 1rem 3rem; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-panel { display: none; }
  .detail { grid-template-columns: 1fr; }
  .detail .cover { min-height: 200px; }
}

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