/* ============================================================
   Comic Book Database — Design System
   Flexible comic-inspired theme: bold outlines, offset shadows,
   restrained pop-art accents. Desktop-first, mobile-friendly.
   ============================================================ */

:root {
  /* Core palette */
  --red:        #E23636;
  --red-dark:   #A61b1b;
  --yellow:     #FFC60B;
  --blue:       #2B6CB0;
  --blue-dark:  #1c4a7c;
  --ink:        #1A202C;
  --paper:      #F8F9FA;
  --paper-deep: #E9ECEF;
  --white:      #FFFFFF;
  --muted:      #6B7280;
  --green:      #2F855A;

  /* Type */
  --font-display: 'Bangers', system-ui, sans-serif;
  --font-head: 'Archivo Black', system-ui, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --border: 2.5px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: var(--white);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--red);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.sidebar .brand-sub {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--paper-deep);
  opacity: 0.7;
  margin-bottom: 2rem;
  display: block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.3rem;
  border-radius: 8px;
  color: var(--paper);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.1); }
.nav-link.active { background: var(--yellow); color: var(--ink); }
.nav-link .ico { font-size: 1.1rem; }

.sidebar .logout {
  margin-top: 1.5rem;
  width: 100%;
  background: transparent;
  border: 2px solid rgba(255,255,255,0.3);
  color: var(--paper);
  padding: 0.55rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}
.sidebar .logout:hover { border-color: var(--red); color: var(--red); }

.main {
  padding: 2rem 2.5rem 4rem;
  max-width: 1300px;
  width: 100%;
}

/* ---------- Topbar (mobile) ---------- */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--ink);
  color: var(--yellow);
  padding: 0.9rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: 0.04em; text-shadow: 2px 2px 0 var(--red); }
.hamburger { background: none; border: none; color: var(--white); font-size: 1.6rem; cursor: pointer; }

/* ---------- Headings ---------- */
.page-title {
  font-family: var(--font-head);
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.page-sub { color: var(--muted); margin-bottom: 1.75rem; font-size: 0.95rem; }

.section-divider {
  height: 5px;
  background: repeating-linear-gradient(45deg, var(--ink) 0 14px, var(--yellow) 14px 28px);
  border-radius: 3px;
  margin: 2rem 0 1.5rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.1rem;
  margin-bottom: 2rem;
}
.stat {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem 1.3rem;
}
.stat .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.stat .value { font-family: var(--font-head); font-size: 2rem; line-height: 1.1; margin-top: 0.3rem; }
.stat.red    { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
.stat.blue   { border-color: var(--blue); box-shadow: 3px 3px 0 var(--blue); }
.stat.yellow { box-shadow: 3px 3px 0 var(--yellow); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--red);
  color: var(--white);
  border: var(--border);
  border-radius: 40px;
  padding: 0.6rem 1.3rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.blue   { background: var(--blue); }
.btn.yellow { background: var(--yellow); color: var(--ink); }
.btn.ghost  { background: var(--white); color: var(--ink); }
.btn.sm     { padding: 0.4rem 0.9rem; font-size: 0.8rem; }

.btn-row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.2rem;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700; color: var(--muted);
}
.field input, .field select, .field textarea {
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--paper-deep);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.field textarea { resize: vertical; min-height: 70px; }
.field .check { flex-direction: row; align-items: center; gap: 0.5rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--white); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th {
  background: var(--ink); color: var(--white); text-align: left;
  padding: 0.7rem 0.9rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; cursor: pointer; user-select: none;
}
table.data th:hover { color: var(--yellow); }
table.data td { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--paper-deep); white-space: nowrap; }
table.data tr:hover td { background: #fffbea; }
table.data tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; border: 1.5px solid var(--ink);
}
.badge.key { background: var(--yellow); }
.badge.owned { background: #d1fae5; }
.badge.wanted { background: #dbeafe; }
.badge.sold { background: #fee2e2; }
.badge.slabbed { background: var(--blue); color: var(--white); }

/* ---------- Speech bubble (tips) ---------- */
.bubble {
  position: relative;
  background: var(--yellow);
  border: var(--border);
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.bubble::after {
  content: ''; position: absolute; bottom: -14px; left: 32px;
  border-width: 14px 12px 0 0; border-style: solid;
  border-color: var(--ink) transparent transparent transparent;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 3rem 1rem; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--paper); border: var(--border); border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--ink); width: 100%; max-width: 780px; padding: 1.8rem;
}
.modal h2 { font-family: var(--font-head); font-size: 1.3rem; margin-bottom: 1.2rem; }
.modal-close { float: right; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  background: var(--ink); color: var(--white); padding: 0.85rem 1.3rem;
  border-radius: 8px; box-shadow: var(--shadow); font-weight: 600; font-size: 0.9rem;
  opacity: 0; transform: translateY(12px); transition: all 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.5rem; margin-bottom: 0.5rem; }
.spinner-line { color: var(--muted); padding: 1.5rem; text-align: center; }

.hint { font-size: 0.78rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 250px;
    transform: translateX(-100%); transition: transform 0.25s; z-index: 60; height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 1.3rem 1.1rem 4rem; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 55; display: none; }
  .scrim.show { display: block; }
}
