/**
 * quickbuy-toast.css — QuickBuy Toast para WooCommerce
 * @version 1.2.0
 */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --qb-success:    #2ecc71;
  --qb-error:      #e74c3c;
  --qb-bg:         #ffffff;
  --qb-text:       #111827;
  --qb-subtext:    #6b7280;
  --qb-action:     #2563eb;
  --qb-action-bg:  #eff6ff;
  --qb-shadow:     0 10px 40px rgba(0, 0, 0, 0.13), 0 2px 8px rgba(0,0,0,.07);
  --qb-radius:     14px;
  --qb-strip-w:    4px;
  --qb-font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --qb-dur:        0.38s;
  --qb-ease:       cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Contenedor global ──────────────────────────────────────────────────── */
#qbt-container {
  position: fixed;
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 370px;
  width: calc(100vw - 32px);
}

/* Posiciones */
#qbt-container.qbt-pos-bottom-right { bottom: 24px; right: 24px; }
#qbt-container.qbt-pos-bottom-left  { bottom: 24px; left: 24px; }
#qbt-container.qbt-pos-top-right    { top: 80px; right: 24px; }
#qbt-container.qbt-pos-top-left     { top: 80px; left: 24px; }

/* ── Toast base ─────────────────────────────────────────────────────────── */
.qbt-toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--qb-bg);
  border-radius: var(--qb-radius);
  box-shadow: var(--qb-shadow);
  padding: 13px 14px 13px calc(var(--qb-strip-w) + 14px);
  font-family: var(--qb-font);
  font-size: 14px;
  pointer-events: all;
  overflow: hidden;

  /* Estado inicial (oculto, fuera de pantalla) */
  opacity: 0;
  transform: translateX(calc(100% + 40px));
  transition:
    opacity   var(--qb-dur) var(--qb-ease),
    transform var(--qb-dur) var(--qb-ease);
  will-change: transform, opacity;
}

/* Toasts que entran por la izquierda */
#qbt-container.qbt-pos-bottom-left .qbt-toast,
#qbt-container.qbt-pos-top-left    .qbt-toast {
  transform: translateX(calc(-100% - 40px));
}

/* ── Barra de color lateral ─────────────────────────────────────────────── */
.qbt-toast__strip {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--qb-strip-w);
  border-radius: var(--qb-radius) 0 0 var(--qb-radius);
}
.qbt-toast--success .qbt-toast__strip { background: var(--qb-success); }
.qbt-toast--error   .qbt-toast__strip { background: var(--qb-error); }

/* ── Estados ────────────────────────────────────────────────────────────── */
.qbt-toast--in {
  opacity: 1;
  transform: translateX(0) !important;
}
.qbt-toast--out {
  opacity: 0;
  transform: translateX(calc(100% + 40px));
  transition:
    opacity   0.32s ease-in,
    transform 0.32s ease-in;
}
#qbt-container.qbt-pos-bottom-left .qbt-toast--out,
#qbt-container.qbt-pos-top-left    .qbt-toast--out {
  transform: translateX(calc(-100% - 40px));
}

/* ── Miniatura ──────────────────────────────────────────────────────────── */
.qbt-toast__thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 9px;
  overflow: hidden;
  background: #f3f4f6;
}
.qbt-toast__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Icono de error ─────────────────────────────────────────────────────── */
.qbt-toast__icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fde8e8;
  color: var(--qb-error);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ── Cuerpo ─────────────────────────────────────────────────────────────── */
.qbt-toast__body {
  flex: 1;
  min-width: 0;
}
.qbt-toast__title {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--qb-success);
  line-height: 1.2;
}
.qbt-toast__product {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--qb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qbt-toast__message {
  margin: 0;
  flex: 1;
  font-size: 13.5px;
  color: var(--qb-text);
  line-height: 1.4;
}

/* ── Botones de acción ──────────────────────────────────────────────────── */
.qbt-toast__actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.qbt-toast__action {
  display: inline-block;
  padding: 5px 11px;
  background: var(--qb-action-bg);
  color: var(--qb-action) !important;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  text-decoration: none !important;
  white-space: nowrap;
  line-height: 1.4;
  transition: background 0.18s, transform 0.15s;
  text-align: center;
}
.qbt-toast__action:hover { background: #dbeafe; transform: translateY(-1px); }
.qbt-toast__action--alt  { background: #f0fdf4; color: #15803d !important; }
.qbt-toast__action--alt:hover { background: #dcfce7; }

/* ── Botón cerrar ───────────────────────────────────────────────────────── */
.qbt-toast__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  line-height: 1;
  transition: background 0.18s, color 0.18s;
}
.qbt-toast__close:hover { background: #f3f4f6; color: var(--qb-text); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #qbt-container {
    bottom: 12px !important;
    top: auto !important;
    left: 10px !important;
    right: 10px !important;
    width: auto;
    max-width: 100%;
  }
  .qbt-toast__actions { display: none; }
  .qbt-toast { padding-right: 10px; }
}

/* ── Modo oscuro ────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --qb-bg:        #1f2937;
    --qb-text:      #f9fafb;
    --qb-action-bg: #1e3a5f;
    --qb-shadow:    0 10px 40px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
  }
  .qbt-toast__thumb    { background: #374151; }
  .qbt-toast__icon     { background: #4b1c1c; }
  .qbt-toast__close:hover { background: #374151; }
  .qbt-toast__action--alt { background: #14532d; color: #86efac !important; }
  .qbt-toast__action--alt:hover { background: #166534; }
}

/* ── Reducción de movimiento ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .qbt-toast { transition: opacity var(--qb-dur) ease; transform: none !important; }
  .qbt-toast--out { transform: none !important; }
}
