@import url('tokens.css');

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--color-sidebar);
  color: var(--color-sidebar-foreground);
  border-bottom: 3px solid var(--color-primary);
}

.brand {
  font-weight: 700;
  color: var(--color-sidebar-foreground);
  text-decoration: none;
}
.brand:hover {
  text-decoration: none;
  color: var(--color-primary);
}
.topbar strong { color: #ffffff; }
.sep { color: var(--color-zinc-400); }
.logout {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--color-sidebar-foreground);
}
.logout:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

.footer {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--surface);
}

h1 { margin: 0 0 0.75rem; font-size: 1.5rem; font-weight: 500; }
.muted { color: var(--muted); font-size: 0.95rem; }
.mono { font-family: ui-monospace, monospace; font-size: 0.85rem; }
.error { color: var(--err); }

.flash {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.flash-ok { background: #dcfce7; color: var(--ok); }
.flash-error { background: #fee2e2; color: var(--err); }
.flash-warn { background: #fef9c3; color: var(--warn); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.panel.narrow { max-width: 400px; margin: 2rem auto; }

.module-grid {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.module-grid a {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: border-color var(--duration-fast) ease, color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
.module-grid a:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(235, 100, 0, 0.12);
  text-decoration: none;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.toolbar-row-search {
  width: 100%;
}

.toolbar-row-actions {
  width: 100%;
}

.search-form {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  width: auto;
}

.search-form button[type="submit"],
.search-form .btn {
  flex-shrink: 0;
}

input[type="search"],
input[type="text"],
input[type="password"],
textarea,
label select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
input[type="search"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
label select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(235, 100, 0, 0.15);
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease;
}
.btn:hover {
  text-decoration: none;
  border-color: var(--color-proactive-gray-hover);
  background: var(--surface-muted);
}
.btn.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-foreground);
}
.btn.primary:hover,
button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-foreground);
}

button[type="submit"] {
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: var(--accent-foreground);
  font: inherit;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}
button[type="submit"]:hover { background: var(--accent-hover); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--color-proactive-gray);
  color: var(--color-sidebar-foreground);
  font-weight: 500;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(235, 100, 0, 0.05); }
td.empty { text-align: center; color: var(--muted); padding: 2rem; }
td.actions { white-space: nowrap; }

.row-link {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.row-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.sort-link:hover { color: #ffffff; opacity: 0.9; }
th.sorted .sort-link { color: #ffffff; }
.sort-indicator {
  font-size: 0.75rem;
  margin-left: 0.2rem;
  color: var(--color-primary);
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.filter-label {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 160px;
}
.filter-label select {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
