@import url("https://fonts.googleapis.com/icon?family=Material+Icons");

/**
 * Café de la Suegra — Side Cart — Styles
 * Uses CSS custom properties set by PHP (configurable from back office).
 */

/* ----------------------------------------------------------------
   Defaults (overridden by :root vars injected via PHP)
---------------------------------------------------------------- */
:root {
  --csc-bg:           #ffffff;
  --csc-text:         #2c2416;
  --csc-btn:          #5a6e3a;
  --csc-btn-primary:  #c0603a;
  --csc-width:        420px;
  --csc-width-mobile: 92%;
  --csc-radius:       0;
  --csc-shadow:       -4px 0 32px rgba(0,0,0,0.14);
  --csc-transition:   0.32s cubic-bezier(0.4, 0, 0.2, 1);
  --csc-border:       #ede5d8;
  --csc-muted:        #7a6a58;
  --csc-danger:       #c0603a;
  --csc-discount:     #5a6e3a;
}

/* ----------------------------------------------------------------
   No-scroll on body when open
---------------------------------------------------------------- */
body.csc-no-scroll {
  overflow: hidden;
  /* Compensate for the scrollbar width that disappears to avoid horizontal layout jump */
  padding-right: var(--csc-scrollbar-width, 0px);
}

/* ----------------------------------------------------------------
   Overlay
---------------------------------------------------------------- */
.csc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 9998;
  pointer-events: none;
  transition: background var(--csc-transition);
}

.csc-overlay--visible {
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

/* ----------------------------------------------------------------
   Panel shell
---------------------------------------------------------------- */
.csc-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--csc-width);
  max-width: 100vw;
  background: var(--csc-bg);
  color: var(--csc-text);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--csc-transition);
  box-shadow: var(--csc-shadow);
  border-left: 1px solid var(--csc-border);
  border-radius: var(--csc-radius) 0 0 var(--csc-radius);
  overflow: hidden;
  will-change: transform;
}

.csc-panel--open {
  transform: translateX(0);
}

/* Loading shimmer */
.csc-panel--loading .csc-panel__inner {
  opacity: 0.5;
  pointer-events: none;
}

/* Initial loading spinner (shown before first AJAX fetch) */
.csc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
}
.csc-loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0,0,0,.1);
  border-top-color: var(--csc-btn-primary, #c0603a);
  border-radius: 50%;
  animation: csc-spin .7s linear infinite;
}
@keyframes csc-spin {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------
   Panel header
---------------------------------------------------------------- */
.csc-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 2px solid var(--csc-border);
  flex-shrink: 0;
  background: var(--csc-bg);
}

.csc-panel__title {
  font-family: 'Georgia', serif;
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--csc-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.csc-panel__title-icon {
  font-size: 1.25rem !important;
  color: var(--csc-btn-primary);
}

.csc-panel__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--csc-btn-primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: sans-serif;
  margin-left: 0.25rem;
}

.csc-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  color: var(--csc-text);
  transition: background 0.2s, color 0.2s;
  padding: 0;
}

.csc-panel__close:hover {
  background: var(--csc-border);
  color: var(--csc-btn-primary);
}

.csc-panel__close .material-icons {
  font-size: 1.3rem !important;
}

/* ----------------------------------------------------------------
   Panel inner (scrollable area)
---------------------------------------------------------------- */
.csc-panel__inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.csc-panel__inner::-webkit-scrollbar      { width: 5px; }
.csc-panel__inner::-webkit-scrollbar-track { background: transparent; }
.csc-panel__inner::-webkit-scrollbar-thumb { background: var(--csc-border); border-radius: 3px; }

/* ----------------------------------------------------------------
   Empty state
---------------------------------------------------------------- */
.csc-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1.5rem;
  text-align: center;
}

.csc-empty__icon {
  font-size: 3.5rem !important;
  color: var(--csc-border);
}

.csc-empty__text {
  font-size: 1rem;
  color: var(--csc-muted);
  margin: 0;
}

/* ----------------------------------------------------------------
   Product list
---------------------------------------------------------------- */
.csc-products {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
  flex: 1;
}

.csc-product {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--csc-border);
  position: relative;
  transition: background 0.15s;
}

.csc-product:last-child {
  border-bottom: none;
}

.csc-product:hover {
  background: rgba(0,0,0,0.02);
}

/* Thumbnail */
.csc-product__img {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--csc-border);
}

.csc-product__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Info */
.csc-product__info {
  flex: 1;
  min-width: 0;
}

.csc-product__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--csc-text);
  margin: 0 0 0.2rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csc-product__attrs {
  font-size: 0.78rem;
  color: var(--csc-muted);
  margin: 0 0 0.2rem;
}

.csc-product__unit-price {
  font-size: 0.8rem;
  color: var(--csc-muted);
  margin: 0 0 0.45rem;
}

.csc-product__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.csc-product__line-total {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--csc-btn-primary);
  white-space: nowrap;
}

/* Qty controls */
.csc-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--csc-border);
  border-radius: 4px;
  overflow: hidden;
}

.csc-qty__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--csc-text);
  transition: background 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.csc-qty__btn:hover {
  background: var(--csc-border);
}

.csc-qty__btn .material-icons {
  font-size: 1rem !important;
}

.csc-qty__val {
  min-width: 28px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0 4px;
  border-left: 1px solid var(--csc-border);
  border-right: 1px solid var(--csc-border);
}

/* Remove button */
.csc-product__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--csc-muted);
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  flex-shrink: 0;
  align-self: center;
}

.csc-product__remove:hover {
  background: #fef0ee;
  color: var(--csc-danger);
}

.csc-product__remove .material-icons {
  font-size: 1.1rem !important;
}

/* ----------------------------------------------------------------
   Summary
---------------------------------------------------------------- */
.csc-summary {
  padding: 1rem 1.25rem 0.5rem;
  border-top: 2px solid var(--csc-border);
  flex-shrink: 0;
  background: var(--csc-bg);
}

.csc-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  color: var(--csc-muted);
}

.csc-summary__row--total {
  border-top: 1px solid var(--csc-border);
  margin-top: 0.4rem;
  padding-top: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--csc-text);
}

.csc-summary__value {
  font-weight: 600;
  color: var(--csc-text);
}

.csc-summary__total {
  font-size: 1.1rem;
  color: var(--csc-btn-primary);
}

.csc-summary__row--discount {
  color: var(--csc-discount);
  font-size: 0.82rem;
}

.csc-summary__discount-amount {
  font-weight: 600;
  color: var(--csc-discount);
}

.csc-summary__tax-note {
  font-size: 0.75rem;
  color: var(--csc-muted);
  margin: 0.4rem 0 0;
  text-align: right;
}

/* ----------------------------------------------------------------
   Action buttons
---------------------------------------------------------------- */
.csc-actions {
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-shrink: 0;
  background: var(--csc-bg);
  border-top: 1px solid var(--csc-border);
}

.csc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.72rem 1.2rem;
  border-radius: 3px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  text-align: center;
  line-height: 1.2;
}

.csc-btn .material-icons {
  font-size: 1rem !important;
}

.csc-btn--primary {
  background: var(--csc-btn-primary);
  border-color: var(--csc-btn-primary);
  color: #fff !important;
}

.csc-btn--primary:hover {
  background: #d4795a;
  border-color: #d4795a;
  color: #fff !important;
}

.csc-btn--secondary {
  background: transparent;
  border-color: var(--csc-btn);
  color: var(--csc-btn) !important;
}

.csc-btn--secondary:hover {
  background: var(--csc-btn);
  color: #fff !important;
}

.csc-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--csc-muted) !important;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.csc-btn--ghost:hover {
  color: var(--csc-text) !important;
  text-decoration: underline;
}

/* ----------------------------------------------------------------
   Responsive — mobile
---------------------------------------------------------------- */
@media (max-width: 575px) {
  .csc-panel {
    width: var(--csc-width-mobile) !important;
    max-width: 100vw;
  }

  .csc-product {
    padding: 0.75rem 1rem;
  }

  .csc-panel__header {
    padding: 0.9rem 1rem;
  }

  .csc-actions {
    padding: 0.75rem 1rem 1.25rem;
  }

  .csc-summary {
    padding: 0.75rem 1rem 0.5rem;
  }
}
