/* =============================================================
   CART-SIDEBAR.CSS  –  Mini Cart Drawer
   ============================================================= */

/* ── Overlay ─────────────────────────────────────────────── */
.cart-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.cart-sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* ── Sidebar panel ───────────────────────────────────────── */
.cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  z-index: 9300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.cart-sidebar.active {
  transform: translateX(0);
}

/* ── Header ──────────────────────────────────────────────── */
.cart-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.cart-sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.cart-sidebar-title i {
  color: var(--accent);
  font-size: 1.05rem;
}
.cs-count-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
  line-height: 1.5;
  display: inline-block;
}
.cart-sidebar-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.cart-sidebar-close:hover {
  background: var(--danger-bg, rgba(239,68,68,.12));
  color: var(--danger, #ef4444);
  border-color: var(--danger, #ef4444);
}

/* ── Body (scrollable) ───────────────────────────────────── */
.cart-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}
.cart-sidebar-body::-webkit-scrollbar { width: 4px; }
.cart-sidebar-body::-webkit-scrollbar-track { background: transparent; }
.cart-sidebar-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* ── Loading state ───────────────────────────────────────── */
.cs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 0;
}
.cs-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cs-spin 0.65s linear infinite;
}
@keyframes cs-spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────── */
.cs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  text-align: center;
}
.cs-empty-icon {
  font-size: 2.8rem;
  color: var(--text-muted);
  opacity: 0.35;
  margin-bottom: 16px;
}
.cs-empty h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 6px;
}
.cs-empty p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 22px;
}
.cs-empty-shop-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}
.cs-empty-shop-link:hover { opacity: 0.86; color: #fff; text-decoration: none; }

/* ── Cart item row ───────────────────────────────────────── */
.cs-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.cs-item:first-child { padding-top: 16px; }
.cs-item:last-child { border-bottom: none; }
.cs-item.cs-removing {
  opacity: 0;
  transform: translateX(30px);
}

/* Image thumbnail */
.cs-item-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}
.cs-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cs-item-img-placeholder {
  color: var(--text-muted);
  font-size: 1.5rem;
  opacity: 0.35;
}

/* Item info */
.cs-item-info {
  flex: 1;
  min-width: 0;
  padding-right: 28px;
}
.cs-item-cat {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 3px;
}
.cs-item-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
  line-height: 1.35;
}
.cs-item-name a {
  color: inherit;
  text-decoration: none;
}
.cs-item-name a:hover { color: var(--accent); }
.cs-item-unit-price {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Qty + line total row */
.cs-item-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cs-qty-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.cs-qty-btn {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  user-select: none;
}
.cs-qty-btn:hover {
  background: var(--accent-muted);
  color: var(--accent);
}
.cs-qty-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.cs-qty-input {
  width: 36px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0;
  height: 28px;
  outline: none;
  -moz-appearance: textfield;
}
.cs-qty-input::-webkit-inner-spin-button,
.cs-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.cs-item-line-total {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Remove button */
.cs-item-remove {
  position: absolute;
  top: 14px;
  right: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 4px 5px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}
.cs-item-remove:hover {
  background: var(--danger-bg, rgba(239,68,68,.12));
  color: var(--danger, #ef4444);
}

/* ── Footer ──────────────────────────────────────────────── */
.cart-sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 16px 20px 20px;
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.cs-summary { margin-bottom: 14px; }
.cs-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.cs-summary-row span:last-child { font-weight: 600; color: var(--text-primary); }
.cs-divider {
  height: 1px;
  background: var(--border-color);
  margin: 10px 0;
}
.cs-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-top: 4px;
}
.cs-actions {
  display: flex;
  gap: 10px;
}
.cs-btn-view-cart {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.cs-btn-view-cart:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--text-muted);
  text-decoration: none;
}
.cs-btn-checkout {
  flex: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.cs-btn-checkout:hover { opacity: 0.87; color: #fff; text-decoration: none; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .cart-sidebar {
    width: 100vw;
    border-left: none;
  }
}
