/* ============================================================
   BASE.CSS — Reset, Variáveis CSS, Utilitários
   Estética: Dark Medieval Pixel Art RPG
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
  /* ── Paleta Medieval Escura ── */
  --bg-void:      #0d0b09;
  --bg-primary:   #1a1510;
  --bg-secondary: #221c14;
  --bg-panel:     #2a2018;
  --bg-cell:      #1e1812;
  --bg-cell-dark: #161009;
  --bg-header:    #3d2a0e;

  /* Bordas sólidas para Pixel Art */
  --border-outer:  #5a3a18;
  --border-inner:  #3a2510;
  --border-gold:   #c8860a;
  --border-gold-dark: #8b5e06;
  --border-red:    #7a1a1a;
  --border-bright: #7a5520;

  /* Texto */
  --text-primary:  #e8d5a0;
  --text-header:   #f5e080;
  --text-secondary:#b89a60;
  --text-muted:    #6a5030;
  --text-white:    #ffffff;
  --text-red:      #c83030;

  /* Acentos */
  --gold:          #c8860a;
  --gold-bright:   #f0b030;
  --gold-dark:     #7a5006;
  --gold-header:   #d4941a;
  --red-dark:      #6b1010;
  --red-mid:       #8b2020;
  --red-accent:    #c03030;
  --amber:         #b87020;
  --green-dark:    #1a4a1a;
  --green-mid:     #2a6a2a;
  --green-bright:  #4aaa4a;
  --blue-dark:     #1a2a5a;
  --blue-bright:   #4a7aee;
  --purple-dark:   #3a1a6a;
  --purple-bright: #8a4aee;

  /* Raridades */
  --rarity-common:    #9a9080;
  --rarity-uncommon:  #4aaa4a;
  --rarity-rare:      #4a7aee;
  --rarity-epic:      #8a4aee;
  --rarity-legendary: #f0b030;
  --rarity-mythic:    #ee4a4a;

  /* Classes */
  --class-warrior:  #cc3333;
  --class-mage:     #8a4aee;
  --class-archer:   #4aaa4a;
  --class-assassin: #f0b030;

  /* Sombras pixeladas */
  --shadow-sm:   2px 2px 0 rgba(0,0,0,0.8);
  --shadow-md:   4px 4px 0 rgba(0,0,0,0.8);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.9);
  --shadow-inner:inset 2px 2px 0 rgba(0,0,0,0.6);
  --shadow-gold: 0 0 16px rgba(200,134,10,0.4);
  --pixel-border: inset 2px 2px 0 rgba(255,255,255,0.1), inset -2px -2px 0 rgba(0,0,0,0.5);

  /* Bordas quadradas */
  --radius:    0px;
  --radius-sm: 0px;
  --radius-lg: 0px;

  /* Layout */
  --sidebar-width:      240px;
  --header-height:      56px;
  --bottom-nav-height:  64px;

  /* Fontes */
  --font-main:  'VT323', monospace;
  --font-title: 'VT323', monospace;

  /* Transitions */
  --t-fast:   0.12s ease;
  --t-normal: 0.22s ease;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
}
html { font-size: 16px; }
body {
  font-family: var(--font-main);
  background-color: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* Textura de fundo */
  background-image:
    repeating-linear-gradient(
      0deg, transparent, transparent 2px,
      rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px
    );
}

/* ── Scrollbar medieval ── */
::-webkit-scrollbar       { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-cell-dark); border: 1px solid var(--border-inner); }
::-webkit-scrollbar-thumb { background: var(--border-outer); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-gold-dark); }

/* ════════════════════════════════════════════
   PAINÉIS MEDIEVAIS — Estilo TBH
   ════════════════════════════════════════════ */

/* Painel base com borda ornamentada */
.panel {
  background: var(--bg-panel);
  border: 2px solid var(--border-outer);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(200,134,10,0.1);
  position: relative;
}

/* Borda dupla — efeito ornamental */
.panel::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid var(--border-inner);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* Barra de título estilo TBH */
.panel-title-bar {
  background: linear-gradient(180deg, #5a3a0a 0%, #3d2608 40%, #2e1c06 100%);
  border-bottom: 2px solid var(--border-gold-dark);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: -2px -2px 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Cantos decorativos nos títulos */
.panel-title-bar::before,
.panel-title-bar::after {
  content: '✦';
  font-size: 0.9rem;
  color: var(--text-muted);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.panel-title-bar::before { left: 8px; }
.panel-title-bar::after  { right: 8px; }

.panel-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-header);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 8px rgba(200,134,10,0.3);
}

/* Painel com título embutido */
.panel-body {
  padding: 12px;
}

/* ── Borda ornamental com cantos ── */
.ornate-border {
  position: relative;
}
.ornate-border::after {
  content: '';
  position: absolute;
  inset: -4px;
  background:
    linear-gradient(var(--border-gold-dark), var(--border-gold-dark)) top left / 8px 8px no-repeat,
    linear-gradient(var(--border-gold-dark), var(--border-gold-dark)) top right / 8px 8px no-repeat,
    linear-gradient(var(--border-gold-dark), var(--border-gold-dark)) bottom left / 8px 8px no-repeat,
    linear-gradient(var(--border-gold-dark), var(--border-gold-dark)) bottom right / 8px 8px no-repeat;
  pointer-events: none;
  z-index: 1;
}

/* ════════════════════════════════════════════
   BOTÕES MEDIEVAIS
   ════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn:active { transform: scale(0.96) translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

/* Botão primário — marrom/ouro */
.btn-primary {
  background: linear-gradient(180deg, #5a3a0e 0%, #3d2608 100%);
  color: var(--text-header);
  border: 1px solid var(--border-gold-dark);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(200,134,10,0.2);
  padding: 8px 16px;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6a4a18 0%, #4d3010 100%);
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: var(--shadow-gold);
}

/* Botão de ação — vermelho (Atacar) */
.btn-danger {
  background: linear-gradient(180deg, #6a1a1a 0%, #3d0a0a 100%);
  color: #f09090;
  border: 1px solid var(--red-mid);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(200,60,60,0.2);
  padding: 8px 16px;
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #8a2a2a 0%, #5a1010 100%);
  border-color: var(--red-accent);
  color: #ffaaaa;
  box-shadow: 0 0 16px rgba(180,40,40,0.4);
}

/* Botão ouro */
.btn-gold {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #1a0f00;
  border: 1px solid var(--gold-bright);
  box-shadow: var(--shadow-sm);
  padding: 8px 16px;
  font-weight: 800;
}
.btn-gold:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

/* Botão fantasma */
.btn-ghost {
  background: var(--bg-cell-dark);
  color: var(--text-secondary);
  border: 1px solid var(--border-inner);
  padding: 8px 14px;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-cell);
  border-color: var(--border-outer);
  color: var(--text-primary);
}

.btn-sm { padding: 5px 10px; font-size: 0.72rem; }
.btn-lg { padding: 12px 24px; font-size: 0.9rem; }

/* ════════════════════════════════════════════
   BARRAS DE PROGRESSO
   ════════════════════════════════════════════ */

.bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-cell-dark);
  border: 1px solid var(--border-inner);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-inner);
}
.bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.35s ease;
}
.bar-hp  { background: linear-gradient(90deg, #8b1a1a, #cc3333); }
.bar-mp  { background: linear-gradient(90deg, #1a3a8b, #4477ee); }
.bar-xp  { background: linear-gradient(90deg, #5a1a8b, #9944ee); }
.bar-enemy { background: linear-gradient(90deg, #7a2020, #dd5555); }
.bar-boss  { background: linear-gradient(90deg, #6b0000, #cc2020, #ff8800); }

.bar-track.thin  { height: 6px; }
.bar-track.thick { height: 14px; }

/* ════════════════════════════════════════════
   BADGES DE RARIDADE
   ════════════════════════════════════════════ */

.rarity-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.rarity-common    { color: var(--rarity-common);    border-color: rgba(154,144,128,0.4); background: rgba(154,144,128,0.08); }
.rarity-uncommon  { color: var(--rarity-uncommon);  border-color: rgba(74,170,74,0.5);   background: rgba(74,170,74,0.08); }
.rarity-rare      { color: var(--rarity-rare);      border-color: rgba(74,122,238,0.5);  background: rgba(74,122,238,0.08); }
.rarity-epic      { color: var(--rarity-epic);      border-color: rgba(138,74,238,0.5);  background: rgba(138,74,238,0.08); }
.rarity-legendary { color: var(--rarity-legendary); border-color: rgba(240,176,48,0.5);  background: rgba(240,176,48,0.1); }
.rarity-mythic    { color: var(--rarity-mythic);    border-color: rgba(238,74,74,0.5);   background: rgba(238,74,74,0.1); }

/* ════════════════════════════════════════════
   GRID DE CÉLULAS — Estilo inventário TBH
   ════════════════════════════════════════════ */

.item-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 6), 1fr);
  gap: 3px;
  background: var(--bg-cell-dark);
  border: 1px solid var(--border-inner);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.item-cell {
  aspect-ratio: 1;
  background: var(--bg-cell);
  border: 1px solid var(--border-inner);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}
.item-cell:hover:not(.empty) {
  background: var(--bg-panel);
  border-color: var(--border-gold-dark);
  box-shadow: 0 0 8px rgba(200,134,10,0.3), inset 0 1px 3px rgba(0,0,0,0.3);
  transform: scale(1.06);
  z-index: 5;
}
.item-cell.empty { cursor: default; }
.item-cell.equipped {
  background: rgba(138,74,238,0.12);
  border-color: rgba(138,74,238,0.5);
}
.item-cell.selected {
  background: rgba(200,134,10,0.15);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(200,134,10,0.4);
}

/* Rarity corner marker */
.item-cell[data-rarity="uncommon"]  { border-color: rgba(74,170,74,0.5); }
.item-cell[data-rarity="rare"]      { border-color: rgba(74,122,238,0.5); }
.item-cell[data-rarity="epic"]      { border-color: rgba(138,74,238,0.5); }
.item-cell[data-rarity="legendary"] {
  border-color: rgba(240,176,48,0.6);
  box-shadow: inset 0 0 8px rgba(240,176,48,0.1);
}
.item-cell[data-rarity="mythic"] {
  border-color: rgba(238,74,74,0.6);
  box-shadow: inset 0 0 8px rgba(238,74,74,0.1);
}

/* Contador de quantidade */
.item-count {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 1px 3px rgba(0,0,0,1);
  line-height: 1;
}

/* ════════════════════════════════════════════
   MODAIS
   ════════════════════════════════════════════ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-panel);
  border: 2px solid var(--border-outer);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0,0,0,0.8);
  max-width: 480px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlideIn 0.22s ease;
  position: relative;
}
.modal::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid var(--border-inner);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* ════════════════════════════════════════════
   TOOLTIPS
   ════════════════════════════════════════════ */

.tooltip {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-outer);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.78rem;
  z-index: 1000;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  max-width: 240px;
}
.tooltip::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid var(--border-inner);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* ════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════ */

.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-cell-dark);
  border: 1px solid var(--border-inner);
  padding: 3px;
  border-radius: var(--radius-sm);
}
.tab-btn {
  flex: 1;
  padding: 6px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tab-btn:hover { color: var(--text-secondary); background: var(--bg-cell); }
.tab-btn.active {
  background: linear-gradient(180deg, #4a3008 0%, #2e1c06 100%);
  color: var(--text-header);
  border-color: var(--border-gold-dark);
}

/* ════════════════════════════════════════════
   UTILITÁRIOS
   ════════════════════════════════════════════ */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.relative { position: relative; }

/* Textos coloridos */
.gold-text   { color: var(--gold-bright); font-weight: 700; }
.red-text    { color: var(--red-accent);  font-weight: 700; }
.green-text  { color: var(--green-bright); font-weight: 700; }
.blue-text   { color: var(--blue-bright); font-weight: 700; }
.purple-text { color: var(--purple-bright); font-weight: 700; }
.muted-text  { color: var(--text-muted); }

/* Divisor */
.divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-outer), transparent);
  margin: 10px 0;
}

/* Estado vazio */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.3; }

/* Spinner de carregamento */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-inner);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.class-image { width: 64px; height: 64px; object-fit: contain; margin-bottom: 8px; image-rendering: pixelated; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.8)); }

