/* Jednoduché štýly bez JavaScriptu. Farby sú tokeny, tmavý režim sa riadi nastavením zariadenia. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --border: #d9dee6;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --ok-bg: #e7f6ec;
  --ok-text: #14532d;
  --warn-bg: #fff4e0;
  --warn-text: #7a3e00;
  --new-bg: #e0ecff;
  --new-text: #1e3a8a;
  --approved-bg: #e7f6ec;
  --approved-text: #14532d;
  --rejected-bg: #fde8e8;
  --rejected-text: #7f1d1d;
  --waitlist-bg: #fff4e0;
  --waitlist-text: #7a3e00;
  --danger: #b42318;
  --danger-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b212a;
    --text: #e8ecf2;
    --muted: #9aa5b5;
    --border: #2f3743;
    --accent: #6ea0ff;
    --accent-text: #0b1220;
    --ok-bg: #123320;
    --ok-text: #b7ebc8;
    --warn-bg: #3a2a0c;
    --warn-text: #ffd9a0;
    --new-bg: #172a52;
    --new-text: #c4d7ff;
    --approved-bg: #123320;
    --approved-text: #b7ebc8;
    --rejected-bg: #411818;
    --rejected-text: #ffc9c9;
    --waitlist-bg: #3a2a0c;
    --waitlist-text: #ffd9a0;
    --danger: #f97066;
    --danger-text: #1a0503;
  }
}

* {
  box-sizing: border-box;
}

body {
  /* dlhý text bez medzier (názov tímu, e-mail) sa zalomí, nerozšíri stránku.
     break-word (nie anywhere): nezmenšuje stĺpce tabuliek na šírku jedného písmena */
  overflow-wrap: break-word;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a {
  color: var(--accent);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 1.6rem;
  margin: 0.4em 0;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 0.5em;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 16px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 0.9rem;
}

.user {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.button,
button {
  display: inline-block;
  font: inherit;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  background: transparent;
  color: var(--accent);
}

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 8px;
  min-height: 0;
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions .button {
  background: transparent;
  color: var(--accent);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.tabs a {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.tabs a.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 700;
}

.count {
  color: var(--muted);
  font-size: 0.9em;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 560px; /* na úzkom displeji sa tabuľka posúva vo vlastnom rámiku, nie celá stránka */
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new {
  background: var(--new-bg);
  color: var(--new-text);
}

.badge-approved {
  background: var(--approved-bg);
  color: var(--approved-text);
}

.badge-rejected {
  background: var(--rejected-bg);
  color: var(--rejected-text);
}

.badge-waitlist {
  background: var(--waitlist-bg);
  color: var(--waitlist-text);
}

.note-flag {
  font-size: 0.8rem;
  color: var(--muted);
}

.muted,
.empty {
  color: var(--muted);
}

.notice {
  padding: 12px 16px;
  border-radius: 10px;
  margin: 12px 0;
  font-weight: 600;
}

.notice-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.notice-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.current-note {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.facts,
.answers {
  display: grid;
  grid-template-columns: minmax(140px, 28%) minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
}

.facts dt,
.answers dt {
  color: var(--muted);
}

.facts dd,
.answers dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.pre {
  white-space: pre-wrap;
}

.files {
  margin: 4px 0 0;
  padding-left: 20px;
}

textarea {
  width: 100%;
  font: inherit;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  margin-bottom: 10px;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .facts,
  .answers {
    grid-template-columns: minmax(0, 1fr);
  }
}

.nowrap {
  white-space: nowrap;
}

.titlebar h1 {
  flex: 1 1 220px;
  min-width: 0;
}

/* Na úzkom displeji zoznam ukáže len tím a stav, ostatné údaje sú v detaile. */
@media (max-width: 600px) {
  .list-table {
    min-width: 0;
  }

  .list-table th:nth-child(n + 3),
  .list-table td:nth-child(n + 3) {
    display: none;
  }

  .list-table td:first-child {
    overflow-wrap: anywhere;
  }
}

.topbar {
  flex-wrap: wrap;
}

/* Správa používateľov */
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 8px 0;
}

.users-table {
  min-width: 640px;
}

.users-table details {
  margin-bottom: 8px;
}

.users-table summary {
  cursor: pointer;
  color: var(--accent);
}

.perms {
  margin: 4px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

input[type='email'] {
  width: 100%;
  max-width: 420px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* Na úzkom displeji sa každý človek zobrazí ako karta (inak by akcie ostali mimo obrazovky). */
@media (max-width: 600px) {
  .users-table {
    min-width: 0;
  }

  .users-table thead {
    display: none;
  }

  .users-table tr,
  .users-table td {
    display: block;
  }

  .users-table tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

  .users-table td {
    padding: 4px 12px;
    border: 0;
    overflow-wrap: anywhere;
  }

  .users-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
  }
}

.button.danger,
.actions .button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-text);
}

/* Bočné menu. Na širokom displeji je stále vidno, na úzkom sa otvára skrytým zaškrtávacím políčkom (bez JavaScriptu). */
.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.shell > main {
  width: 100%;
  max-width: 1100px;
  margin: 0;
  padding: 16px 24px;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar .brand {
  display: block;
  padding: 4px 8px;
  font-size: 1.05rem;
}

.sidebar nav {
  flex: 1 1 auto;
}

.nav-group {
  margin: 12px 0;
}

.nav-heading {
  margin: 0 0 4px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar ul ul {
  margin: 2px 0 6px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.sidebar li > a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.sidebar li > a:hover {
  background: var(--bg);
}

.sidebar li > a.active {
  background: var(--new-bg);
  color: var(--new-text);
  font-weight: 700;
}

.sidebar li.archived > a {
  color: var(--muted);
}

.sidebar .userbox {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.mobilebar,
.menu-toggle {
  display: none;
}

@media (max-width: 900px) {
  .shell {
    display: block;
  }

  .shell > main {
    padding: 16px;
  }

  .mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .menu-toggle {
    display: block;
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }

  .menu-button {
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    cursor: pointer;
  }

  .menu-toggle:focus-visible + .mobilebar .menu-button {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .sidebar {
    display: none;
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .menu-toggle:checked ~ .sidebar {
    display: flex;
  }

  .sidebar > .brand {
    display: none;
  }
}

/* Formuláre v moduloch (ročníky, úlohy) */
input[type='text'],
input[type='date'],
select {
  width: 100%;
  max-width: 420px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  margin-bottom: 12px;
}

.form-grid label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-grid input,
.form-grid select {
  max-width: none;
  margin-top: 2px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.tile {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.tile:hover {
  border-color: var(--accent);
}

.tile strong {
  display: block;
}

.tile .big,
.tile .muted {
  display: block;
}

.tile .big {
  font-size: 1.6rem;
  font-weight: 700;
}

.tile.planned {
  color: var(--muted);
  border-style: dashed;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  margin: 0 4px 2px 0;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.badge-todo {
  background: var(--new-bg);
  color: var(--new-text);
}

.badge-doing {
  background: var(--waitlist-bg);
  color: var(--waitlist-text);
}

.badge-done {
  background: var(--approved-bg);
  color: var(--approved-text);
}

.overdue {
  color: var(--danger);
  font-weight: 600;
}

.task-title.done {
  text-decoration: line-through;
  color: var(--muted);
}

.inline-form {
  display: inline;
  margin: 0;
}

.inline-form button {
  min-height: 0;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.crumbs {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.plain-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.actions.filter {
  align-items: center;
  margin: 12px 0;
}

.actions.filter select {
  width: auto;
  max-width: 260px;
}

details > summary {
  cursor: pointer;
  color: var(--accent);
}

main > h2 {
  margin-top: 24px;
}

/* Úlohy: na úzkom displeji ostanú všetky stĺpce (aj tlačidlá zmeny stavu), tabuľka sa posúva vo vlastnom rámiku. */
.tasks-table {
  min-width: 640px;
}
