/* ------------------------------------------------------------
   Rack.Inventory — audio equipment tracker
   Dark "rack unit" theme: charcoal panels, amber indicator glow,
   monospace for serials/data — like reading labels off gear.
------------------------------------------------------------ */

:root {
  --bg: #14171c;
  --surface: #1c2128;
  --surface-alt: #232a34;
  --border: #2d333d;
  --text: #e7e9ec;
  --muted: #8b929c;
  --accent: #f0a83c;
  --accent-dim: #8a6326;
  --teal: #5ec8c2;
  --danger: #e0615a;
  --success: #5fb87c;
  --gray: #5a6170;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

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

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }

.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px 2px rgba(240, 168, 60, 0.55);
  display: inline-block;
}

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

.nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.92rem;
  flex-wrap: wrap;
}

.nav a { color: var(--text); }
.nav a:hover { color: var(--accent); text-decoration: none; }
.nav-user { color: var(--muted); font-family: var(--font-mono); font-size: 0.85rem; }
.nav-logout { color: var(--muted); }

/* ---------------- Layout ---------------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 2rem 1rem 1.5rem;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1305;
  font-weight: 600;
}
.btn-primary:hover { background: #ffb84f; }

.btn-ghost { background: transparent; }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(224, 97, 90, 0.12); }

/* ---------------- Forms ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.full-width { grid-column: 1 / -1; }

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.25rem 0 0;
}
.hint code {
  font-family: var(--font-mono);
  background: var(--surface-alt);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.25rem;
}

/* Auth pages */
.auth-card {
  max-width: 360px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
}
.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------------- Alerts ---------------- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-error {
  background: rgba(224, 97, 90, 0.12);
  border: 1px solid var(--danger);
  color: #ffb3ae;
}
.alert-success {
  background: rgba(95, 184, 124, 0.12);
  border: 1px solid var(--success);
  color: #b6e6c6;
}

/* ---------------- Search ---------------- */
.search-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.search-bar input { flex: 1; }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }

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

th, td {
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover { background: var(--surface); }

.actions a { margin-right: 0.75rem; font-size: 0.88rem; }
.actions .danger { color: var(--danger); }

.qr-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: #fff;
  padding: 2px;
}

/* ---------------- Status LEDs ---------------- */
.led {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.led-active { background: var(--success); box-shadow: 0 0 6px 1px rgba(95, 184, 124, 0.6); }
.led-in-repair { background: var(--accent); box-shadow: 0 0 6px 1px rgba(240, 168, 60, 0.6); }
.led-retired { background: var(--gray); }

/* ---------------- Item detail (QR landing page) ---------------- */
.item-detail-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.item-detail-head h1 { margin: 0; margin-right: 0.5rem; }

.detail-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.6rem 1rem;
  margin: 0;
}
.detail-list dt { color: var(--muted); font-size: 0.85rem; }
.detail-list dd { margin: 0; }

/* ---------------- History tags ---------------- */
.tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tag-created { background: rgba(95, 184, 124, 0.15); color: var(--success); }
.tag-updated { background: rgba(94, 200, 194, 0.15); color: var(--teal); }
.tag-deleted { background: rgba(224, 97, 90, 0.15); color: var(--danger); }

/* ---------------- Responsive ---------------- */

/* Tablet and down: single-column forms, tighter container */
@media (max-width: 800px) {
  .form-grid { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 130px 1fr; }
  .container { padding: 1rem; }
}

/* Phone: collapse the nav, and turn each table row into its own card
   with labeled fields instead of a horizontally-scrolling table. */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav { gap: 0.85rem; font-size: 0.9rem; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { text-align: center; }

  .search-bar { flex-direction: column; }
  .search-bar .btn, .search-bar a { text-align: center; }

  table, thead, tbody, th, td, tr { display: block; width: 100%; }
  thead { position: absolute; left: -9999px; top: -9999px; }

  table { border: none; }

  tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.8rem;
  }
  tbody tr:hover { background: var(--surface); }

  td {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    white-space: normal;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-align: right;
  }
  td:last-child { border-bottom: none; }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    flex: 0 0 auto;
  }

  td.actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
  }
  td.actions::before { content: none; }
  td.actions a { margin-right: 0; }

  .auth-card { margin: 1.5rem auto; padding: 1.5rem; }
}

