/* ------------------------------------------------------------- tokens */

/* Palette and type matched to the TAFE Queensland Design Kit (TQDSK v2.0.4):
   brand red #CC3300, text #333, borders #DDD, success #288511, 4px radius,
   Helvetica Neue / Arial. Greys added for app surfaces. */
:root {
  color-scheme: light;
  --bg: #f4f4f4;
  --panel: #ffffff;
  --panel-2: #f5f5f5;
  --text: #333333;
  --muted: #777777;
  --line: #dddddd;
  --line-strong: #c7c7c7;
  --accent: #cc3300;
  --accent-hover: #b32d00;
  --accent-soft: #f2dede;
  --accent-text: #a62a00;
  --on-accent: #ffffff;
  --danger: #cc3300;
  --danger-soft: #f2dede;
  --ok: #288511;
  --radius: 4px;
  --shadow: 0 1px 1px rgba(0, 0, 0, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* The kit is light-only; this dark variant keeps the same red hue, lifted for
   legibility on dark grey, so dark-mode phones still read as TAFE. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1c1e;
    --panel: #242628;
    --panel-2: #2b2d30;
    --text: #ececec;
    --muted: #a0a4a9;
    --line: #3a3c3f;
    --line-strong: #4a4d51;
    --accent: #ff6a45;
    --accent-hover: #ff855f;
    --accent-soft: #3a1a12;
    --accent-text: #ff9d80;
    --on-accent: #2a0c00;
    --danger: #ff7a5c;
    --danger-soft: #3a1a12;
    --ok: #79c39b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1c1e;
  --panel: #242628;
  --panel-2: #2b2d30;
  --text: #ececec;
  --muted: #a0a4a9;
  --line: #3a3c3f;
  --line-strong: #4a4d51;
  --accent: #ff6a45;
  --accent-hover: #ff855f;
  --accent-soft: #3a1a12;
  --accent-text: #ff9d80;
  --on-accent: #2a0c00;
  --danger: #ff7a5c;
  --danger-soft: #3a1a12;
  --ok: #79c39b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}

/* -------------------------------------------------------------- base */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* TAFE Queensland Design Kit font stack. */
  font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Kit headings are weight 500, but it pairs that with huge display sizes.
   At app sizes — and on Windows, where Arial has no 500 and rounds to 400 —
   600 keeps a clear hierarchy while staying in the Helvetica/Arial family. */
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

.wrap { width: min(1060px, 100% - 2.5rem); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: .6rem; }
.wrap-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.hide { display: none !important; }

/* ------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar > .inner {
  width: min(1060px, 100% - 2.5rem);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: .9rem;
  height: 58px;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 600;
  text-decoration: none;
}

.brand img { width: 24px; height: 24px; display: block; }
.brand .tag { font-weight: 400; color: var(--muted); font-size: .82rem; }

/* ----------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  padding: .44rem .85rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}

.btn:hover { background: var(--panel-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--line); }
.btn.tiny { padding: .25rem .5rem; font-size: .78rem; }

/* ------------------------------------------------------------ inputs */

input[type="text"], input[type="password"], input[type="search"], textarea, select {
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: .46rem .65rem;
  width: 100%;
}

input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea { resize: vertical; min-height: 68px; }

label.field { display: block; margin-bottom: .8rem; }
label.field > span { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .28rem; color: var(--muted); }
label.check { display: flex; align-items: flex-start; gap: .5rem; font-size: .875rem; }
label.check input { width: auto; margin-top: .22rem; }

/* ------------------------------------------------------------- cards */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pagehead { padding: 2rem 0 1.2rem; }
.pagehead p { margin: .35rem 0 0; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: .85rem;
}

.space-card {
  display: block;
  padding: 1rem 1.05rem;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s;
}

.space-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.space-card .name { font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.space-card .desc {
  color: var(--muted);
  font-size: .85rem;
  margin-top: .3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.space-card .meta { margin-top: .6rem; font-size: .76rem; color: var(--muted); }

.pill {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: .1rem .38rem;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.pill.warn { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* -------------------------------------------------------------- list */

/* --acts is fixed so the header labels line up with the values beneath them. */
.listing { overflow: hidden; --acts: 2.4rem; }
.listing.wide-acts { --acts: 9.5rem; }

.listing .head, .listing .item {
  display: grid;
  grid-template-columns: 1fr 6.5rem 8.5rem var(--acts);
  align-items: center;
  gap: .7rem;
  padding: .55rem .95rem;
}

.listing .head {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.listing .item { border-bottom: 1px solid var(--line); }
.listing .item:last-child { border-bottom: 0; }
.listing .item:hover { background: var(--panel-2); }

.listing .name {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
  text-decoration: none;
  font-weight: 500;
}
.listing .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing .name:hover span { text-decoration: underline; }
.listing .num { font-variant-numeric: tabular-nums; font-size: .84rem; color: var(--muted); }
.listing .acts { display: flex; gap: .3rem; justify-content: flex-end; }

.icon { width: 17px; height: 17px; flex: none; color: var(--muted); }
.icon.folder { color: var(--accent); }

.crumbs { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; font-size: .85rem; margin-bottom: .8rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .sep { color: var(--line-strong); }

.empty { padding: 2.6rem 1rem; text-align: center; color: var(--muted); font-size: .9rem; }

/* ------------------------------------------------------------ upload */

.drop {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 1.7rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
  background: var(--panel-2);
  transition: border-color .12s, background .12s;
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.queue { margin-top: .8rem; display: flex; flex-direction: column; gap: .45rem; }
.q-item { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .7rem; background: var(--panel); }
.q-top { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.q-top .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-top .stat { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-item.done .stat { color: var(--ok); }
.q-item.error .stat { color: var(--danger); }

.bar { height: 4px; border-radius: 3px; background: var(--line); margin-top: .4rem; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .18s; }
.q-item.done .bar > i { background: var(--ok); }
.q-item.error .bar > i { background: var(--danger); }

/* ------------------------------------------------------------- modal */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 18, .48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 60;
}

.modal {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  padding: 1.2rem;
  max-height: 90vh;
  overflow: auto;
}

.modal h2 { margin-bottom: .9rem; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }

.notice { padding: .55rem .7rem; border-radius: var(--radius); font-size: .85rem; margin-bottom: .8rem; }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--accent-soft); color: var(--accent-text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: .5rem .9rem;
  border-radius: var(--radius);
  font-size: .85rem;
  z-index: 90;
  box-shadow: var(--shadow);
}

/* -------------------------------------------------------------- misc */

.foot { padding: 2.5rem 0 3rem; color: var(--muted); font-size: .8rem; }

.stats { display: flex; gap: 1.6rem; flex-wrap: wrap; padding: .9rem 1.05rem; }
.stat-item .v { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-item .k { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.section { margin-bottom: 1.6rem; }
.section > .bar-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .7rem;
  flex-wrap: wrap;
}

.searchbox { position: relative; max-width: 340px; flex: 1; min-width: 180px; }

.spin {
  width: 15px; height: 15px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sp .7s linear infinite;
  display: inline-block;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* The "Added" column drops out on narrow screens, leaving three grid items:
   name, size, actions. The template has to match that or the actions wrap. */
@media (max-width: 660px) {
  .listing { --acts: 2.2rem; }
  .listing.wide-acts { --acts: 7.5rem; }
  .listing .head, .listing .item {
    grid-template-columns: 1fr 4.5rem var(--acts);
    gap: .5rem;
    padding: .55rem .7rem;
  }
  .listing .num.when, .listing .head .when { display: none; }
  .listing .num.size { text-align: right; font-size: .78rem; }
  .listing .acts { gap: .25rem; }
  .btn.tiny { padding: .22rem .4rem; font-size: .72rem; }
  .topbar > .inner { height: 54px; }
  .brand .tag { display: none; }
  .stats { gap: 1.1rem; }
}
