/* === CART MODAL STYLING === */
#cart-modal.hidden { display: none; }

.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 9998;
}

.cart-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  color: #111;
  width: 92%;
  max-width: 460px;
  padding: 24px;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  z-index: 9999;
  animation: popupFade 0.25s ease-out;
  font-family: system-ui, -apple-system, sans-serif;
}

@keyframes popupFade {
  from { opacity: 0; transform: translate(-50%, -47%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.cart-box h2 {
  margin: 0 0 15px;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
}

.close {
  background: none;
  border: none;
  font-size: 30px;
  position: absolute;
  top: 10px;
  right: 18px;
  color: #888;
  cursor: pointer;
  transition: 0.2s;
}
.close:hover { color: #000; }

/* === CART ITEMS === */
#cart-items { max-height: 300px; overflow-y: auto; padding-right: 5px; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}
.cart-item img {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  object-fit: contain;
  background: #f7f8ff;
}
.cart-info {
  flex: 1;
}
.cart-info h3 {
  margin: 0 0 4px;
  font-size: 16px;
}
.cart-info p {
  margin: 0;
  color: #555;
  font-size: 14px;
}
.quantity-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.cart-btn {
  background: #eee;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}
.cart-btn:hover { background: #ddd; }

.subtotal {
  font-weight: bold;
  margin-top: 6px;
  color: #333;
}

.cart-total {
  text-align: right;
  font-weight: bold;
  margin-top: 14px;
  border-top: 1px solid #ccc;
  padding-top: 10px;
}

.cart-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}

.cart-buttons .btn {
  display: inline-block;
  background: #111;
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.2s;
}

.cart-buttons .btn:hover {
  background: #333;
}

.cart-buttons .primary {
  background: #0077ff;
}
.cart-buttons .primary:hover {
  background: #0062cc;
}

.empty-cart {
  text-align: center;
  padding: 60px 20px;
}

.empty-cart-icon {
  width: 42px;
  height: 42px;
  padding: 8px;
  border-radius: 50%;
  background: #042698;
  object-fit: contain;
}

.empty-cart .btn {
  display: inline-block;
  margin-top: 15px;
  background: #222;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
}

#cart-badge {
  position: fixed;
  top: 10px;
  right: 28px;
  background: #042698;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s ease;
  text-decoration: none;
}

.cart-badge-icon {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

#cart-badge:hover {
  background: #011b66;
}

#cart-count {
  background: #ff4444;
  color: #fff;
  border-radius: 50%;
  padding: 2px 7px;
  font-size: 13px;
  font-weight: bold;
}

.hidden {
  display: none;
}

@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
  .cart-overlay {
    display: none;
  }

  .cart-box {
    top: 56px;
    right: 28px;
    left: auto;
    width: min(380px, calc(100vw - 56px));
    max-width: 380px;
    padding: 16px;
    transform: none;
    border: 2px solid #042698;
    border-radius: 16px;
    box-shadow: 0 14px 32px rgba(4,38,152,.18);
    animation: cartPopoverFade .16s ease-out;
  }

  .cart-box::before {
    content: "";
    position: absolute;
    top: -9px;
    right: 34px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-left: 2px solid #042698;
    border-top: 2px solid #042698;
    transform: rotate(45deg);
  }

  .cart-box .close {
    display: none;
  }

  .cart-buttons .close-cart,
  .empty-cart .close-cart {
    display: none;
  }

  .cart-buttons {
    justify-content: flex-end;
  }

  .cart-box h3 {
    margin: 0 0 8px;
    color: #042698;
    font-size: 1rem;
  }

  #cart-items {
    max-height: 330px;
  }

  @keyframes cartPopoverFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 600px) {
  .cart-box {
    width: min(92%, 420px);
    padding: 18px;
    border-radius: 14px;
  }

  .cart-buttons {
    justify-content: flex-end;
    gap: 10px;
  }

  .cart-buttons .btn {
    width: auto;
    flex: 0 0 auto;
    padding: 9px 14px;
    font-size: 13px;
    border-radius: 8px;
    text-align: center;
  }

  #cart-badge {
    right: 12px;
    top: 16px;
  }
}
