/**
 * speedyrect-plugins.css
 * SpeedyRectCore v7 · Sismo Digital Pro · Setiembre 2026
 *
 * Estilos para todos los plugins:
 *   - Carrito (drawer lateral)
 *   - Modal de producto
 *   - TV flotante
 *
 * Va en: app/css/speedyrect-plugins.css
 * Agregar en index.html:
 *   <link rel="stylesheet" href="app/css/speedyrect-plugins.css">
 *
 * Colores desde variables — fácil de clonar para otro comercio.
 */

/* ── VARIABLES ───────────────────────────────────────────── */
:root {
  --sr-primario:    #2563eb;
  --sr-acento:      #fbbf24;
  --sr-texto:       #1f2937;
  --sr-texto-muted: #6b7280;
  --sr-fondo:       #f9fafb;
  --sr-blanco:      #ffffff;
  --sr-borde:       #e5e7eb;
  --sr-radio:       12px;
  --sr-sombra:      0 8px 32px rgba(0,0,0,.18);
  --sr-z-drawer:    1000;
  --sr-z-modal:     1100;
  --sr-z-tv:        900;
}

/* ══════════════════════════════════════════════════════════
   CARRITO — DRAWER LATERAL
══════════════════════════════════════════════════════════ */

#sr-carrito-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--sr-z-drawer);
  pointer-events: none;
}

#sr-carrito-drawer.sr-drawer-abierto {
  pointer-events: all;
}

.sr-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity .25s ease;
}

.sr-drawer-abierto .sr-drawer-overlay {
  opacity: 1;
}

.sr-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(380px, 100vw);
  height: 100%;
  background: var(--sr-blanco);
  display: grid;
  grid-template-rows: auto 1fr auto;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--sr-sombra);
}

.sr-drawer-abierto .sr-drawer-panel {
  transform: translateX(0);
}

.sr-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--sr-borde);
  background: var(--sr-primario);
  color: #fff;
}

.sr-drawer-header strong {
  font-size: 1.1rem;
}

.sr-drawer-header button {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.sr-drawer-body {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sr-carrito-vacio {
  text-align: center;
  padding: 48px 20px;
  color: var(--sr-texto-muted);
}

.sr-carrito-vacio span {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}

.sr-carrito-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--sr-borde);
  border-radius: var(--sr-radio);
  background: var(--sr-fondo);
}

.sr-carrito-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--sr-borde);
}

.sr-carrito-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sr-carrito-item-info strong {
  font-size: .9rem;
  color: var(--sr-texto);
  line-height: 1.3;
}

.sr-carrito-precio {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sr-primario);
}

.sr-carrito-controles {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.sr-carrito-controles button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--sr-borde);
  background: var(--sr-blanco);
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  display: grid;
  place-items: center;
}

.sr-carrito-controles button.sr-quitar {
  margin-left: auto;
  background: #fee2e2;
  border-color: #fca5a5;
}

.sr-carrito-controles span {
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.sr-drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sr-borde);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sr-carrito-total {
  font-size: .95rem;
  color: var(--sr-texto);
}

.sr-btn-wa {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--sr-radio);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.sr-btn-vaciar {
  background: transparent;
  color: var(--sr-texto-muted);
  border: 1px solid var(--sr-borde);
  padding: 10px;
  border-radius: var(--sr-radio);
  font-size: .85rem;
  cursor: pointer;
  width: 100%;
}

/* Badge del carrito */
#sr-carrito-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--sr-acento);
  color: #1f2937;
  font-size: .7rem;
  font-weight: 900;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  place-items: center;
  justify-content: center;
}


/* ══════════════════════════════════════════════════════════
   MODAL DE PRODUCTO
══════════════════════════════════════════════════════════ */

#sr-product-modal {
  position: fixed;
  inset: 0;
  z-index: var(--sr-z-modal);
  display: none;
  place-items: center;
}

#sr-product-modal.sr-modal-abierto {
  display: grid;
}

.sr-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.sr-modal-panel {
  position: relative;
  background: var(--sr-blanco);
  border-radius: 18px;
  width: min(520px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sr-sombra);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  animation: srModalEntrar .22s ease;
}

@keyframes srModalEntrar {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.sr-modal-cerrar {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,.08);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
  display: grid;
  place-items: center;
}

.sr-modal-img-wrap {
  background: var(--sr-fondo);
  border-radius: 18px 0 0 18px;
  overflow: hidden;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sr-modal-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sr-modal-info {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sr-modal-titulo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sr-texto);
  margin: 0;
  line-height: 1.3;
}

.sr-modal-precio {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--sr-primario);
  margin: 0;
}

.sr-modal-desc {
  font-size: .88rem;
  color: var(--sr-texto-muted);
  line-height: 1.5;
  margin: 0;
}

.sr-modal-acciones {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.sr-modal-acciones button {
  padding: 12px;
  border-radius: var(--sr-radio);
  border: none;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

#sr-modal-btn-carrito {
  background: var(--sr-primario);
  color: #fff;
}

#sr-modal-btn-wa {
  background: #25d366;
  color: #fff;
}

/* Mobile: modal en columna */
@media (max-width: 540px) {
  .sr-modal-panel {
    grid-template-columns: 1fr;
    border-radius: 18px 18px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 92vh;
    animation: srModalSlide .25s ease;
  }
  @keyframes srModalSlide {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .sr-modal-img-wrap {
    border-radius: 18px 18px 0 0;
    min-height: 180px;
  }
}


/* ══════════════════════════════════════════════════════════
   TV FLOTANTE
══════════════════════════════════════════════════════════ */

#sr-tv-flotante {
  position: fixed;
  bottom: 216px;
  right: 16px;
  width: min(300px, calc((100vh - 300px) * 0.5625), calc(100vw - 32px));
  background: #000;
  border-radius: 14px;
  box-shadow: var(--sr-sombra);
  z-index: var(--sr-z-tv);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

#sr-tv-flotante.sr-tv-visible {
  display: flex;
}

#sr-tv-flotante.sr-tv-minimizado .sr-tv-body {
  display: none;
}

.sr-tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--sr-primario);
  cursor: grab;
}

.sr-tv-titulo {
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
}

.sr-tv-controles {
  display: flex;
  gap: 6px;
}

.sr-tv-controles button {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
  display: grid;
  place-items: center;
}

.sr-tv-body {
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;   /* vertical, igual que produccion */
  background: #000;
  position: relative;
}

.sr-tv-body iframe,
.sr-tv-body #sr-tv-player {
  width: 100%;
  height: 100%;
  border: none;
}

@media (max-width: 400px) {
  #sr-tv-flotante {
    width: calc(100vw - 32px);
    right: 16px;
  }
  .sr-tv-body {
    width: 100%;
  }
}
