/* Board Game Inventory — dark theme
   Cyan #52D1DC / Olive #8CBA80 / Strawberry Red #F8333C
   Matte-black background, sand/white text.
*/

:root {
  --bg:            #121212;
  --bg-elevated:   #1a1a1a;
  --bg-card:       #1e1e1e;
  --bg-input:      #242424;
  --border:        #333333;
  --border-soft:   #2a2a2a;

  --text:          #DBD5B5; /* sand dune — primary reading text */
  --text-bright:   #F5F2E8; /* near-white — headings, emphasis */
  --text-muted:    #9a9686;

  --cyan:          #52D1DC;
  --cyan-dim:      #3aa3ac;
  --olive:         #8CBA80;
  --olive-dim:     #6f9a65;
  --red:           #F8333C;
  --red-dim:       #c9202a;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 8px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

h1, h2, h3 { color: var(--text-bright); margin: 0; }

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

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--cyan);
  color: #0a1416;
}
.btn-primary:hover { background: #6bdae3; }

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

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red-dim);
}
.btn-danger:hover { background: rgba(248, 51, 60, 0.12); }

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
}
.btn-icon:hover { color: var(--cyan); }

.btn-block { width: 100%; }

/* ---------- Inputs ---------- */

.input, input[type="text"], input[type="url"], input[type="number"],
input[type="date"], input[type="password"], input[type="search"], select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-bright);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(82, 209, 220, 0.18);
}
.input-narrow { width: 130px; }
textarea { resize: vertical; font-family: inherit; }

.form-error {
  color: var(--red);
  font-size: 13px;
  margin: 4px 0 0;
}
.form-success {
  color: var(--olive);
  font-size: 13px;
  margin: 4px 0 0;
}

/* ---------- Auth page ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.auth-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.auth-card h1 { font-size: 19px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; }
.auth-card label { font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.auth-card .btn { margin-top: 20px; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  flex-wrap: wrap;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand-logo { width: 32px; height: 32px; object-fit: contain; }
.topbar h1 { font-size: 18px; }
.hello { color: var(--text-muted); font-size: 14px; margin-right: 4px; }

/* ---------- Content layout ---------- */

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

/* ---------- Stats row ---------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}
.stat-tile--olive { border-left-color: var(--olive); }
.stat-tile--red   { border-left-color: var(--red); }
.stat-tile--cyan  { border-left-color: var(--cyan); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-bright); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}
.search-input { flex: 1 1 220px; min-width: 160px; }

/* ---------- Game grid ---------- */

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

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.game-card:hover { border-color: var(--cyan-dim); transform: translateY(-2px); }

.game-card-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #0d0d0d;
}
.game-card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.status-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  color: #0a1416;
}
.status-badge.in_inventory { background: var(--olive); color: #0d1a0a; }
.status-badge.checked_out  { background: var(--red); color: #2a0507; }
.status-badge.overdue      { background: var(--red); color: #2a0507; box-shadow: 0 0 0 2px rgba(248,51,60,0.35); }

.game-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-card-name { font-size: 15px; font-weight: 700; color: var(--text-bright); line-height: 1.25; }
.game-card-meta { font-size: 12.5px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 6px 10px; }
.game-card-categories { font-size: 12px; color: var(--cyan); }
.game-card-loan { font-size: 12px; color: var(--red); margin-top: 2px; }

.game-card-actions { display: flex; gap: 8px; margin-top: 8px; }
.game-card-actions .btn { flex: 1; padding: 7px 10px; font-size: 13px; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 15px;
}

/* ---------- Modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  padding: 20px 22px 24px;
  box-shadow: var(--shadow);
}
.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-pane[hidden] { display: none; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 4px;
  margin-right: 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }

.bgg-results { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 340px; overflow-y: auto; }
.bgg-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.bgg-result-item:hover { border-color: var(--cyan); }
.bgg-result-year { color: var(--text-muted); font-size: 12px; }
.bgg-hint { color: var(--text-muted); font-size: 13px; margin-top: 10px; }

.form-image-row { display: flex; gap: 16px; margin-bottom: 14px; }
.game-image-preview {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #0d0d0d;
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.form-grid--grow { flex: 1; }
.form-grid-full { grid-column: 1 / -1; }
.form-grid label, #checkoutForm label, #accountForm label, #newUserForm label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}
#checkoutForm, #accountForm, #newUserForm { display: flex; flex-direction: column; gap: 12px; }

.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}
.modal-actions-right { display: flex; gap: 10px; margin-left: auto; }

/* ---------- Detail / lending history ---------- */

.loan-history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.loan-history-item:last-child { border-bottom: none; }
.loan-history-item .loan-status-open { color: var(--red); font-weight: 700; }
.loan-history-item .loan-status-returned { color: var(--olive); }

/* ---------- Users admin ---------- */

.users-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; margin-bottom: 4px; }
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.user-row .admin-tag { color: var(--cyan); font-size: 11px; font-weight: 700; margin-left: 6px; }

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

@media (max-width: 720px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-image-row { flex-direction: column; align-items: flex-start; }
}
