/* ============================================
   FarmBrawl — Sidebar v2 (farm inventory board)
   Wooden signboard + inventory slots.
   Overrides juegoprueba.css via cascade.
   ============================================ */

:root {
  --sb-w: 208px;
  --sb-ink: #120e0b;
  --sb-wood-hi: #4a3728;
  --sb-wood-mid: #2f2218;
  --sb-wood-lo: #1a120e;
  --sb-leather: #241912;
  --sb-cream: #f4ead8;
  --sb-cream-dim: #cbb89a;
  --sb-muted: #8f7d68;
  --sb-gold: #f0c14b;
  --sb-gold-deep: #c49220;
  --sb-moss: #6ab04a;
  --sb-edge: #0a0604;
  --sb-slot: #16100c;
  --sb-radius: 4px;
  --sidebar-w: 208px;
}

/* ─── Shell: tabla de madera + cuero ─── */
#sidebar {
  width: var(--sb-w) !important;
  min-width: var(--sb-w) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  z-index: 50;
  /* Marco exterior tipo letrero */
  background:
    /* bisel izquierdo / derecho */
    linear-gradient(90deg, rgba(0, 0, 0, 0.45) 0%, transparent 10px, transparent calc(100% - 8px), rgba(0, 0, 0, 0.28) 100%),
    /* vena horizontal sutil */
    repeating-linear-gradient(
      180deg,
      transparent 0 28px,
      rgba(0, 0, 0, 0.18) 28px 29px,
      rgba(255, 220, 160, 0.03) 29px 30px
    ),
    /* cuero interior */
    radial-gradient(120% 80% at 50% 0%, rgba(74, 55, 40, 0.55) 0%, transparent 55%),
    linear-gradient(168deg, var(--sb-wood-hi) 0%, var(--sb-wood-mid) 38%, var(--sb-wood-lo) 100%) !important;
  border-right: 3px solid var(--sb-edge) !important;
  box-shadow:
    inset 2px 0 0 rgba(255, 230, 180, 0.08),
    inset -2px 0 0 rgba(0, 0, 0, 0.45),
    8px 0 28px rgba(0, 0, 0, 0.5) !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(240, 193, 75, 0.45) transparent;
}

#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--sb-gold), var(--sb-gold-deep));
  border-radius: 99px;
}

/* Brand desactivado */
.sb-brand { display: none !important; }

/* ─── Scroll body ─── */
.sb-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(240, 193, 75, 0.35) transparent;
}

.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb {
  background: rgba(240, 193, 75, 0.35);
  border-radius: 99px;
}

/* ─── Secciones ─── */
.sb-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px 6px;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0.08) 100%);
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 180, 0.06),
    0 2px 0 rgba(0, 0, 0, 0.25);
}

.sb-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 6px;
  margin: 0 2px 2px;
  font-family: var(--font-ui, 'Nunito', system-ui, sans-serif);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sb-gold);
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(240, 193, 75, 0.25);
  border-bottom: 1px dashed rgba(240, 193, 75, 0.22);
}

.sb-section-label::before {
  content: "";
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  background: var(--sb-gold);
  box-shadow: 0 0 6px rgba(240, 193, 75, 0.7);
  transform: rotate(45deg);
}

.sb-section-label::after {
  content: none;
}

/* ─── Items (slots de inventario) ─── */
#sidebar .tab {
  position: relative;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  margin: 0 !important;
  padding: 6px 8px 6px 6px !important;
  min-height: 40px;
  border-radius: var(--sb-radius) !important;
  border: 2px solid transparent !important;
  border-left: 2px solid transparent !important;
  background: transparent !important;
  color: var(--sb-cream-dim) !important;
  font-family: var(--font-ui, 'Nunito', system-ui, sans-serif) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  line-height: 1.2 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  text-decoration: none !important;
  cursor: pointer;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease,
    transform 0.1s ease,
    box-shadow 0.14s ease !important;
  box-shadow: none !important;
}

/* kill legacy arrow */
#sidebar .tab::before {
  content: none !important;
  display: none !important;
}

#sidebar .tab .tab-ic,
#sidebar .tab .tab-ic-wrap {
  flex-shrink: 0;
}

/* Slot de icono: marco pixel / inventário */
#sidebar .tab .tab-ic-wrap {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(160deg, rgba(255, 230, 180, 0.06) 0%, transparent 42%),
    radial-gradient(circle at 50% 40%, rgba(60, 45, 30, 0.9), var(--sb-slot));
  border: 2px solid #0a0604;
  box-shadow:
    inset 1px 1px 0 rgba(255, 230, 180, 0.12),
    inset -1px -1px 0 rgba(0, 0, 0, 0.55),
    0 2px 0 #050302,
    0 0 0 1px rgba(255, 220, 150, 0.06);
  transition:
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.1s ease,
    background 0.14s ease;
}

#sidebar .tab .tab-ic {
  width: 20px !important;
  height: 20px !important;
  object-fit: contain !important;
  image-rendering: auto !important;
  filter: saturate(1.05) contrast(1.05) !important;
  opacity: 0.95 !important;
  transition: opacity 0.12s ease, transform 0.12s ease, filter 0.12s ease !important;
}

#sidebar .tab > span:not(.tab-ic-wrap) {
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tintes por ruta (borde interior del slot) */
#sidebar .tab[data-tab="home"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(106, 176, 74, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="attack"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(239, 98, 72, 0.5), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="missions"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(240, 193, 75, 0.4), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="roulette"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(244, 114, 182, 0.4), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="shop"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="market"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.4), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="exchange"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="staking"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="withdrawals"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.4), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="inventory"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(180, 140, 90, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="forge"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="laboratory"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.5), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="referrals"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.4), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }
#sidebar .tab[data-tab="rewards"] .tab-ic-wrap { box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.45), inset 1px 1px 0 rgba(255,230,180,0.1), 0 2px 0 #050302; }

/* Hover: tablero iluminado */
#sidebar .tab:hover {
  color: var(--sb-cream) !important;
  background: linear-gradient(90deg, rgba(240, 193, 75, 0.1), rgba(255, 230, 180, 0.04)) !important;
  border-color: rgba(240, 193, 75, 0.22) !important;
  transform: translateX(2px);
}

#sidebar .tab:hover .tab-ic-wrap {
  transform: translateY(-1px);
  border-color: rgba(240, 193, 75, 0.55);
}

#sidebar .tab:hover .tab-ic {
  opacity: 1 !important;
  filter: saturate(1.15) contrast(1.08) drop-shadow(0 0 2px rgba(255, 255, 255, 0.15)) !important;
}

/* Active: slot seleccionado */
#sidebar .tab.active {
  color: #fff6d8 !important;
  background:
    linear-gradient(90deg, rgba(240, 193, 75, 0.22) 0%, rgba(106, 176, 74, 0.1) 70%, transparent 100%) !important;
  border-color: rgba(240, 193, 75, 0.7) !important;
  box-shadow:
    inset 0 0 0 1px rgba(240, 193, 75, 0.18),
    0 0 16px rgba(240, 193, 75, 0.12) !important;
  transform: none;
}

#sidebar .tab.active .tab-ic-wrap {
  border-color: var(--sb-gold) !important;
  background:
    linear-gradient(160deg, rgba(240, 193, 75, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 50% 40%, #3a2a18, #120e0a);
  box-shadow:
    inset 0 0 0 1px rgba(240, 193, 75, 0.55),
    inset 1px 1px 0 rgba(255, 255, 255, 0.12),
    0 0 12px rgba(240, 193, 75, 0.35),
    0 2px 0 #050302 !important;
}

#sidebar .tab.active .tab-ic {
  opacity: 1 !important;
  filter: saturate(1.2) contrast(1.1) drop-shadow(0 0 3px rgba(240, 193, 75, 0.55)) !important;
}

/* Diamante activo a la derecha */
#sidebar .tab.active::after {
  content: "";
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  margin-left: 2px;
  background: linear-gradient(145deg, #ffe08a, var(--sb-gold-deep));
  border: 1px solid #5a3a08;
  box-shadow: 0 0 8px rgba(240, 193, 75, 0.75);
  transform: rotate(45deg);
}

#sidebar .tab:active {
  transform: scale(0.985);
}

#sidebar .tab:focus-visible {
  outline: 2px solid var(--sb-gold);
  outline-offset: 1px;
}

/* ─── Footer ─── */
#sidebar-footer {
  flex-shrink: 0;
  margin-top: 0 !important;
  padding: 10px 12px 12px !important;
  border-top: 2px solid var(--sb-edge) !important;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.4));
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.08);
}

#sidebar .sidebar-version {
  font-family: var(--font-ui, 'Nunito', system-ui, sans-serif);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sb-muted);
  text-align: center;
  opacity: 0.9;
}

/* Profile card (legacy, si reaparece) */
#sidebar #profile-card {
  display: none !important;
}

/* ─── Responsive: rail de iconos ─── */
@media (max-width: 900px) {
  :root {
    --sb-w: 58px;
    --sidebar-w: 58px;
  }

  #sidebar {
    width: var(--sb-w) !important;
    min-width: var(--sb-w) !important;
  }

  .sb-section {
    padding: 6px 4px;
    gap: 4px;
  }

  .sb-section-label,
  #sidebar .tab > span:not(.tab-ic-wrap),
  #sidebar .tab.active::after,
  #sidebar .sidebar-version {
    display: none !important;
  }

  .sb-nav {
    padding: 8px 6px;
    gap: 10px;
  }

  #sidebar .tab {
    justify-content: center !important;
    padding: 6px 0 !important;
    gap: 0 !important;
    min-height: 40px;
  }

  #sidebar .tab:hover {
    transform: none;
  }

  #sidebar-footer {
    padding: 8px 4px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar .tab,
  #sidebar .tab .tab-ic,
  #sidebar .tab .tab-ic-wrap {
    transition: none !important;
  }
}
