/* ==========================================================================
   css/cart.css — Carrito de compras
   Depende de css/style.css
   ========================================================================== */

/* ── Sección principal ───────────────────────────────────────────────────── */
.cart-section { padding: 2rem 0 5rem; }

/* ── Estado vacío ────────────────────────────────────────────────────────── */
.cart-empty {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
}
.cart-empty-icon  { font-size: 3rem; margin-bottom: 1rem; }
.cart-empty-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem; color: var(--text-main); }
.cart-empty-desc  { margin-bottom: 1.75rem; font-size: .95rem; }

/* ── Layout 2 columnas ───────────────────────────────────────────────────── */
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2rem;
  align-items: start;
}

/* ── Columna de ítems ────────────────────────────────────────────────────── */
.cart-col-items {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.cart-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}
.cart-title {
  font-size: 1.1rem; font-weight: 700; color: var(--text-main);
}
.cart-line-label { font-size: .85rem; font-weight: 500; color: var(--text-muted); }

.btn-cart-clear-all {
  font-size: .8rem; font-weight: 600;
  color: var(--text-muted);
  background: none; border: none;
  cursor: pointer; text-decoration: underline;
  transition: color var(--t-fast);
}
.btn-cart-clear-all:hover { color: var(--danger); }

/* Cabecera de columnas */
.cart-col-labels {
  display: grid;
  grid-template-columns: 1fr auto 90px 36px;
  gap: 1rem;
  padding: .55rem 1.5rem;
  font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
}

/* Lista de ítems */
.cart-item-list {
  list-style: none; margin: 0; padding: 0;
}

/* ── Ítem individual ─────────────────────────────────────────────────────── */
.cart-item {
  display: grid;
  grid-template-columns: 68px 1fr auto 90px 36px;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.cart-item:last-child { border-bottom: none; }
.cart-item:hover { background: #fafbfc; }

/* Imagen */
.ci-img-wrap {
  width: 68px; height: 68px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-muted);
}
.ci-img { width: 100%; height: 100%; object-fit: cover; }
.ci-no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
}

/* Info */
.ci-info { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.ci-name {
  font-size: .92rem; font-weight: 700; color: var(--text-main);
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
  transition: color var(--t-fast);
}
.ci-name:hover { color: var(--primary); }
.ci-variant   { font-size: .78rem; color: var(--text-muted); }
.ci-unit-price { font-size: .78rem; color: var(--text-light); }

/* Control de cantidad */
.ci-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-muted);
}

.btn-cart-qty {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: white; color: var(--text-main); border: none;
  cursor: pointer; transition: all var(--t-fast);
}
.btn-cart-qty:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); }
.btn-cart-qty:disabled { opacity: .35; cursor: not-allowed; }

.cart-qty-value {
  width: 34px; text-align: center;
  font-weight: 700; font-size: .9rem;
  color: var(--text-main);
  background: var(--bg-muted);
  line-height: 32px;
}

/* Subtotal */
.ci-subtotal {
  font-size: .95rem; font-weight: 700;
  color: var(--text-main); text-align: right;
  white-space: nowrap;
}

/* Eliminar */
.btn-cart-remove {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-light); background: none; border: none;
  cursor: pointer; transition: all var(--t-fast);
}
.btn-cart-remove:hover { color: var(--danger); background: var(--danger-light); }

/* ── Columna de resumen ───────────────────────────────────────────────────── */
.cart-col-summary { position: sticky; top: 88px; }

.cart-summary-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: .85rem;
}
.summary-title {
  font-size: 1rem; font-weight: 700; color: var(--text-main);
  padding-bottom: .75rem; border-bottom: 1px solid var(--border);
}

.summary-rows { display: flex; flex-direction: column; gap: .55rem; }
.summary-row  {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .88rem; color: var(--text-muted);
}
.shipping-pending { font-style: italic; color: var(--text-light); }

.summary-divider { height: 1px; background: var(--border); }

.summary-total-row {
  display: flex; justify-content: space-between; align-items: center;
}
.summary-total-label { font-size: .9rem; font-weight: 600; color: var(--text-main); }
.summary-total-value { font-size: 1.35rem; font-weight: 800; color: var(--primary); }

.summary-notice {
  font-size: .78rem; color: var(--text-muted);
  line-height: 1.5; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: var(--radius-sm);
  padding: .6rem .75rem;
}

.btn-continue-shopping {
  display: block; text-align: center;
  font-size: .85rem; font-weight: 600;
  color: var(--primary); transition: color var(--t-fast);
}
.btn-continue-shopping:hover { color: var(--primary-hover); }

.btn-checkout-placeholder {
  display: block; width: 100%;
  padding: .75rem; border-radius: var(--radius-md);
  background: var(--bg-muted); color: var(--text-muted);
  font-size: .9rem; font-weight: 600;
  border: 1px dashed var(--border);
  cursor: not-allowed; opacity: .6;
}

/* ── Feedback agregar al carrito (en modal/detalle de producto) ───────────── */
.cart-add-feedback { min-height: 0; }

.cart-feedback {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem; border-radius: var(--radius-md);
  font-size: .87rem; font-weight: 600; margin-top: .5rem;
  animation: feedbackIn .2s ease;
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cart-feedback-success {
  background: var(--success-light); color: #065f46;
  border: 1px solid #6ee7b7;
}
.cart-feedback-success svg { flex-shrink: 0; stroke: #059669; }
.cart-feedback-error {
  background: var(--danger-light); color: #991b1b;
  border: 1px solid #fca5a5;
}
.cart-feedback-link {
  display: block; font-size: .82rem; font-weight: 600;
  color: #059669; margin-top: .1rem;
}
.cart-feedback-link:hover { text-decoration: underline; }

/* ── Badge del header ────────────────────────────────────────────────────── */
.cart-badge {
  background: var(--accent);
  color: white;
  font-size: .7rem; font-weight: 800;
  border-radius: var(--radius-full);
  min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 .3rem;
  line-height: 1;
}
.cart-badge[hidden] { display: none !important; }

/* ── Diálogo de confirmación (eliminar / qty=0) ──────────────────────────── */
.cart-confirm-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  width: min(380px, 92vw);
  box-shadow: var(--shadow-xl);
  text-align: center;
}
.cart-confirm-dialog::backdrop {
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
}
@keyframes confirmIn {
  from { opacity: 0; transform: scale(.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.cart-confirm-dialog[open] { animation: confirmIn .2s ease forwards; }

.confirm-icon    { font-size: 2rem; margin-bottom: .75rem; }
.confirm-message {
  font-size: .95rem; font-weight: 600;
  color: var(--text-main); margin-bottom: 1.25rem; line-height: 1.4;
}
.confirm-actions { display: flex; gap: .75rem; justify-content: center; }

.btn-confirm-yes {
  padding: .6rem 1.4rem; border-radius: var(--radius-md);
  background: var(--danger); color: white;
  font-weight: 700; font-size: .88rem;
  border: none; cursor: pointer;
  transition: background var(--t-fast);
}
.btn-confirm-yes:hover { background: #dc2626; }

.btn-confirm-no {
  padding: .6rem 1.4rem; border-radius: var(--radius-md);
  background: var(--bg-muted); color: var(--text-main);
  font-weight: 600; font-size: .88rem;
  border: 1px solid var(--border); cursor: pointer;
  transition: all var(--t-fast);
}
.btn-confirm-no:hover { background: var(--border); }

/* ── HTMX loading en carrito ─────────────────────────────────────────────── */
#cart-content.htmx-request { opacity: .5; pointer-events: none; transition: opacity .2s; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .cart-layout          { grid-template-columns: 1fr; }
  .cart-col-labels      { display: none; }
  .cart-col-summary     { position: static; }
  .cart-item {
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto auto;
    gap: .5rem 1rem;
    padding: 1rem;
  }
  .ci-img-wrap { grid-row: 1 / 3; width: 56px; height: 56px; }
  .ci-qty      { grid-column: 2; }
  .ci-subtotal { grid-column: 2; text-align: left; font-size: .88rem; }
  .btn-cart-remove { grid-column: 1 / -1; justify-self: end; margin-top: -.5rem; }
}
@media (max-width: 480px) {
  .cart-section { padding: 1rem 0 4rem; }
  .cart-col-header { padding: .85rem 1rem; }
  .cart-item { padding: .85rem 1rem; }
}
