/* ==========================================================================
   SPAWNCHRONO - UNIVERSAL MMORPG BOSS & RESPAWN TRACKER (TABLE HUD)
   Zero visual fluff, high information density, full names (no truncation),
   defined respawn, elapsed time, time remaining, and % progress.
   Built for any game: T4C, Tibia, Ragnarok Online, WoW, Lineage II, Custom.
   ========================================================================== */

:root {
  --bg-app: #08090d;
  --bg-panel: #11131c;
  --bg-row-hover: #171a26;
  --bg-header: #151824;

  --border-subtle: #1e2230;
  --border-focus: #333a52;

  --gold: #eab308;
  --gold-dim: rgba(234, 179, 8, 0.15);

  --window-green: #10b981;
  --window-dim: rgba(16, 185, 129, 0.14);
  --window-glow: 0 0 10px rgba(16, 185, 129, 0.35);

  --overdue-red: #f43f5e;
  --overdue-dim: rgba(244, 63, 94, 0.14);
  --overdue-glow: 0 0 10px rgba(244, 63, 94, 0.35);

  --wait-blue: #38bdf8;
  --wait-dim: rgba(56, 189, 248, 0.12);

  --boss-purple: #c084fc;
  --boss-dim: rgba(192, 132, 252, 0.14);

  --event-amber: #f59e0b;
  --event-dim: rgba(245, 158, 11, 0.14);

  --elite-teal: #2dd4bf;
  --elite-dim: rgba(45, 212, 191, 0.14);

  --text-pure: #ffffff;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
}

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

html, body {
  height: 100vh;
  width: 100vw;
  overflow: hidden; /* Zero page scroll */
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: none;
  background: none;
}
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* Master Layout */
.hud-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 6px 12px;
  gap: 5px;
}

/* ==========================================================================
   TOP BAR (Compact Single-Row Navigation: ~38px)
   ========================================================================== */
.hud-top-bar {
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 10px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--text-pure);
  white-space: nowrap;
}
.brand-crest {
  color: var(--gold);
  font-size: 16px;
}
.brand-text {
  font-size: 14px;
  letter-spacing: 0.05em;
}

/* Game Preset Dropdown */
.game-selector-wrap select {
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.45);
  color: var(--gold);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
}
.game-selector-wrap select:focus {
  border-color: var(--gold);
}

.hud-stat-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11.5px;
}
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}
.stat-badge:hover { color: var(--text-pure); }
.badge-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-pure);
}
.badge-window .badge-val { color: var(--window-green); }
.badge-overdue .badge-val { color: var(--overdue-red); }
.badge-sep { color: var(--border-subtle); font-size: 10px; }

.dot-win {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--window-green);
  box-shadow: 0 0 6px var(--window-green);
}
.dot-due {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--overdue-red);
  box-shadow: 0 0 6px var(--overdue-red);
}

/* Center Filters */
.top-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 2px;
}
.filter-pill {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s;
}
.filter-pill:hover { color: var(--text-pure); background: rgba(255, 255, 255, 0.05); }
.filter-pill.active {
  background: rgba(234, 179, 8, 0.18);
  color: var(--gold);
  font-weight: 700;
}
.filter-pill.pill-alert.active {
  background: var(--window-dim);
  color: var(--window-green);
}

.compact-search-wrap {
  position: relative;
  width: 150px;
}
.compact-search-wrap input {
  width: 100%;
  height: 25px;
  padding: 0 20px 0 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-pure);
  font-size: 11.5px;
  transition: width 0.15s;
}
.compact-search-wrap input:focus {
  outline: none;
  border-color: var(--gold);
  width: 180px;
}
.search-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 13px;
}

/* Right Actions */
.top-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-top-act {
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-add {
  background: #ca8a04;
  color: #0c0a03;
  font-weight: 700;
}
.btn-add:hover { filter: brightness(1.15); }

.btn-sim {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  color: var(--gold);
}
.btn-sim:hover { background: rgba(234, 179, 8, 0.22); }

.btn-top-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  position: relative;
}
.btn-top-icon:hover { color: var(--text-pure); border-color: var(--border-focus); background: var(--bg-row-hover); }
#btnSoundToggle {
  width: auto;
  padding: 0 7px;
  font-size: 11px;
}
.badge-count {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--gold);
  color: #000;
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 3px;
  border-radius: 6px;
}

.lang-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 1px;
  gap: 1px;
}
.lang-opt {
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 2px;
}
.lang-opt:hover { color: var(--text-pure); }
.lang-opt.active {
  background: var(--gold);
  color: #000;
}

/* ==========================================================================
   CLEAN & COMPACT TABLE (Fills 100% of remaining height, zero page scroll)
   ========================================================================== */
.table-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.table-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.table-container::-webkit-scrollbar-track {
  background: var(--bg-panel);
}
.table-container::-webkit-scrollbar-thumb {
  background: var(--border-focus);
  border-radius: 3px;
}

.t4c-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.t4c-table th {
  position: sticky;
  top: 0;
  background: var(--bg-header);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border-subtle);
  z-index: 10;
  white-space: nowrap;
}

.t4c-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  vertical-align: middle;
  height: 40px;
}

.t4c-table tr:hover td {
  background: var(--bg-row-hover);
}

/* Status row highlights */
.t4c-table tr.row-window td {
  background: rgba(16, 185, 129, 0.06);
}
.t4c-table tr.row-window td:first-child {
  border-left: 3px solid var(--window-green);
}

.t4c-table tr.row-overdue td {
  background: rgba(244, 63, 94, 0.06);
}
.t4c-table tr.row-overdue td:first-child {
  border-left: 3px solid var(--overdue-red);
}

/* Target Column */
.target-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.type-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.type-badge.boss {
  background: var(--boss-dim);
  color: var(--boss-purple);
  border: 1px solid rgba(192, 132, 252, 0.3);
}
.type-badge.chest {
  background: var(--wait-dim);
  color: var(--wait-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.type-badge.event {
  background: var(--event-dim);
  color: var(--event-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.type-badge.elite {
  background: var(--elite-dim);
  color: var(--elite-teal);
  border: 1px solid rgba(45, 212, 191, 0.3);
}

.target-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.target-name-full {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-pure);
  white-space: nowrap; /* Full name, no truncation! */
}
.target-drops {
  font-size: 10.5px;
  color: var(--gold);
  white-space: nowrap;
}

/* Location Column */
.location-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.zone-tag-mini {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: #a5b4fc;
  border: 1px solid rgba(165, 180, 252, 0.2);
}
.loc-text {
  color: var(--text-muted);
  font-size: 12px;
}

/* Respawn Column */
.respawn-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Elapsed Time Column (Passou) */
.elapsed-cell {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-pure);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.elapsed-empty {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
}

/* Status / Time Remaining Column */
.status-pill-clean {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-pill-clean.pill-window {
  background: var(--window-dim);
  color: var(--window-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
  animation: pulseWindow 1.8s infinite;
}
.status-pill-clean.pill-overdue {
  background: var(--overdue-dim);
  color: var(--overdue-red);
  border: 1px solid rgba(244, 63, 94, 0.4);
  animation: pulseOverdue 1.8s infinite;
}
.status-pill-clean.pill-wait {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.status-pill-clean.pill-none {
  background: transparent;
  color: var(--text-dim);
}
.time-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
}

/* Progress % Column */
.progress-col-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
}
.progress-pct-text {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.progress-pct-bold {
  color: var(--text-pure);
  font-weight: 700;
}
.progress-bar-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s linear;
}
.progress-bar-fill.fill-wait { background: #3b82f6; }
.progress-bar-fill.fill-window {
  background: var(--window-green);
  box-shadow: 0 0 6px var(--window-green);
}
.progress-bar-fill.fill-overdue {
  background: var(--overdue-red);
  box-shadow: 0 0 6px var(--overdue-red);
}

/* Action Button Column (Clean & Compact) */
.action-cell-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-main-action {
  height: 27px;
  padding: 0 12px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  transition: transform 0.1s, filter 0.15s;
}
.btn-main-action:active { transform: scale(0.95); }
.btn-kill {
  background: #059669;
  color: #fff;
  border: 1px solid #10b981;
}
.btn-kill:hover { filter: brightness(1.2); }
.btn-open {
  background: #0284c7;
  color: #fff;
  border: 1px solid #38bdf8;
}
.btn-open:hover { filter: brightness(1.2); }

.btn-more-options {
  width: 27px;
  height: 27px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 14px;
}
.btn-more-options:hover {
  color: var(--text-pure);
  background: var(--bg-row-hover);
  border-color: var(--border-focus);
}

/* Action Popover */
.action-popover {
  position: fixed;
  background: var(--bg-header);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  padding: 4px;
  z-index: 90;
  min-width: 220px;
}
.popover-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text-main);
  text-align: left;
}
.popover-item:hover {
  background: var(--bg-row-hover);
  color: var(--text-pure);
}
.popover-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 3px 0;
}
.popover-danger:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--overdue-red);
}

/* Dropdown Simulation Menu */
.dropdown-wrap { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 250px;
  background: var(--bg-header);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  padding: 4px;
  z-index: 50;
}
.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-xs);
  text-align: left;
}
.dropdown-item:hover { background: var(--border-subtle); }
.dropdown-item strong { display: block; font-size: 12px; color: var(--text-pure); }
.dropdown-item small { display: block; font-size: 10.5px; color: var(--text-muted); }
.sim-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-live { background: #eab308; }
.dot-frenzy { background: #10b981; }
.dot-overdue { background: #f43f5e; }
.dot-wait { background: #38bdf8; }
.dot-clear { background: #64748b; }
.dot-reset { background: #a855f7; }
.dropdown-divider { height: 1px; background: var(--border-subtle); margin: 3px 0; }

/* Footer */
.hud-footer {
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
}
.foot-left { display: flex; align-items: center; gap: 6px; }
.live-indicator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--window-green);
  box-shadow: 0 0 5px var(--window-green);
}
.foot-right { display: flex; align-items: center; gap: 6px; }

/* Empty state */
.table-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.empty-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}
.modal.open { opacity: 1; visibility: visible; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}
.modal-panel {
  position: relative;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
}
.modal-panel-sm { width: min(380px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-head h2 { font-size: 15px; font-weight: 700; color: var(--text-pure); }
.modal-close { font-size: 18px; color: var(--text-dim); }
.modal-close:hover { color: var(--text-pure); }
.modal-body { padding: 16px; }
.modal-intro { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

.form-row { display: flex; gap: 10px; margin-bottom: 10px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.form-field { margin-bottom: 10px; }
.form-field label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.form-field input, .form-field select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: #090a0f;
  color: var(--text-pure);
}
.form-field input:focus, .form-field select:focus {
  outline: none;
  border-color: var(--gold);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.btn-modal {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
}
.btn-save { background: var(--gold); color: #000; font-weight: 700; }
.btn-cancel { background: var(--border-focus); color: var(--text-main); }

.quick-offset-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.btn-offset-chip {
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-row-hover);
  color: var(--text-main);
  text-align: left;
  font-size: 12px;
}
.btn-offset-chip:hover { border-color: var(--gold); color: var(--text-pure); }

.custom-offset-box label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.custom-offset-input-wrap { display: flex; gap: 6px; }
.custom-offset-input-wrap input {
  flex: 1;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: #090a0f;
  color: var(--text-pure);
}

.hidden-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.hidden-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-row-hover);
  border-radius: var(--radius-xs);
  font-size: 12px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  background: var(--bg-header);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-pure);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}
.toast.toast-success { border-color: var(--window-green); }
.toast.toast-warning { border-color: var(--gold); }
.toast.toast-danger { border-color: var(--overdue-red); }

@keyframes pulseWindow {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}
@keyframes pulseOverdue {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.hidden { display: none !important; }
