/* Clautick structural styles — pure CSS custom properties, no preprocessor.
   Every colour value must come from a token defined by the active theme
   file in assets/css/themes/*.css: --bg --surface --border --text
   --text-muted --primary --accent --success --warning --danger. Never
   hardcode a colour here. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

.muted {
  color: var(--text-muted);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--primary);
}

/* ---------- forms ---------- */
form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

textarea {
  resize: vertical;
  font-family: inherit;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- alerts ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-danger {
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}

/* ---------- auth page ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 24px;
}

.auth-card .brand {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 18px;
}

.auth-card .btn-primary {
  margin-top: 18px;
  justify-content: center;
}

/* ---------- app shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.nav {
  display: flex;
  gap: 16px;
}

.nav a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}

.nav a:hover {
  color: var(--text);
}

.topbar form {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin: 0;
}

.user-chip {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.user-chip:hover {
  color: var(--text);
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
}

.content.wide {
  max-width: 1440px;
}

.content h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

/* ---------- chips (type / priority / status) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--text-muted) 16%, transparent);
  color: var(--text-muted);
}

.chip-type {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.chip-priority-critical,
.chip-priority-high {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}

.chip-priority-medium {
  background: color-mix(in srgb, var(--warning) 22%, transparent);
  color: var(--warning);
}

.chip-priority-low {
  background: color-mix(in srgb, var(--text-muted) 18%, transparent);
  color: var(--text-muted);
}

.chip-status-open {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
}

.chip-status-in_progress {
  background: color-mix(in srgb, var(--primary) 26%, transparent);
  color: var(--primary);
}

.chip-status-blocked {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}

.chip-status-in_review {
  background: color-mix(in srgb, var(--warning) 22%, transparent);
  color: var(--warning);
}

.chip-status-done {
  background: color-mix(in srgb, var(--success) 22%, transparent);
  color: var(--success);
}

.chip-status-closed,
.chip-status-wont_fix {
  background: color-mix(in srgb, var(--text-muted) 16%, transparent);
  color: var(--text-muted);
}

.chip-sla-breach {
  background: var(--danger);
  color: var(--bg);
  text-transform: uppercase;
}

.chip-updated {
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
}

.ticket-card .ticket-updated {
  margin-top: 8px;
}

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.filter-bar form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-bar select,
.filter-bar input[type="text"] {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.view-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.view-toggle a {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
}

.view-toggle a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--bg);
}

/* ---------- ticket board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.board-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.board-column summary {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}

.board-column summary::-webkit-details-marker {
  display: none;
}

.board-column summary span:first-child::before {
  content: "▸";
  margin-right: 6px;
  font-size: 10px;
  position: relative;
  top: -1px;
}

.board-column[open] summary span:first-child::before {
  content: "▾";
}

.board-column[open] summary {
  margin-bottom: 10px;
}

.board-column-cards {
  max-height: calc(100vh - 320px);
  overflow-y: auto;
}

.board-column-empty {
  font-size: 12.5px;
  margin: 0;
}

.ticket-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--text);
}

.ticket-card:hover {
  border-color: var(--primary);
}

.ticket-card .ticket-ref {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.ticket-card .ticket-title {
  font-size: 14px;
  font-weight: 600;
  margin: 4px 0 8px;
}

.ticket-card .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.more-link {
  display: block;
  text-align: center;
  font-size: 12.5px;
  padding: 8px;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.more-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ---------- pagination ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
  font-size: 13px;
}

.pager a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.pager a:hover {
  text-decoration: underline;
}

.pager-disabled {
  color: var(--text-muted);
  opacity: 0.5;
}

.pager-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pager-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.pager-page:hover {
  border: 1px solid var(--border);
  color: var(--primary);
}

.pager-page-current {
  background: var(--primary);
  color: var(--bg);
}

.pager-ellipsis {
  color: var(--text-muted);
  padding: 0 2px;
}

/* ---------- ticket list (table) ---------- */
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ticket-table th,
.ticket-table td {
  text-align: left;
  padding: 10px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}

.ticket-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}

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

.ticket-table a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.ticket-table a:hover {
  color: var(--primary);
}

/* ---------- ticket detail ---------- */
.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.ticket-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.ticket-meta-grid form {
  gap: 4px;
}

.ticket-meta-grid label {
  margin-top: 0;
}

.ticket-meta-grid select,
.ticket-meta-grid input {
  font-size: 13px;
  padding: 7px 9px;
}

.description-block {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 14px;
}

.attachment-list {
  list-style: none;
  margin: 8px 0 12px;
  padding: 0;
}

.attachment-list li {
  padding: 6px 0;
  font-size: 13.5px;
}

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

.timeline li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.timeline li:last-child {
  border-bottom: none;
}

.timeline .who {
  font-weight: 600;
}

.timeline .when {
  color: var(--text-muted);
  font-size: 12px;
}

.timeline .comment-body {
  margin-top: 4px;
  white-space: pre-wrap;
}

.timeline .history-line {
  color: var(--text-muted);
}

/* ---------- plain data tables (admin) ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}

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

.data-table form {
  display: inline-flex;
  flex-direction: row;
  gap: 6px;
  margin: 0;
}

.data-table select {
  font-size: 12.5px;
  padding: 4px 6px;
}

.inline-form {
  display: inline-flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
  margin: 0;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 32px 0 12px;
}

.section-title:first-child {
  margin-top: 0;
}

/* ---------- settings forms ---------- */
.settings-form {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  max-width: 420px;
}

.settings-form label {
  margin-top: 0;
  white-space: nowrap;
}

.settings-form input[type="number"] {
  width: 90px;
}

/* ---------- settings theme grid ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.theme-option {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}

.theme-option.active {
  border-color: var(--primary);
}

.theme-swatch {
  height: 40px;
  display: flex;
}

.theme-swatch span {
  flex: 1;
}

.theme-option .theme-name {
  display: block;
  font-size: 12.5px;
  padding: 8px 10px;
  color: var(--text);
}

/* ---------- card / key-value rows ---------- */
.card {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  font-size: 14px;
}

.card-row + .card-row {
  border-top: 1px solid var(--border);
}

.card-row .label {
  color: var(--text-muted);
}
