/**
 * Kibos City — Estilos pixel art y skins multitenancy
 * Extensible: añadir nuevas variantes en .shop-skin--* y .accesorio--*
 */

:root {
  --pixel-size: 4px;
  --color-suelo-a: #1e293b;
  --color-suelo-b: #0f172a;
}

/* Tipografía título pixel */
.pixel-title {
  image-rendering: pixelated;
  text-shadow: 3px 3px 0 #78350f;
}

/* Mundo: render nítido tipo pixel */
.mundo-pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Jugador base (cuadrado pixel escalado) */
.jugador-pixel {
  width: calc(var(--pixel-size) * 6);
  height: calc(var(--pixel-size) * 8);
  z-index: 100;
  transition: transform 0.05s linear;
  background: transparent !important;
  border: none !important;
}

/* --- Skins de avatar (selección + estado en mapa) --- */
.avatar--guerrero {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 40%, #7f1d1d 100%);
  border: 2px solid #fca5a5;
}
.avatar--guerrero::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 25%;
  background: #fecaca;
  border-radius: 1px;
}

.avatar--constructor {
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 50%, #78350f 100%);
  border: 2px solid #fde68a;
}
.avatar--constructor::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  width: 60%;
  height: 30%;
  background: #fef3c7;
}

.avatar--ejecutivo {
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 45%, #172554 100%);
  border: 2px solid #93c5fd;
}
.avatar--ejecutivo::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 15%;
  width: 70%;
  height: 22%;
  background: #1f2937;
}

.avatar--explorador {
  background: linear-gradient(180deg, #047857 0%, #065f46 50%, #064e3b 100%);
  border: 2px solid #6ee7b7;
}
.avatar--explorador::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 4px;
  width: 35%;
  height: 28%;
  background: #d1fae5;
  clip-path: polygon(0 0, 100% 0, 80% 100%, 0 100%);
}

/* Neutraliza skins CSS al usar sprite sheets transparentes */
.jugador-pixel.avatar--guerrero,
.jugador-pixel.avatar--constructor,
.jugador-pixel.avatar--ejecutivo,
.jugador-pixel.avatar--explorador,
.jugador-remoto .avatar--guerrero,
.jugador-remoto .avatar--constructor,
.jugador-remoto .avatar--ejecutivo,
.jugador-remoto .avatar--explorador {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.jugador-pixel.avatar--guerrero::after,
.jugador-pixel.avatar--constructor::after,
.jugador-pixel.avatar--ejecutivo::after,
.jugador-pixel.avatar--explorador::after,
.jugador-remoto .avatar--guerrero::after,
.jugador-remoto .avatar--constructor::after,
.jugador-remoto .avatar--ejecutivo::after,
.jugador-remoto .avatar--explorador::after {
  display: none !important;
}

/* Tarjetas selección avatar (preview) */
.avatar-card-preview {
  width: 120px;
  height: 92px;
  margin: 0 auto 10px;
  position: relative;
}

.avatar-card-preview--cover {
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.avatar-card-preview.avatar-renderer {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* --- Skins de fachada de tienda (multitenancy visual) --- */
.shop {
  position: absolute;
  z-index: 10;
  box-sizing: border-box;
  image-rendering: pixelated;
}

.shop--image {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}
.shop--image .shop-techo,
.shop--image .shop-ventana,
.shop--image .shop-puerta {
  display: none;
}

.shop-skin--moderno {
  background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 35%, #64748b 100%);
  border: 3px solid #f1f5f9;
  box-shadow: inset 0 -8px 0 #475569, 4px 4px 0 rgba(0, 0, 0, 0.35);
}
.shop-skin--moderno .shop-ventana {
  background: #38bdf8;
  border: 2px solid #0ea5e9;
  opacity: 0.9;
}

.shop-skin--retro {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 40%, #92400e 100%);
  border: 3px solid #451a03;
  box-shadow: inset 0 -6px 0 #78350f, 4px 4px 0 #000;
}
.shop-skin--retro .shop-ventana {
  background: #fef08a;
  border: 2px solid #854d0e;
}

.shop-skin--futurista {
  background: linear-gradient(180deg, #22d3ee 0%, #0891b2 45%, #164e63 100%);
  border: 3px solid #a5f3fc;
  box-shadow:
    0 0 12px rgba(34, 211, 238, 0.5),
    inset 0 -8px 0 #0e7490,
    4px 4px 0 rgba(0, 0, 0, 0.4);
}
.shop-skin--futurista .shop-ventana {
  background: #67e8f9;
  border: 2px solid #06b6d4;
  box-shadow: 0 0 8px #22d3ee;
}

.shop-techo {
  position: absolute;
  top: -12px;
  left: -4px;
  right: -4px;
  height: 14px;
  background: #334155;
  border: 2px solid #1e293b;
}

.shop-ventana {
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 28%;
  height: 35%;
}

.shop-puerta {
  position: absolute;
  bottom: 0;
  right: 12px;
  width: 22%;
  height: 42%;
  background: #1e293b;
  border: 2px solid #0f172a;
}

.shop-label {
  position: absolute;
  top: -28px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: bold;
  color: #f8fafc;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Accesorios (vallas, luces, plantas, carteles) --- */
.accesorio {
  position: absolute;
  z-index: 15;
  pointer-events: none;
}

.accesorio--valla {
  width: 56px;
  height: 40px;
  background: #334155;
  border: 2px solid #64748b;
  box-shadow: 2px 2px 0 #000;
}
.accesorio--valla::before {
  content: attr(data-message);
  display: block;
  font-size: 6px;
  line-height: 1.2;
  padding: 4px;
  color: #f1f5f9;
  text-align: center;
  word-break: break-word;
}

.accesorio--luces {
  width: 24px;
  height: 24px;
  background: radial-gradient(circle, #fef08a 0%, #eab308 50%, transparent 70%);
  border-radius: 50%;
  animation: pulso-luz 1.2s ease-in-out infinite;
  box-shadow: 0 0 10px #facc15;
}
@keyframes pulso-luz {
  50% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

.accesorio--planta {
  width: 20px;
  height: 28px;
  background: linear-gradient(180deg, #22c55e 0%, #166534 100%);
  border: 2px solid #14532d;
  border-radius: 2px 2px 0 0;
}
.accesorio--planta::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 2px;
  right: 2px;
  height: 8px;
  background: #78350f;
}

.accesorio--cartel {
  min-width: 48px;
  min-height: 32px;
  background: #fef3c7;
  border: 3px solid #b45309;
  padding: 4px;
  font-size: 7px;
  color: #451a03;
  text-align: center;
  box-shadow: 2px 2px 0 #000;
}

/* Resaltado al estar en rango de interacción */
.shop--cerca {
  outline: 2px dashed #34d399;
  outline-offset: 4px;
}

.shop--image.shop--cerca {
  outline: none;
  outline-offset: 0;
}

.accesorio--valla.cerca {
  outline: 2px dashed #fbbf24;
  outline-offset: 2px;
}

/* --- Fase 2: cyberpunk / multijugador --- */
.cyber-bg {
  background: radial-gradient(ellipse at 50% 0%, #0c4a6e 0%, #020617 55%);
}

#ciclo-dia-noche {
  transition: filter 0.8s ease-out;
}

.jugador-etiqueta {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  margin-bottom: 2px;
  font-size: 8px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 0 #000;
}

.jugador-etiqueta--yo {
  background: #22d3ee;
  color: #0f172a;
  border: 1px solid #67e8f9;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
}

.jugador-etiqueta--otro {
  background: #d946ef;
  color: #faf5ff;
  border: 1px solid #e879f9;
  box-shadow: 0 0 8px rgba(217, 70, 239, 0.5);
}

.jugador-remoto .jugador-pixel {
  opacity: 0.95;
  background: transparent !important;
  border: none !important;
}

.chat-burbuja {
  z-index: 96;
  animation: burbuja-in 0.25s ease-out;
}

@keyframes burbuja-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Fase 3: ciudad viva (workers + sprites + marketing) --- */
.avatar-renderer {
  position: relative;
  image-rendering: pixelated;
  background: transparent !important;
}

.avatar-sprite {
  width: 32px;
  height: 32px;
  position: absolute;
  top: 0;
  left: 0;
  background-repeat: no-repeat;
  background-color: transparent !important;
  image-rendering: pixelated;
  transform: scale(1);
  transform-origin: top left;
}

.avatar-sprite--back {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 70ms linear;
  pointer-events: none;
}

.worker {
  position: absolute;
  z-index: 75;
  pointer-events: none;
}

.worker-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  margin-bottom: 3px;
  white-space: nowrap;
  font-size: 9px;
  color: #e0f2fe;
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(6, 182, 212, 0.6);
  padding: 1px 5px;
  border-radius: 4px;
  text-shadow: 0 1px 0 #000;
}

.marketing-bubble {
  position: absolute;
  max-width: 180px;
  font-size: 10px;
  line-height: 1.2;
  color: #fefce8;
  background: rgba(146, 64, 14, 0.95);
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 4px 6px;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
  animation: marketing-in 0.2s ease-out;
}

@keyframes marketing-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.touch-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: rgba(15, 23, 42, 0.85);
  color: #67e8f9;
  font-weight: bold;
}

.global-chat-line {
  border: 1px solid rgba(51, 65, 85, 0.7);
  background: rgba(15, 23, 42, 0.75);
  border-radius: 6px;
  padding: 4px 6px;
  color: #cbd5e1;
}

.global-chat-line b {
  color: #67e8f9;
}

.chat-panel-header {
  cursor: move;
  user-select: none;
}

.chat-panel-header button {
  cursor: pointer;
}

#global-chat-panel.chat-panel--minimized {
  width: 260px;
  max-height: none;
}

#global-chat-panel.chat-panel--minimized > :not(.chat-panel-header) {
  display: none;
}

.chat-panel-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  background: linear-gradient(135deg, transparent 0 45%, rgba(103, 232, 249, 0.85) 45% 55%, transparent 55% 100%);
  cursor: nwse-resize;
}

.online-player-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
}

.room-member-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
}

/* Feedback al añadir al carrito desde la vitrina */
.btn-add-cart {
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn-add-cart--added {
  animation: btn-add-cart-flash 0.75s ease;
}
@keyframes btn-add-cart-flash {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
  35% {
    transform: scale(1.06);
    box-shadow: 0 0 16px rgba(52, 211, 153, 0.75);
    background-color: rgb(5 150 105) !important;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

.cart-badge-bump {
  animation: cart-badge-bump 0.45s ease;
}
@keyframes cart-badge-bump {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.25);
  }
}

/* Decoración global del tablero (superadmin) */
#capa-mundo-decor .world-decor-wrap {
  position: absolute;
}
#capa-mundo-decor .world-decor-img {
  display: block;
  max-width: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
