/* ============================================================
   SmuLogSniffer – stylesheet
   ============================================================ */

:root {
  --bg: #0e1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #f7c948;
  --accent2: #58a6ff;
  --ok: #3fb950;
  --missing: #f85149;
  --na: #8b949e;
  --warn: #d29922;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
header {
  background: linear-gradient(135deg, #1a2332 0%, #0d1117 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.header-input {
  flex: 1;
}

.header-input .hint {
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: .5rem;
}

.logo-link { display: inline-block; line-height: 0; }
.logo-img  { height: 96px; width: auto; display: block; mix-blend-mode: lighten; }

/* ---- Main ---- */
main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---- Cards ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: .6rem;
  color: var(--accent);
}

.card h3 {
  font-size: 1rem;
  margin-bottom: .75rem;
  color: var(--accent);
}

/* ---- Input card ---- */
.hint {
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: .75rem;
}

.input-row {
  display: flex;
  gap: .5rem;
}

input[type="text"] {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .55rem .9rem;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}

input[type="text"]:focus { border-color: var(--accent2); }

button {
  background: var(--accent);
  color: #0e1117;
  border: none;
  border-radius: var(--radius);
  padding: .55rem 1.4rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}

button:disabled { opacity: .5; cursor: not-allowed; }
button:not(:disabled):hover { opacity: .85; }

.error-box {
  margin-top: .75rem;
  background: rgba(248, 81, 73, .15);
  border: 1px solid var(--missing);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  color: var(--missing);
  font-size: .875rem;
}

/* ---- Loading ---- */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  color: var(--text-muted);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Report meta ---- */
.report-meta {
  font-size: .9rem;
  color: var(--text-muted);
}

.report-meta strong { color: var(--text); }

.report-meta a { color: var(--accent2); text-decoration: none; }
.report-meta a:hover { text-decoration: underline; }

/* ---- Legend ---- */
.legend-card h3 {
  margin: 0 0 .6rem;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.legend-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.4rem;
  align-items: center;
  font-size: .85rem;
  color: var(--text-muted);
}

.legend-grid span:not(.badge) {
  margin-right: .2rem;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 700;
  text-align: center;
  min-width: 3.5rem;
}

.badge.ok       { background: rgba(63, 185, 80, .18);  color: var(--ok);      border: 1px solid rgba(63, 185, 80, .4); }
.badge.missing  { background: rgba(248, 81, 73, .18);  color: var(--missing); border: 1px solid rgba(248, 81, 73, .4); }
.badge.na       { background: rgba(139, 148, 158, .15); color: var(--na);     border: 1px solid rgba(139, 148, 158, .3); }
.badge.partial  { background: rgba(210, 153, 34, .18);  color: var(--warn);    border: 1px solid rgba(210, 153, 34, .4); }

/* ---- Consume icons ---- */
.consume-icons { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; justify-content: center; }
.consume-icon { line-height: 0; display: inline-block; cursor: pointer; text-decoration: none; }
.consume-icon img { width: 20px; height: 20px; border-radius: 3px; border: 1px solid rgba(255,255,255,.15); vertical-align: top; }

/* Override power.js white-space:nowrap so tooltip text wraps correctly */
.wowhead-tooltip table, .wowhead-tooltip td, .wowhead-tooltip span { white-space: normal !important; }



/* ---- Filter card ---- */
.filter-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.filter-card label {
  color: var(--text-muted);
  font-size: .875rem;
  white-space: nowrap;
}

.filter-card input[type="text"] {
  flex: 0 0 220px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-muted);
  user-select: none;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ---- Summary card ---- */
.summary-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  font-size: .9rem;
}

.summary-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: .65rem;
  border-bottom: 1px solid rgba(139,148,158,.15);
}

.summary-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.summary-item .label {
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  color: var(--text-muted);
  font-size: .6rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
  position: relative;
}

.info-icon:hover::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 9999;
  background: #1e2127;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 6px;
  padding: .45rem .65rem;
  font-size: .78rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  width: max-content;
  max-width: 420px;
  white-space: normal;
  line-height: 1.5;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.55);
}

/* Info panel above table */
.info-panel {
  font-size: .85rem;
  color: var(--text-muted);
  border-left: 3px solid var(--accent);
  padding: .75rem 1rem;
}

.info-panel strong {
  color: var(--text);
  display: block;
  margin-bottom: .3rem;
}

.info-panel p {
  margin: 0;
  line-height: 1.6;
}

.summary-item .value {
  font-size: 1.4rem;
  font-weight: 700;
}

.summary-item .value.all-ok  { color: var(--ok); }
.summary-item .value.has-issues { color: var(--missing); }
.summary-item .value.neutral { color: var(--accent); }

/* ---- Table ---- */
.table-card { padding: 0; overflow: hidden; }

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  white-space: nowrap;
}

thead th {
  background: var(--bg3);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .7rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

thead th:first-child { text-align: left; min-width: 140px; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }

tbody td {
  padding: .6rem 1rem;
  text-align: center;
  vertical-align: middle;
}

tbody td:first-child { text-align: left; vertical-align: middle; }

/* Player name cell */
.player-cell {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.class-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
}

.player-name {
  font-weight: 600;
}

/* Class colours (WoW standard) */
.cls-DeathKnight { color: #C41E3A; }
.cls-Druid       { color: #FF7C0A; }
.cls-Hunter      { color: #AAD372; }
.cls-Mage        { color: #3FC7EB; }
.cls-Paladin     { color: #F48CBA; }
.cls-Priest      { color: #FFFFFF; }
.cls-Rogue       { color: #FFF468; }
.cls-Shaman      { color: #0070DD; }
.cls-Warlock     { color: #8788EE; }
.cls-Warrior     { color: #C69B3A; }

/* ---- Enchant sub-cells ---- */
.enchant-icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: 172px; /* 5 × 32px icons + 4 × 3px gaps */
  margin: 0 auto;
}

.enchant-item-icon {
  display: inline-flex;
  text-decoration: none;
  cursor: pointer;
}

.enchant-item-icon img {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 3px;
  display: block;
}

/* ---- Utility ---- */
.hidden { display: none !important; }

/* ---- Footer ---- */
footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
}

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

/* ---- Fight-by-fight tooltip ---- */
.fight-tooltip-popup {
  position: fixed;
  z-index: 9999;
  background: #1e2127;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .7rem;
  font-size: .8rem;
  min-width: 200px;
  max-width: 320px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.55);
}

.fight-tooltip-popup .ft-header {
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
  margin-bottom: .35rem;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fight-tooltip-popup .ft-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .12rem 0;
}

.fight-tooltip-popup .ft-row .badge {
  min-width: 1.8rem;
  font-size: .7rem;
  padding: .1rem .3rem;
  flex-shrink: 0;
  text-align: center;
}

.fight-tooltip-popup .ft-name {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hoverable cells with fight tooltip get a subtle cursor hint */
td[data-tip-col] { cursor: default; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .logo-img    { height: 72px; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .input-row   { flex-direction: column; }
  button     { width: 100%; }
}

/* Tooltip inside sticky <th> — rendered as a real body-level element to escape stacking context */
.col-info-tooltip {
  position: fixed;
  z-index: 10000;
  background: #1e2127;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 6px;
  padding: .45rem .65rem;
  font-size: .78rem;
  font-weight: 400;
  width: max-content;
  max-width: 420px;
  white-space: normal;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.55);
}

/* ---- Item expand accordion ---- */
.iexp-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.iexp-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 1px 4px;
  margin-top: 4px;
  cursor: pointer;
  transition: color .1s, transform .15s;
  display: block;
  width: 100%;
  text-align: center;
}

.iexp-btn:hover { color: var(--accent); }
.iexp-btn.open  { transform: rotate(180deg); color: var(--accent); }

.item-expand-popup {
  position: fixed;
  z-index: 9998;
  background: #1e2127;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .7rem;
  font-size: .8rem;
  min-width: 220px;
  max-width: 340px;
  box-shadow: 0 4px 20px rgba(0,0,0,.55);
}

.iep-header {
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
  margin-bottom: .35rem;
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iep-fight {
  padding: .15rem 0;
  color: var(--text);
  white-space: nowrap;
}

.iep-enchant-row {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  white-space: normal;
}

.iep-enchant-row .enchant-item-icon {
  flex-shrink: 0;
}

.iep-enchant-row .enchant-item-icon img {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: block;
}

.iep-enchant-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.iep-slot-name {
  font-size: .72rem;
  color: var(--text-muted);
}

.iep-ench-name {
  font-size: .8rem;
  color: var(--text);
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
}
