/* ============================================================
   BLOOD BOWL LEAGUE MANAGER — Shared Stylesheet
   Theme: Dark Gothic-Industrial / Cool Black & Silver
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Share+Tech+Mono&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Backgrounds — true cool blacks */
  --bg:          #0a0a0b;
  --bg-mid:      #101013;
  --bg-panel:    #16161a;
  --bg-raised:   #1e1e24;
  --bg-input:    #0d0d10;

  /* Primary accent — silver/steel white */
  --accent:        #c8cdd6;
  --accent-bright: #e8ecf2;
  --accent-dim:    #6b7280;
  --accent-faint:  #1a1b20;

  /* Status colors */
  --red:         #7a1f1f;
  --red-bright:  #e05555;
  --green:       #1e5c2e;
  --green-bright:#4caf6e;

  /* Text */
  --text:        #c8cdd6;
  --text-muted:  #606470;
  --text-dim:    #38393f;
  --text-head:   #e8ecf2;

  /* Borders — cool grays */
  --border:        #22232a;
  --border-accent: #3a3d48;
  --border-bright: #52566a;

  --radius:    4px;
  --radius-lg: 8px;

  --font-display: 'Cinzel', serif;
  --font-body:    'Crimson Pro', Georgia, serif;
  --font-mono:    'Share Tech Mono', monospace;
}

/* ── Theme: Blood (deep crimson & bone) ────────────────────── */
html[data-theme="blood"] {
  --bg:          #0d0505;
  --bg-mid:      #130808;
  --bg-panel:    #1a0c0c;
  --bg-raised:   #251212;
  --bg-input:    #0f0606;

  --accent:        #c9a87a;
  --accent-bright: #e8cfa0;
  --accent-dim:    #7a5a3a;
  --accent-faint:  #1e1008;

  --red:         #8b1a1a;
  --red-bright:  #e05555;
  --green:       #1e5c2e;
  --green-bright:#4caf6e;

  --text:        #d4c0a8;
  --text-muted:  #6e5a48;
  --text-dim:    #3d2a20;
  --text-head:   #f0e0c8;

  --border:        #2e1515;
  --border-accent: #4a2020;
  --border-bright: #6a3030;
}

/* ── Theme: Parchment (warm light — old scroll) ─────────────── */
html[data-theme="parchment"] {
  --bg:          #f2ead8;
  --bg-mid:      #ede3cc;
  --bg-panel:    #e8dcc0;
  --bg-raised:   #ddd0b0;
  --bg-input:    #f7f0e0;

  --accent:        #6b3a1f;
  --accent-bright: #4a2510;
  --accent-dim:    #9a6a4a;
  --accent-faint:  #d8c8a8;

  --red:         #8b2020;
  --red-bright:  #b83030;
  --green:       #2a5a1a;
  --green-bright:#3a7a28;

  --text:        #3a2810;
  --text-muted:  #7a6040;
  --text-dim:    #b8a888;
  --text-head:   #1e1608;

  --border:        #c8b898;
  --border-accent: #a89878;
  --border-bright: #887858;
}

/* ── Theme: Forest (dark green & gold) ──────────────────────── */
html[data-theme="forest"] {
  --bg:          #060d06;
  --bg-mid:      #0a120a;
  --bg-panel:    #0f1a0f;
  --bg-raised:   #162216;
  --bg-input:    #080e08;

  --accent:        #c8a840;
  --accent-bright: #e8c860;
  --accent-dim:    #7a6820;
  --accent-faint:  #181408;

  --red:         #7a1f1f;
  --red-bright:  #e05555;
  --green:       #1a4a1a;
  --green-bright:#4a8a4a;

  --text:        #b8c8a0;
  --text-muted:  #5a6848;
  --text-dim:    #303820;
  --text-head:   #d8e8c0;

  --border:        #1a2a1a;
  --border-accent: #2a4028;
  --border-bright: #3a5838;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  font-size: 1rem;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 0%,   rgba(200,205,214,0.025) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(122,31,31,0.03)    0%, transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='%230a0a0b'/%3E%3Crect x='0' y='0' width='1' height='1' fill='%23101013' opacity='0.5'/%3E%3C/svg%3E");
}

html[data-theme="blood"] body {
  background-image:
    radial-gradient(ellipse at 20% 0%,   rgba(180,40,40,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(180,40,40,0.04) 0%, transparent 55%);
}
html[data-theme="parchment"] body {
  background-image:
    radial-gradient(ellipse at 20% 0%,   rgba(107,58,31,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(107,58,31,0.04) 0%, transparent 55%);
}
html[data-theme="forest"] body {
  background-image:
    radial-gradient(ellipse at 20% 0%,   rgba(40,100,40,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(200,168,64,0.04) 0%, transparent 55%);
}

/* ── Navigation ────────────────────────────────────────────── */
.bb-nav {
  background: var(--bg-mid);
  border-bottom: 2px solid var(--border-accent);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 24px rgba(0,0,0,0.6);
}

.bb-nav__logo {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  text-decoration: none;
  padding: 1rem 1.5rem 1rem 0;
  border-right: 1px solid var(--border);
  margin-right: 0.5rem;
  white-space: nowrap;
  text-shadow: 0 0 24px rgba(200,205,214,0.2);
}

.bb-nav__logo span {
  color: var(--red-bright);
}

.bb-nav a {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-muted);
  padding: 1.1rem 1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.bb-nav a:hover,
.bb-nav a.active {
  color: var(--accent-bright);
  border-bottom-color: var(--accent);
}

/* ── Page Layout ───────────────────────────────────────────── */
.bb-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.bb-page--wide {
  max-width: 1700px;
}

/* ── Page Header ───────────────────────────────────────────── */
.bb-page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.bb-page-header__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-head);
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.bb-page-header__title span {
  color: var(--accent);
}

.bb-page-header__sub {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-style: italic;
}

.bb-page-header__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
}

/* ── Panels / Cards ────────────────────────────────────────── */
.bb-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.bb-panel--gold {
  border-color: var(--border-accent);
  background: linear-gradient(135deg, var(--bg-panel) 0%, var(--accent-faint) 100%);
}

.bb-panel__title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Form Elements ─────────────────────────────────────────── */
.bb-form label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.bb-form input,
.bb-form select,
.bb-form textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.bb-form input:focus,
.bb-form select:focus,
.bb-form textarea:focus {
  border-color: var(--border-bright);
  box-shadow: 0 0 0 2px rgba(200,205,214,0.08);
}

.bb-form input[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Custom select arrow */
.bb-form .bb-select-wrap {
  position: relative;
}
.bb-form .bb-select-wrap::after {
  content: "▾";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-dim);
  pointer-events: none;
  font-size: 0.85rem;
}
.bb-form .bb-select-wrap select {
  padding-right: 2rem;
  cursor: pointer;
}

.bb-form textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

/* ── Grid helpers ──────────────────────────────────────────── */
.bb-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.bb-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.bb-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; }
.bb-full   { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .bb-grid-2, .bb-grid-3, .bb-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .bb-grid-2, .bb-grid-3, .bb-grid-4 { grid-template-columns: 1fr; }
}

/* ── Field groups ──────────────────────────────────────────── */
.bb-field {
  display: flex;
  flex-direction: column;
}

/* ── Buttons ───────────────────────────────────────────────── */
.bb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.7rem 1.4rem;
  border: 1px solid;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}

.bb-btn--primary {
  background: var(--accent);
  border-color: var(--accent-bright);
  color: #0a0a0b;
}
.bb-btn--primary:hover {
  background: var(--accent-bright);
  box-shadow: 0 0 18px rgba(200,205,214,0.25);
}

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

.bb-btn--danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red-bright);
}
.bb-btn--danger:hover {
  background: var(--red);
  color: #fff;
}

.bb-btn-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

/* ── Messages ──────────────────────────────────────────────── */
.bb-msg {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.bb-msg ul { padding-left: 1.2em; margin: 0; }
.bb-msg li { margin-bottom: 0.2em; }

.bb-msg--error {
  background: rgba(122,31,31,0.18);
  border-color: var(--red);
  color: #e87a7a;
}
.bb-msg--warn {
  background: rgba(200,205,214,0.06);
  border-color: var(--accent-dim);
  color: var(--accent);
}
.bb-msg--ok {
  background: rgba(30,92,46,0.18);
  border-color: var(--green);
  color: var(--green-bright);
}

/* ── Tables ────────────────────────────────────────────────── */
.bb-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-height: 75vh;
}

.bb-table {
  border-collapse: collapse;
  width: 100%;
}

.bb-table th {
  background: var(--bg-raised);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.7rem 0.85rem;
  border-bottom: 2px solid var(--border-accent);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  text-align: left;
}
.bb-table th:last-child { border-right: none; }

.bb-table td {
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: middle;
}
.bb-table td:last-child { border-right: none; }

.bb-table tbody tr { transition: background 0.1s; }
.bb-table tbody tr:hover { background: var(--bg-raised); }
.bb-table tbody tr:last-child td { border-bottom: none; }

.bb-table a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}
.bb-table a:hover { color: var(--accent-bright); text-decoration: underline; }

/* Status badges */
.bb-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  border: 1px solid;
}
.bb-badge--active  { background: rgba(30,92,46,0.2);    border-color: var(--green);      color: var(--green-bright); }
.bb-badge--retired { background: rgba(50,52,60,0.4);    border-color: var(--text-dim);   color: var(--text-muted); }
.bb-badge--deleted { background: rgba(122,31,31,0.2);   border-color: var(--red);        color: var(--red-bright); }

/* ── Details/Summary (collapsible panels) ──────────────────── */
details.bb-details {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

details.bb-details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  user-select: none;
  transition: background 0.1s;
}
details.bb-details > summary::-webkit-details-marker { display: none; }
details.bb-details > summary:hover { background: var(--bg-raised); }

details.bb-details > summary .bb-details__icon {
  color: var(--accent-dim);
  font-size: 0.7rem;
  transition: transform 0.2s;
  width: 1em;
}
details.bb-details[open] > summary .bb-details__icon {
  transform: rotate(90deg);
}

details.bb-details > summary .bb-details__title {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

details.bb-details > summary .bb-details__sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-left: auto;
  font-style: italic;
}

details.bb-details > .bb-details__body {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Stat chip ─────────────────────────────────────────────── */
.bb-stat {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
}

/* ── Divider ───────────────────────────────────────────────── */
.bb-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Drag list (column picker) ─────────────────────────────── */
.bb-col-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.bb-col-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  user-select: none;
  transition: background 0.1s;
}
.bb-col-item:first-child { border-top: none; }
.bb-col-item:hover { background: var(--bg-raised); }

.bb-col-item .handle {
  cursor: grab;
  font-size: 0.9rem;
  color: var(--text-dim);
  width: 1.2em;
  text-align: center;
}

.bb-col-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.bb-col-item .col-name {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text);
}

.bb-col-item.dragging { opacity: 0.4; }
.bb-col-item.over { outline: 2px dashed var(--accent-dim); outline-offset: -2px; }

.bb-btn-row--small {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
  flex-wrap: wrap;
}

/* ── Code inline ───────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-raised);
  color: var(--accent-dim);
  padding: 0.1em 0.4em;
  border-radius: 2px;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-accent); }

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-mono   { font-family: var(--font-mono); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
