/* ============================================================
   style-components.css
   Split from static/css/style.css on 2026-08-01 for token-cost
   reasons (7057-line file forced multi-chunk reads on every touch).
   Sections 21-24: theme picker, source/edition badges, rich searchable select, login & admin pages
   Load order matters - see templates/base.html <link> order.
   ============================================================ */


/* ══════════════════════════════════════════════════════════
   21. THEME PICKER
   ══════════════════════════════════════════════════════════ */
.theme-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.theme-overlay.hidden { display: none; }

.theme-modal {
  background: var(--bg-card, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  padding: 24px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.theme-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.theme-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary, #eee);
}
.theme-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted, #888);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.theme-close-btn:hover { color: var(--text-primary, #eee); }

.theme-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.theme-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg, #12121c);
  border: 2px solid var(--border, #333);
  border-radius: 8px;
  padding: 14px 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: center;
}
.theme-card:hover {
  border-color: var(--accent, #7c5cbf);
}
.theme-card.selected {
  border-color: var(--accent, #7c5cbf);
  box-shadow: 0 0 0 3px rgba(124,92,191,0.25);
}

.theme-swatch {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.theme-swatch-refined  { background: #ffffff; border-color: #8a1212; }
.theme-swatch-verdant  { background: linear-gradient(135deg, #ece2c4 60%, #4a5a2a 60%); border-color: #5a6b35; }
.theme-swatch-arcane   { background: linear-gradient(135deg, #141527 60%, #2a2150 60%); border-color: #b79cf0; }
.theme-swatch-leather  { background: linear-gradient(135deg, #6b4a2f 60%, #4a3320 60%); border-color: #caa46a; }

.theme-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.theme-card-body strong {
  font-size: 0.88rem;
  color: var(--text-primary, #eee);
}
.theme-card-body span {
  font-size: 0.74rem;
  color: var(--text-muted, #888);
  line-height: 1.3;
}

.theme-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ══════════════════════════════════════════════════════════
   22. SOURCE & EDITION BADGES
   ══════════════════════════════════════════════════════════ */
.source-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 5px;
    line-height: 1.4;
    white-space: nowrap;
}
.source-badge.edition-2024 {
    background: var(--badge-edition2024-bg);
    color: var(--badge-edition2024-fg);
}
.source-badge.edition-2014 {
    background: var(--badge-edition2014-bg);
    color: var(--badge-edition2014-fg);
}
.source-badge.edition-unknown {
    background: var(--badge-editionunknown-bg);
    color: var(--badge-editionunknown-fg);
}

/* Semantic status badges — colors come from mode-aware tokens (both .source-badge and .bg-skill-tag) */
.badge-grant  { background: var(--badge-grant-bg);  color: var(--badge-grant-fg);  border: 1px solid var(--badge-border); }
.badge-prof   { background: var(--badge-prof-bg);   color: var(--badge-prof-fg);   border: 1px solid var(--badge-border); }
.badge-info   { background: var(--badge-info-bg);   color: var(--badge-info-fg);   border: 1px solid var(--badge-border); }
.badge-warn   { background: var(--badge-warn-bg);   color: var(--badge-warn-fg);   border: 1px solid var(--badge-border); }
.badge-arcane { background: var(--badge-arcane-bg); color: var(--badge-arcane-fg); border: 1px solid var(--badge-border); }

/* Magic-item rarity — colors come from mode-aware tokens (mirror the .badge-* pattern).
   Applied to wizard category pills (.iv-tag.rarity-<key>), the wizard detail panel
   (.inv-detail-rarity.rarity-<key>), and live-play badges (.locked-rarity.rarity-<key>).
   Load order: style-components.css comes AFTER wizard-steps, so the rarity background
   overrides the default .iv-tag tint on magic category pills. */
.rarity-common    { background: var(--rarity-common-bg);    color: var(--rarity-common-fg);    border: 1px solid var(--rarity-common-fg); }
.rarity-uncommon  { background: var(--rarity-uncommon-bg);  color: var(--rarity-uncommon-fg);  border: 1px solid var(--rarity-uncommon-fg); }
.rarity-rare      { background: var(--rarity-rare-bg);      color: var(--rarity-rare-fg);      border: 1px solid var(--rarity-rare-fg); }
.rarity-very_rare { background: var(--rarity-very_rare-bg); color: var(--rarity-very_rare-fg); border: 1px solid var(--rarity-very_rare-fg); }
.rarity-legendary { background: var(--rarity-legendary-bg); color: var(--rarity-legendary-fg); border: 1px solid var(--rarity-legendary-fg); }
.rarity-artifact  { background: var(--rarity-artifact-bg);  color: var(--rarity-artifact-fg);  border: 1px solid var(--rarity-artifact-fg); }

/* Text-only variant (no background/border) for coloring a magic item's NAME by rarity,
   e.g. the live-play inventory row — same tokens as the badges above, just color. */
.rarity-common-text    { color: var(--rarity-common-fg); }
.rarity-uncommon-text  { color: var(--rarity-uncommon-fg); }
.rarity-rare-text      { color: var(--rarity-rare-fg); }
.rarity-very_rare-text { color: var(--rarity-very_rare-fg); }
.rarity-legendary-text { color: var(--rarity-legendary-fg); }
.rarity-artifact-text  { color: var(--rarity-artifact-fg); }

/* ══════════════════════════════════════════════════════════
   23. RICH SEARCHABLE SELECT
   ══════════════════════════════════════════════════════════ */
.rich-select-wrapper {
  position: relative;
  width: 100%;
}
.rich-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  min-height: 38px;
  user-select: none;
}
.rich-select-trigger:focus { outline: 2px solid var(--accent); }
.rich-select-trigger.open { border-color: var(--accent); }
.rich-select-trigger-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rich-select-trigger-arrow { margin-left: 8px; color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.rich-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--input-bg);
  border: 1px solid var(--accent);
  border-radius: 9px;
  z-index: 1200;
  max-height: 320px;
  overflow: hidden;
  flex-direction: column;
  box-shadow: 0 14px 34px rgba(0,0,0,0.38);
}
.rich-select-dropdown.open { display: flex; }
.rich-select-search {
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.rich-select-list {
  overflow-y: auto;
  flex: 1;
}
.rich-select-option {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 9px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  gap: 8px;
}
.rich-select-option:hover,
.rich-select-option.focused { background: color-mix(in srgb, var(--accent) 10%, var(--surface2)); }
.rich-select-option.selected { background: color-mix(in srgb, var(--accent) 14%, var(--surface2)); color: var(--accent); }
.rich-select-option-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.rich-select-option-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rich-select-option-summary { color: var(--text-muted); font-size: 12px; line-height: 1.35; }
.rich-select-option-badges { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.rich-select-empty { padding: 12px 10px; color: var(--text-muted); font-size: 13px; text-align: center; }
.rich-select-group-header {
  padding: 7px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface2);
  position: sticky;
  top: 0;
}

/* Edition badge — separate from source badge */
.edition-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  white-space: nowrap;
}
.edition-badge.ed-2024 { background: #1a3a2a; color: #7fcca0; border: 1px solid #2a6040; }
[data-theme="light"] .edition-badge.ed-2024 { background: #d8ecdf; color: #1f5c3d; border-color: #8fbfa0; }
.edition-badge.ed-2014 { background: var(--badge-edition2014-bg); color: var(--badge-edition2014-fg); border: 1px solid color-mix(in srgb, var(--badge-edition2014-fg) 50%, transparent); }

/* Hide native selects that have a rich-select wrapper */
#f-species, #f-background, #f-class { display: none; }

/* Weapon Mastery picker */
.mastery-count-label    { font-size:13px; margin-bottom:10px; color:var(--text-muted); }
.choice-note { color: var(--text-muted); font-size: 13px; margin: 0 0 10px; }
.class-choice-progress { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 8px 0 11px; }
.class-choice-progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--badge-grant-fg)); }
.mastery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mastery-label.class-choice-tile {
  display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--input-bg); padding: 9px 10px; color: var(--text-muted); cursor: pointer; font-size: 13px;
}
.mastery-label.class-choice-tile input { position: absolute; opacity: 0; pointer-events: none; }
.mastery-label.class-choice-tile .choice-check {
  width: 16px; height: 16px; display: inline-grid; place-items: center; flex-shrink: 0;
  border: 1px solid var(--border-strong); border-radius: 4px; color: var(--input-bg); font-size: 11px; font-weight: 900;
}
.mastery-label.class-choice-tile.selected { border-color: var(--badge-grant-fg); background: var(--badge-grant-bg); color: var(--badge-grant-fg); font-weight: 800; }
.mastery-label.class-choice-tile.selected .choice-check { background: var(--badge-grant-fg); border-color: var(--badge-grant-fg); color: var(--input-bg); }
.mastery-label.class-choice-tile.opt-taken { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.mastery-count { color: var(--text-muted); font-size: 12px; margin: 9px 0 0; font-weight: 800; }
.mastery-weapon-list    { display:flex; flex-direction:column; gap:4px; max-height:320px; overflow-y:auto; }
.mastery-weapon-row     { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:8px 10px;
                           border-radius:6px; border:1px solid var(--border); cursor:pointer;
                           transition:background 0.15s; }
.mastery-weapon-row:hover    { background:var(--bg-hover,rgba(255,255,255,0.05)); }
.mastery-weapon-row.selected { border-color:var(--gold); background:rgba(212,175,55,0.08); }
.mastery-weapon-name    { font-weight:600; font-size:13px; flex:1; min-width:100px; }
.mastery-tag            { font-size:11px; padding:2px 7px; border-radius:10px; font-weight:700;
                           background:var(--bg-card,#1a1a2e); border:1px solid var(--border); white-space:nowrap; }
.mastery-weapon-desc    { width:100%; font-size:12px; color:var(--text-muted); padding-left:24px; line-height:1.4; }
/* formatDescriptionHTML() output (paragraphs/bullet lists) inside this compact
   row description -- drop the browser default <p>/<ul> margin on the first/last
   child so it doesn't add unwanted vertical gaps in the tightly-packed row. */
.mastery-weapon-desc > p:first-child, .mastery-weapon-desc > ul:first-child { margin-top: 0; }
.mastery-weapon-desc > p:last-child, .mastery-weapon-desc > ul:last-child { margin-bottom: 0; }
.mastery-warning        { font-size:12px; margin-top:6px; color:#e06060; }
input.mastery-weapon-cb { flex-shrink:0; cursor:pointer; }

/* ══════════════════════════════════════════════════════════
   24. LOGIN & ADMIN PAGES
   ══════════════════════════════════════════════════════════ */
.login-container {
  max-width: 380px;
  margin: 80px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
}
.login-title {
  font-family: var(--font-display);
  color: var(--gold);
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.login-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.login-form .btn {
  margin-top: 0.5rem;
  width: 100%;
}
.login-error {
  color: #e55;
  font-size: 0.9rem;
  text-align: center;
  margin: 0;
}

/* -- Navbar right side ---------------------------------------- */
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-username {
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 0.5rem;
}
.nav-logout {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Admin page --- */
.admin-container { max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
.admin-section { margin-bottom: 2rem; }
.admin-section h3 { color: var(--gold); margin-bottom: 0.75rem; }
.admin-section form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.admin-section input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.admin-table th { color: var(--text-muted); font-size: 0.85rem; }
.admin-msg { margin-top: 0.5rem; font-size: 0.9rem; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-danger { background: #6b1c1c; color: #fff; border: 1px solid #9b2c2c; }
.btn-danger:hover { background: #9b2c2c; }

/* Homebrew badge. Appears wherever an authored item can sit beside a published one --
   the wizard's browse rows (.inv-res) and owned rows (.inv-row), and live play's catalog
   search and inventory rows -- because that is where the player is choosing between two
   similarly named items and has to be able to tell which is which. Deliberately not a
   rarity colour: it says where the item came from, not how good it is. */
.iv-homebrew {
  display: inline-block; font-size: 8.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: 1px 7px; border-radius: 99px;
  margin: 0 4px 0 6px; vertical-align: 1px; cursor: help; white-space: nowrap;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid color-mix(in srgb, var(--border-strong) 55%, transparent);
}
