/**
 * Mini Cart Component
 * Luxury header dropdown — self-contained, no full-page cart styles bleed in.
 *
 * @package Sestito Template
 */

/* ===== WRAPPER ===== */
.sestito-mini-cart {
  position: static;
  isolation: isolate;
}

/* ===== CART BUTTON ===== */
.sestito-cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--hdr-text-dark, var(--ssc-color-text));
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.sestito-cart-btn:hover {
  background: var(--hdr-green-soft, color-mix(in srgb, var(--ssc-color-primary) 12%, transparent));
  color: var(--hdr-green-deep, var(--ssc-color-primary));
}

/* ===== BADGE ===== */
.sestito-cart-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  background: var(--ssc-color-accent);
  color: var(--ssc-color-background);
  font-family: var(--font-nav, 'Jost', sans-serif);
  font-size: 9px;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

.sestito-cart-count:empty,
.sestito-cart-count[data-count="0"] {
  display: none;
}

/* ===== DROPDOWN PANEL ===== */
.sestito-mini-cart-dropdown {
  position: fixed;
  /* top: set dynamically by header.js (headerWrap.getBoundingClientRect().bottom + 4px) */
  top: 80px; /* safe CSS fallback — JS overrides this immediately on open/hover */
  right: max(16px, calc(50% - 630px));
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100svh - 90px);  /* JS sets exact top; this just prevents overflow */
  background: #ffffff;
  border: 1px solid rgba(29, 61, 47, 0.1);
  border-top: 2px solid #c9a84c;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.13), 0 4px 16px rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
  z-index: 99999;
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  color: #1c1c1c;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
}

.sestito-mini-cart-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
}

/* Hover trigger for desktop (JS overrides for mobile) */
@media (hover: hover) and (pointer: fine) {
  .sestito-mini-cart:hover .sestito-mini-cart-dropdown,
  .sestito-mini-cart:focus-within .sestito-mini-cart-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
  }
}

/* ===== PANEL HEADER ===== */
.sestito-mc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px 20px;
  border-bottom: 1px solid rgba(29, 61, 47, 0.07);
  flex-shrink: 0;
  gap: 8px;
}

.sestito-mc-header__left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sestito-mc-header__title {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #1d3d2f;
  margin: 0;
}

.sestito-mc-header__count {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 400;
  color: #8a7a5a;
  letter-spacing: 0.05em;
}

/* ===== CLOSE BUTTON ===== */
.sestito-mc-close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  margin-left: auto;
  background: none;
  border: none;
  border-radius: 50%;
  color: #8a7a5a;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sestito-mc-close:hover,
.sestito-mc-close:focus-visible {
  background: rgba(29, 61, 47, 0.07);
  color: #1d3d2f;
  outline: none;
}

.sestito-mc-close svg {
  display: block;
  pointer-events: none;
}

/* ===== CONTENT WRAPPER (fragment target) ===== */
.sestito-mini-cart-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* ===== ITEM LIST ===== */
.sestito-mc-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 76, 0.3) transparent;
}

.sestito-mc-list::-webkit-scrollbar {
  width: 3px;
}

.sestito-mc-list::-webkit-scrollbar-track {
  background: transparent;
}

.sestito-mc-list::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, 0.4);
  border-radius: 2px;
}

/* ===== SINGLE ITEM ===== */
.sestito-mc-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(29, 61, 47, 0.05);
  position: relative;
  transition: background 0.15s ease;
}

.sestito-mc-item:last-child {
  border-bottom: none;
}

.sestito-mc-item:hover {
  background: #faf9f7;
}

/* Thumbnail */
.sestito-mc-item__img {
  flex-shrink: 0;
  width: 64px;
  height: 80px;
}

.sestito-mc-item__img img {
  width: 64px;
  height: 80px;
  object-fit: cover;
  display: block;
}

.sestito-mc-item__img a {
  display: block;
  line-height: 0;
  overflow: hidden;
}

/* Body */
.sestito-mc-item__body {
  flex: 1;
  min-width: 0;
  padding-right: 22px;
  padding-top: 2px;
}

.sestito-mc-item__name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15px;
  font-weight: 500;
  color: #1d3d2f;
  line-height: 1.3;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.sestito-mc-item__name a {
  color: inherit;
  text-decoration: none;
}

.sestito-mc-item__name a:hover {
  color: #c9a84c;
}

/* Compact fabric/meta line for custom shirts */
.sestito-mc-item__meta {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: #8a7a5a;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sestito-mc-item__qty-price {
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  color: #6a6a6a;
  margin-top: 3px;
}

.sestito-mc-item__qty {
  font-size: 12px;
  color: #6a6a6a;
}

/* ===== PRICE / SALE STYLING ===== */
/* Hide the red discount badge — too loud for luxury context */
.sestito-mini-cart-dropdown .ssc-discount-badge {
  display: none;
}

/* Strikethrough original price — subtle */
.sestito-mini-cart-dropdown del,
.sestito-mini-cart-dropdown .ssc-original-price {
  color: #aaa;
  font-size: 11px;
  text-decoration: line-through;
  opacity: 0.7;
  margin-right: 4px;
}

/* Sale price */
.sestito-mini-cart-dropdown ins,
.sestito-mini-cart-dropdown .ssc-sale-price {
  text-decoration: none;
  color: #1d3d2f;
  font-weight: 500;
}

/* WooCommerce price wrapper */
.sestito-mini-cart-dropdown .ssc-price-wrapper {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  flex-wrap: wrap;
}

/* Variation data */
.sestito-mc-item .variation {
  font-size: 10px;
  color: #8a7a5a;
  margin: 3px 0 0;
}

.sestito-mc-item .variation p {
  margin: 0;
}

/* Remove button */
.sestito-mc-item__remove {
  position: absolute;
  top: 14px;
  right: 20px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: #c4bfb5;
  text-decoration: none;
  transition: color 0.15s;
}

.sestito-mc-item__remove:hover {
  color: #1d3d2f;
}

/* ===== TOTAL ROW ===== */
.sestito-mc-total {
  padding: 14px 20px;
  border-top: 1px solid rgba(29, 61, 47, 0.08);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* WC outputs: <strong>Subtotal:</strong> <span class="woocommerce-Price-amount"> */
.sestito-mc-total strong {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #8a7a5a;
}

.sestito-mc-total .woocommerce-Price-amount {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  color: #1d3d2f;
  letter-spacing: 0.01em;
}

.sestito-mc-total .total {
  display: contents;
}

/* ===== BUTTONS ===== */
.sestito-mc-buttons {
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sestito-mc-buttons .button,
.sestito-mc-buttons a {
  display: block;
  text-align: center;
  padding: 12px 16px;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  box-sizing: border-box;
  border-radius: 0;
}

.sestito-mc-buttons .button.checkout,
.sestito-mc-buttons a.checkout {
  background: #c9a84c;
  color: #1c1c1c;
  border: 1px solid #c9a84c;
}

.sestito-mc-buttons .button.checkout:hover,
.sestito-mc-buttons a.checkout:hover {
  background: #b8963d;
  border-color: #b8963d;
}

.sestito-mc-buttons .button:not(.checkout),
.sestito-mc-buttons a:not(.checkout) {
  background: transparent;
  color: #1d3d2f;
  border: 1px solid rgba(29, 61, 47, 0.3);
}

.sestito-mc-buttons .button:not(.checkout):hover,
.sestito-mc-buttons a:not(.checkout):hover {
  border-color: #1d3d2f;
  background: transparent;
}

/* ===== EMPTY STATE ===== */
.sestito-mc-empty {
  padding: 48px 20px;
  text-align: center;
  color: #9a9a9a;
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.sestito-mc-empty::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9a84c' stroke-width='1.2'%3E%3Cpath d='M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4z'/%3E%3Cline x1='3' y1='6' x2='21' y2='6'/%3E%3Cpath d='M16 10a4 4 0 01-8 0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.6;
}

/* Hide WooCommerce default empty-cart message — we render our own .sestito-mc-empty */
.sestito-mini-cart-content .woocommerce-mini-cart__empty-message {
  display: none;
}

/* ===== LOADING OVERLAY ===== */
.sestito-mini-cart-dropdown.is-loading {
  pointer-events: none;
}

.sestito-mini-cart-dropdown.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 1;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .sestito-mini-cart-dropdown {
    width: calc(100vw - 24px);
    max-width: 380px;
    right: 12px;
    left: auto;
    /* top: controlled by JS */
    max-height: calc(100svh - 80px);
    border-radius: 0 0 4px 4px;
  }
}

@media (max-width: 400px) {
  .sestito-mini-cart-dropdown {
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }
}
