/* ============================================================
   Space HeatMap Pro — Dashboard fullscreen para thin clients
   Resolución objetivo: 1920×1080, sin mouse
   ============================================================ */

/* ── Reset fullscreen ── */
.sp-dashboard {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
}

/* ══════════════════════════════════════════════════════════════
   NAVBAR (~6vh)
   ══════════════════════════════════════════════════════════════ */
.sp-navbar {
    height: 6vh;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background: var(--bg-primary);
    flex-shrink: 0;
    gap: 1.5rem;
}

.sp-navbar__left,
.sp-navbar__right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.sp-navbar__brand {
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    font-weight: 300;
    color: var(--white);
    letter-spacing: 0.01em;
}

.sp-navbar__brand-stow {
    font-weight: 700;
}

/* Leyenda central */
.sp-navbar__center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.sp-navbar__leyenda {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sp-navbar__leyenda-text {
    font-size: clamp(0.6rem, 0.9vw, 0.8rem);
    color: var(--text-secondary);
    white-space: nowrap;
}

.sp-navbar__leyenda-bar {
    width: clamp(120px, 15vw, 250px);
    height: 0.6rem;
    border-radius: 0.3rem;
    background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
}

/* Timestamp */
.sp-navbar__right {
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
}

.sp-navbar__timestamp {
    font-size: clamp(0.75rem, 1.1vw, 1rem);
    color: var(--gray-300);
    font-weight: 600;
    white-space: nowrap;
}

.sp-navbar__update-label {
    font-size: clamp(0.5rem, 0.7vw, 0.65rem);
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   SVG HEATMAP — Tamaño y posición CSS por zona
   ══════════════════════════════════════════════════════════════
   El mismo SVG de data/space/ se usa en /space/ (sin zoom)
   y aquí con tamaño y posición personalizados por zona.

   Cada zona controla 4 cosas:
     1. width  del SVG  → qué tan ancho se ve (% del contenedor)
     2. height del SVG  → qué tan alto se ve (% del contenedor)
     3. translateX      → mover horizontalmente (+ derecha, - izquierda)
     4. translateY      → mover verticalmente (+ abajo, - arriba)

   Para ajustar una zona:
     .sp-heatmap[data-zona="XX"] .sp-heatmap__inner svg {
         width: 94%;       ← tamaño horizontal
         height: 78%;      ← tamaño vertical
     }
     .sp-heatmap[data-zona="XX"] .sp-heatmap__inner {
         transform: translate(5%, -3%);  ← posición X, Y
     }
   ══════════════════════════════════════════════════════════════ */
.sp-heatmap {
    flex: 1;
    overflow: hidden;
    background: #0e0e0e; /* audit:keep — SVG heatmap background, intentionally near-black */
    position: relative;
}

.sp-heatmap__inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
}

/* Tamaño base del SVG (se sobreescribe por zona) */
.sp-heatmap__inner svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Ocultar el fondo original del SVG para que se vea el color de .sp-heatmap
   P1, P2 usan id="Layer_154" — P3, P4, P5 usan id="Fondo" */
.sp-heatmap__inner svg #Layer_154,
.sp-heatmap__inner svg #Fondo {
    fill: #0e0e0e; /* audit:keep — SVG heatmap background fill */
}

/* ── P1 — Piso 1 ── */
.sp-heatmap[data-zona="P1"] .sp-heatmap__inner svg {
    width: 137%;
    height: 162%;
    transform: translate(0%, 4%);
}

/* ── P1Z1 — Piso 1 Zona 1 ── */
.sp-heatmap[data-zona="P1Z1"] .sp-heatmap__inner svg {
    width: 137%;
    height: 162%;
    transform: translate(0%, 4%);
}

/* ── P1Z2 — Piso 1 Zona 2 ── */
.sp-heatmap[data-zona="P1Z2"] .sp-heatmap__inner svg {
    width: 137%;
    height: 162%;
    transform: translate(0%, 4%);
}

/* ── P2 — Piso 2 ── */
.sp-heatmap[data-zona="P2"] .sp-heatmap__inner svg {
    width: 137%;
    height: 162%;
    transform: translate(0%, 4%);
}

/* ── P2Z1 — Piso 2 Zona 1 ── */
.sp-heatmap[data-zona="P2Z1"] .sp-heatmap__inner svg {
    width: 137%;
    height: 162%;
    transform: translate(0%, 4%);
}

/* ── P2Z2 — Piso 2 Zona 2 ── */
.sp-heatmap[data-zona="P2Z2"] .sp-heatmap__inner svg {
    width: 137%;
    height: 162%;
    transform: translate(0%, 4%);
}

/* ── P3 — Piso 3 completo ── */
.sp-heatmap[data-zona="P3"] .sp-heatmap__inner svg {
    width: 125%;
    height: 161%;
    transform: translate(0%, 6.5%);
}


/* ── P3Z1 — Piso 3 Zona 1 ── */
.sp-heatmap[data-zona="P3Z1"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P3Z2 — Piso 3 Zona 2 ── */
.sp-heatmap[data-zona="P3Z2"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P3Z3 — Piso 3 Zona 3 ── */
.sp-heatmap[data-zona="P3Z3"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P4 — Piso 4 ── */
.sp-heatmap[data-zona="P4"] .sp-heatmap__inner svg {
    width: 125%;
    height: 161%;
    transform: translate(0%, 6.5%);
}

/* ── P4Z1 — Piso 4 Zona 1 ── */
.sp-heatmap[data-zona="P4Z1"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P4Z2 — Piso 4 Zona 2 ── */
.sp-heatmap[data-zona="P4Z2"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P4Z3 — Piso 4 Zona 3 ── */
.sp-heatmap[data-zona="P4Z3"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P5 — Piso 5 ── */
.sp-heatmap[data-zona="P5"] .sp-heatmap__inner svg {
    width: 125%;
    height: 161%;
    transform: translate(0%, 6.5%);
}

/* ── P5Z1 — Piso 5 Zona 1 ── */
.sp-heatmap[data-zona="P5Z1"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P5Z2 — Piso 5 Zona 2 ── */
.sp-heatmap[data-zona="P5Z2"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── P5Z3 — Piso 5 Zona 3 ── */
.sp-heatmap[data-zona="P5Z3"] .sp-heatmap__inner svg {
    width: 100%;
    height: 140%;
    transform: translate(1%, 9%);
}

/* ── HRK — Hazmat Rack ── */
.sp-heatmap[data-zona="HRK"] .sp-heatmap__inner svg {
    width: 100%;
    height: 100%;
}

/* ══════════════════════════════════════════════════════════════
   BARRA INFERIOR — Título arriba + Zona + Tarjetas
   ══════════════════════════════════════════════════════════════ */
.sp-barra {
    height: 13rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-hover) 100%);
    border-top: 2px solid var(--border-primary);
    padding: 0.3rem 1.5rem 0.5rem 0;
    gap: 0.2rem;
}

/* (título y countdown ahora están dentro de .sp-barra__zona) */

/* Fila con zona + tarjetas */
.sp-barra__row {
    display: flex;
    align-items: stretch;
    flex: 1;
    gap: 1rem;
    min-height: 0;
    margin-bottom: 0.5rem;
}

/* Indicador de zona grande (P3, P1, etc.) — fondo más oscuro */
.sp-barra__zona {
    font-weight: 900;
    color: var(--white);
    line-height: 1;
    padding: 0.4rem 1rem 0.4rem 0.8rem;
    margin: 0;
    flex-shrink: 0;
    min-width: 7rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 0 0.5rem 0.5rem 0;
    gap: 0.15rem;
}

.sp-barra__zona-nombre {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 900;
    line-height: 1;
}

.sp-barra__zona-titulo {
    font-size: clamp(0.75rem, 1.1vw, 1rem);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    max-width: 100%;
    line-height: 1.2;
}

.sp-barra__zona-countdown {
    font-size: clamp(0.9rem, 1.3vw, 1.2rem);
    color: var(--white);
    font-weight: 500;
}

/* Contenedor de tarjetas */
.sp-barra__tarjetas {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: stretch;
    height: 100%;
    padding: 0.25rem 0;
    margin-bottom: 1rem;
}

.sp-barra__empty {
    color: var(--text-muted);
    font-size: 1rem;
    align-self: center;
    margin: auto;
}

/* ══════════════════════════════════════════════════════════════
   TARJETAS DE BINTYPE — con icono SVG
   ══════════════════════════════════════════════════════════════ */
.sp-card {
    flex: 1 1 0;
    min-width: 8rem;
    max-width: 14rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background: var(--bg-card-alt);
    border: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    position: relative;
    text-align: left;
}

/* Nombre del bintype (arriba) */
.sp-card__nombre {
    font-size: clamp(0.75rem, 1.2vw, 1.1rem);
    color: var(--white);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    order: 1;
}

/* Porcentaje grande */
.sp-card__valor {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 900;
    line-height: 1;
    color: var(--white);
    order: 2;
}

/* Label "Fullness" */
.sp-card__label {
    font-size: clamp(0.5rem, 0.7vw, 0.65rem);
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    order: 3;
}

/* Icono SVG del bintype (esquina inferior derecha)
   Ajusta width/height aquí para cambiar el tamaño del icono */
.sp-card__icon {
    position: absolute;
    bottom: 0.4rem;
    right: 0.4rem;
    width: clamp(3rem, 5vw, 4.5rem);
    height: clamp(3rem, 5vw, 4.5rem);
    opacity: 1;
    object-fit: contain;
}

/* ── Colores: azul sólido para todas las tarjetas ── */
.sp-card--verde,
.sp-card--amarillo,
.sp-card--rojo {
    background: var(--bg-card-alt);
    border-color: transparent;
}

/* ── Transiciones de rotación ── */
@keyframes sp-fadeIn {
    from { opacity: 0; transform: translateY(0.375rem); }
    to   { opacity: 1; transform: translateY(0); }
}

.sp-barra__tarjetas.sp-fade-out {
    opacity: 0;
    transform: translateY(-0.375rem);
    transition: opacity 200ms ease-in, transform 200ms ease-in;
}

.sp-barra__tarjetas.sp-fade-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 250ms ease-out, transform 250ms ease-out;
}

/* ── Scrollbar sutil ── */
.sp-barra__tarjetas::-webkit-scrollbar { height: 0.25rem; }
.sp-barra__tarjetas::-webkit-scrollbar-track { background: transparent; }
.sp-barra__tarjetas::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* ══════════════════════════════════════════════════════════════
   LAYOUTS POR TIPO DE VISTA
   ══════════════════════════════════════════════════════════════
   Cada tipo de vista tiene su propio layout.
   El contenedor .sp-barra__tarjetas recibe data-tipo="xxx"
   que activa los estilos específicos.

   Para crear un nuevo tipo de vista:
   1. Agrega una sección [data-tipo="tu_tipo"] abajo
   2. Define cómo se ven las tarjetas .sp-card dentro
   3. En el JSON, usa ese tipo en el campo "tipo" de la vista
   ══════════════════════════════════════════════════════════════ */

/* ── bintype_fullness: texto izquierda + icono SVG derecha ── */
/* (ya es el layout base de .sp-card, no necesita override) */

/* ── mejores_pasillos: texto grande centrado, sin icono ── */
[data-tipo="mejores_pasillos"] .sp-card {
    align-items: center;
    text-align: center;
    justify-content: center;
}

[data-tipo="mejores_pasillos"] .sp-card__nombre {
    max-width: 100%;
    font-size: clamp(0.9rem, 1.4vw, 1.3rem);
    text-align: center;
}

[data-tipo="mejores_pasillos"] .sp-card__valor {
    font-size: clamp(1.8rem, 3.5vw, 3rem);
}

[data-tipo="mejores_pasillos"] .sp-card__icon {
    display: none;
}

/* ── resumen_zona: texto genérico centrado ── */
[data-tipo="resumen_zona"] .sp-card {
    align-items: center;
    text-align: center;
}

[data-tipo="resumen_zona"] .sp-card__nombre {
    max-width: 100%;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    color: var(--text-secondary);
    text-align: center;
}

[data-tipo="resumen_zona"] .sp-card__valor {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
}

/* ══════════════════════════════════════════════════════════════
   mejores_pasillos_bintype — Tarjeta tipo lista
   Cada tarjeta = un bintype con header + lista de pasillos
   ══════════════════════════════════════════════════════════════ */
.sp-card-list {
    flex: 1 1 0;
    min-width: 10rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0.5rem;
    background: var(--bg-card-alt);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
}

/* Header: "Library Deep — A" o "Barrel" */
.sp-card-list__header {
    font-size: clamp(0.9rem, 1.3vw, 1.2rem);
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--border-strong);
    padding-bottom: 0.25rem;
}

/* Contenedor de items */
.sp-card-list__items {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* Cada fila: pasillo + fullness% */
.sp-card-list__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.sp-card-list__pasillo {
    font-size: clamp(0.6rem, 0.85vw, 0.8rem);
    color: var(--text-on-card);
    font-weight: 500;
}

.sp-card-list__fullness {
    font-size: clamp(0.6rem, 0.85vw, 0.8rem);
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

/* Scrollbar sutil para listas largas */
.sp-card-list::-webkit-scrollbar { width: 0.1875rem; }
.sp-card-list::-webkit-scrollbar-track { background: transparent; }
.sp-card-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* ── Tabla de pasillos/bays/fullness ── */
.sp-card-list__table-header {
    display: flex;
    gap: 0.5rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border-strong);
    margin-bottom: 0.2rem;
}

.sp-card-list__table-header span {
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sp-card-list__row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    margin-bottom: 0.1rem;
}

/* Colores de fila alternados (par/impar) */
.sp-card-list__row { background: var(--border-primary); }
.sp-card-list__row:nth-child(even) { background: var(--bg-hover); }

/* Columnas de la tabla */
.sp-card-list__col-pasillo {
    flex: 1;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--text-on-card);
    font-weight: 600;
}

.sp-card-list__col-bay {
    flex: 1;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--text-secondary);
    font-weight: 500;
}

.sp-card-list__col-fullness {
    flex: 0 0 auto;
    min-width: 3rem;
    text-align: right;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--white);
    font-weight: 700;
}

/* ── Badge de shelf en header (Library Deep A, B, C, D) ── */
.sp-card-list__shelf-badge {
    display: inline-block;
    font-size: clamp(0.8rem, 1.1vw, 1rem);
    font-weight: 900;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    margin-left: 0.4rem;
    line-height: 1.2;
    vertical-align: middle;
}

/* Shelf A — fondo blanco, letra negra */
.sp-card-list__shelf-badge--A {
    background: #ffffff; /* audit:keep — shelf badge color */
    color: #000000; /* audit:keep — shelf badge color */
}

/* Shelf B — fondo verde, letra blanca */
.sp-card-list__shelf-badge--B {
    background: #22c55e; /* audit:keep — shelf badge color */
    color: #ffffff; /* audit:keep — shelf badge color */
}

/* Shelf C — fondo morado, letra blanca */
.sp-card-list__shelf-badge--C {
    background: #8b5cf6; /* audit:keep — shelf badge color */
    color: #ffffff; /* audit:keep — shelf badge color */
}

/* Shelf D — fondo amarillo, letra negra */
.sp-card-list__shelf-badge--D {
    background: #eab308; /* audit:keep — shelf badge color */
    color: #000000; /* audit:keep — shelf badge color */
}

/* ══════════════════════════════════════════════════════════════
   PIN DE UBICACIÓN — Rebote suave tipo Google Maps
   ══════════════════════════════════════════════════════════════
   El SVG debe contener un elemento con id="Pin".
   La animación usa transform-origin en la base del pin
   para que rebote desde su punto de anclaje (la punta).
   ══════════════════════════════════════════════════════════════ */
.sp-heatmap__inner svg #Pin {
    transform-origin: center bottom;
    animation: pin-bounce 2s ease-in-out infinite;
}

@keyframes pin-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    15% {
        transform: translateY(-0.375rem);
    }
    30% {
        transform: translateY(0);
    }
    45% {
        transform: translateY(-0.1875rem);
    }
    60% {
        transform: translateY(0);
    }
}
