/* ============================================
   FABRIEMPANADAS - Carrito
   ============================================ */

/* --------------------------------------------
   OVERLAY
   -------------------------------------------- */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  backdrop-filter: blur(3px);
}

.cart-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------
   PANEL CARRITO
   -------------------------------------------- */
.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  background: #ffffff;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-base);
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
}

.cart-panel.active {
  transform: translateX(0);
}

/* Header del carrito */
.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 2px solid var(--gray-border);
  background: var(--light);
  flex-shrink: 0;
}

.cart-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.cart-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--gray-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
  color: var(--dark);
}

.cart-close:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Items del carrito */
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 120px;
  max-height: 28vh;
}

@media (min-width: 768px) {
  .cart-items {
    max-height: 30vh;
  }
}

.cart-items::-webkit-scrollbar {
  width: 4px;
}

.cart-items::-webkit-scrollbar-track {
  background: var(--light);
}

.cart-items::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 2px;
}

/* Estado vacío */
.cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  text-align: center;
}

.cart-empty-icon {
  font-size: 4rem;
  opacity: 0.4;
}

.cart-empty h4 {
  color: var(--gray);
  font-weight: 600;
}

.cart-empty p {
  font-size: var(--font-size-sm);
  color: var(--gray);
}

/* Item individual */
.cart-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--light);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-border);
  transition: all var(--transition-fast);
  animation: fadeIn 0.3s ease forwards;
}

.cart-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.cart-item-img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #FFE0B2, var(--light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.cart-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--dark);
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price {
  font-size: var(--font-size-sm);
  color: var(--primary);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.cart-qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--gray-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  transition: all var(--transition-fast);
  user-select: none;
}

.cart-qty-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.cart-qty-num {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--dark);
  min-width: 24px;
  text-align: center;
}

.cart-item-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(229,57,53,0.1);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--error);
  transition: all var(--transition-fast);
}

.cart-item-remove:hover {
  background: var(--error);
  color: #ffffff;
}

.cart-item-subtotal {
  font-size: var(--font-size-xs);
  color: var(--gray);
  margin-top: var(--space-xs);
}

/* Footer del carrito */
.cart-footer {
  padding: var(--space-md);
  border-top: 2px solid var(--gray-border);
  background: #ffffff;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 45vh;
}

@media (min-width: 768px) {
  .cart-footer {
    max-height: 48vh;
    padding: var(--space-lg);
  }
}

.cart-summary {
  margin-bottom: var(--space-lg);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  font-size: var(--font-size-sm);
  color: var(--gray);
  border-bottom: 1px dashed var(--gray-border);
}

.cart-summary-row:last-child {
  border-bottom: none;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--dark);
  padding-top: var(--space-md);
}

.cart-summary-row:last-child span:last-child {
  color: var(--primary);
}

.cart-footer-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.cart-clear {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--gray);
  cursor: pointer;
  padding: var(--space-sm);
  transition: color var(--transition-fast);
  text-decoration: underline;
}

.cart-clear:hover {
  color: var(--error);
}

/* Formulario datos cliente */
.cart-form {
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: var(--light);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-border);
}

.cart-form h4 {
  font-size: var(--font-size-sm);
  color: var(--dark);
  margin-bottom: var(--space-md);
  font-weight: 700;
}

.cart-form .form-control {
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-sm);
  padding: 0.6rem 0.8rem;
}

/* Notificación toast */
.cart-toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--dark);
  color: #ffffff;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
  z-index: 9999;
  transition: transform var(--transition-base);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

.cart-toast.show {
  transform: translateX(-50%) translateY(0);
}

.cart-toast.success {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
}