/* ================================================================
   TECNOTECH — cart.css
   Estilos del carrito global (sidebar + botón navbar + badge)
   Compatible con el sistema de variables CSS del proyecto.
================================================================ */

/* ── Botón de carrito en navbar ── */
.tt-cart-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm, 8px);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: .95rem;
  transition: border-color .2s, color .2s, background .2s;
  flex-shrink: 0;
}
.tt-cart-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--badge-bg, rgba(196,26,26,.07));
}

/* Badge con la cantidad total */
.tt-cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--accent-primary, #c41a1a);
  color: #fff;
  border-radius: 100px;
  font-size: .62rem;
  font-weight: 800;
  display: none;                 /* oculto cuando qty = 0 */
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-navbar, #fff);
  line-height: 1;
  pointer-events: none;
}
.tt-cart-badge.visible { display: flex; }

/* ── Overlay oscuro detrás del sidebar ── */
.tt-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1600;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility .3s;
}
.tt-cart-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Sidebar del carrito ── */
.tt-cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100dvh;               /* dvh para móviles con barra inferior */
  z-index: 1700;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #fff);
  border-left: 1px solid var(--border-color);
  box-shadow: -8px 0 48px rgba(0, 0, 0, .18);
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
.tt-cart-sidebar.open { transform: translateX(0); }

/* ── Header del sidebar ── */
.tt-cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 1rem;
}
.tt-cart-head-left {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.tt-cart-head-icon {
  width: 36px;
  height: 36px;
  background: var(--badge-bg, rgba(196,26,26,.08));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary, #c41a1a);
  font-size: .95rem;
  flex-shrink: 0;
}
.tt-cart-head-title {
  font-family: var(--font-heading, 'Inter', sans-serif);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}
.tt-cart-head-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin: 0;
  margin-top: 1px;
}
.tt-cart-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-primary, #f9f9f9);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: all .2s;
  flex-shrink: 0;
}
.tt-cart-close:hover {
  background: var(--accent-gradient, linear-gradient(135deg,#c41a1a,#e63535));
  color: #fff;
  border-color: transparent;
}

/* ── Zona scrollable de items ── */
.tt-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: .85rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.tt-cart-body::-webkit-scrollbar { width: 4px; }
.tt-cart-body::-webkit-scrollbar-track { background: transparent; }
.tt-cart-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

/* ── Estado vacío ── */
.tt-cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  gap: .75rem;
  color: var(--text-muted);
}
.tt-cart-empty-icon { font-size: 3.2rem; opacity: .3; line-height: 1; }
.tt-cart-empty-title {
  font-family: var(--font-heading, sans-serif);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.tt-cart-empty-sub { font-size: .8rem; margin: 0; }

/* ── Tarjeta de producto en carrito ── */
.tt-cart-item {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: .65rem;
  align-items: start;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: .8rem;
  transition: border-color .2s, box-shadow .2s;
  animation: ttItemIn .25s cubic-bezier(.4, 0, .2, 1) both;
}
@keyframes ttItemIn {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}
.tt-cart-item:hover {
  border-color: rgba(196, 26, 26, .22);
  box-shadow: 0 2px 12px rgba(196, 26, 26, .07);
}

/* Thumbnail */
.tt-cart-thumb {
  width: 50px;
  height: 50px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  flex-shrink: 0;
  overflow: hidden;
}
.tt-cart-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

/* Info del producto */
.tt-cart-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tt-cart-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  /* cortar texto largo */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tt-cart-sku {
  font-size: .67rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-bottom: 3px;
}

/* Fila de cantidad */
.tt-cart-qty-row {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-top: .35rem;
  flex-wrap: wrap;
}
.tt-qty-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 700;
  transition: all .17s;
  padding: 0;
  line-height: 1;
}
.tt-qty-btn:hover {
  background: var(--accent-gradient, linear-gradient(135deg,#c41a1a,#e63535));
  color: #fff;
  border-color: transparent;
}
.tt-qty-val {
  min-width: 22px;
  text-align: center;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-primary);
}
.tt-cart-price-unit {
  font-size: .68rem;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Subtotal del item */
.tt-cart-subtotal {
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent-primary, #c41a1a);
  margin-top: 3px;
}

/* Botón eliminar */
.tt-cart-del {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  transition: all .17s;
  padding: 0;
  flex-shrink: 0;
  align-self: start;
}
.tt-cart-del:hover {
  background: rgba(255, 77, 109, .1);
  color: #ff4d6d;
  border-color: rgba(255, 77, 109, .3);
}

/* ── Footer: totales + botones ── */
.tt-cart-foot {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.4rem 1.35rem;
  flex-shrink: 0;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.tt-cart-totals { display: flex; flex-direction: column; gap: .35rem; }
.tt-cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  color: var(--text-secondary);
}
.tt-cart-row.total {
  font-family: var(--font-heading, sans-serif);
  font-size: .98rem;
  font-weight: 800;
  color: var(--text-primary);
  padding-top: .4rem;
  border-top: 1px solid var(--border-color);
  margin-top: .1rem;
}
.tt-cart-row.total span:last-child { color: var(--accent-primary, #c41a1a); }

/* Botones de envío */
.tt-cart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.tt-btn-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: .65rem .75rem;
  background: rgba(37, 211, 102, .08);
  border: 1.5px solid rgba(37, 211, 102, .28);
  border-radius: 8px;
  color: #15803d;
  font-family: var(--font-body, sans-serif);
  font-size: .79rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  white-space: nowrap;
}
[data-theme="dark"] .tt-btn-wa { color: #25d366; }
.tt-btn-wa:hover {
  background: #25d366;
  color: #fff;
  border-color: #25d366;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 211, 102, .28);
}
.tt-btn-mail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: .65rem .75rem;
  background: var(--badge-bg, rgba(196,26,26,.07));
  border: 1.5px solid rgba(196, 26, 26, .22);
  border-radius: 8px;
  color: var(--accent-primary, #c41a1a);
  font-family: var(--font-body, sans-serif);
  font-size: .79rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  white-space: nowrap;
}
.tt-btn-mail:hover {
  background: var(--accent-gradient, linear-gradient(135deg,#c41a1a,#e63535));
  color: #fff;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(196, 26, 26, .28);
}
.tt-btn-clear {
  width: 100%;
  padding: .48rem;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: 7px;
  font-family: var(--font-body, sans-serif);
  font-size: .74rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
}
.tt-btn-clear:hover { border-color: #ff4d6d; color: #ff4d6d; }

/* ── Selector cantidad en detalle del artículo ── */
.tt-qty-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.tt-qty-wrap .tt-qty-btn {
  width: 38px;
  height: 44px;
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
}
.tt-qty-wrap .tt-qty-btn:last-child {
  border-right: none;
  border-left: 1px solid var(--border-color);
}
.tt-qty-wrap .tt-qty-btn:hover {
  background: var(--badge-bg);
  color: var(--accent-primary);
  border-color: var(--border-color);
  box-shadow: none;
}
.tt-qty-wrap .tt-qty-display {
  min-width: 40px;
  text-align: center;
  font-family: var(--font-heading, sans-serif);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 44px;
}

/* Botón "Agregar al carrito" en articulos.html */
.tt-btn-add-cart {
  flex: 1;
  min-width: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: .75rem 1.4rem;
  background: var(--accent-gradient, linear-gradient(135deg,#c41a1a,#e63535));
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-body, sans-serif);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .3px;
  transition: all .25s;
  box-shadow: 0 4px 18px rgba(196, 26, 26, .32);
}
.tt-btn-add-cart:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(196, 26, 26, .48);
  filter: brightness(1.07);
}
.tt-btn-add-cart:active { transform: translateY(0); }
.tt-btn-add-cart.added {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 18px rgba(16, 185, 129, .32);
}
.tt-btn-add-cart:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Fila add-cart en articulos.html */
.tt-add-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}

/* ── Toast de confirmación ── */
.tt-toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-primary, #c41a1a);
  border-radius: 10px;
  padding: .7rem 1.15rem;
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .14);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 92vw;
}
.tt-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .tt-cart-sidebar { width: 100vw; }
  .tt-cart-actions { grid-template-columns: 1fr; }
  .tt-add-row { flex-direction: column; align-items: stretch; }
  .tt-btn-add-cart { min-width: unset; }
}