/* ==========================================================================
   shop.css - Perls Holzschmiede
   Produktliste, Filterleiste, Produktkarten, Detailansicht-Modal,
   Warenkorb-Sidebar
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Shop Header
   Zentrierter Titel und Untertitel ueber der Produktliste
   -------------------------------------------------------------------------- */

.shop-header {
  text-align: center;
  padding-bottom: var(--space-xl);
}

.shop-header .section-header {
  margin-bottom: 0;
}


/* --------------------------------------------------------------------------
   2. Filter-Leiste
   Horizontal zentrierte Kategorie-Buttons
   -------------------------------------------------------------------------- */

.shop-filters-section {
  padding-bottom: var(--space-xl);
}

.shop-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
}

/* Einzel-Filterbutton (Pill-Form) */
.filter-btn {
  padding: 0.5rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-light);
  background-color: transparent;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-fast),
              color var(--transition-fast),
              border-color var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.filter-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background-color: var(--color-surface-hover);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.filter-btn.active {
  color: var(--color-surface);
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.filter-btn.active:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: var(--color-surface);
}


/* --------------------------------------------------------------------------
   3. Produkt-Grid
   Responsives Grid-Layout fuer die Produktkarten
   -------------------------------------------------------------------------- */

.shop-products {
  padding-top: 0;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

/* Lade-Spinner (wird von shop.js entfernt) */
.shop-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) 0;
  gap: var(--space-md);
}

.shop-loading-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: 0;
}

/* Keine-Ergebnisse-Meldung */
.shop-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-3xl) 0;
  color: var(--color-text-muted);
}


/* --------------------------------------------------------------------------
   4. Produktkarte
   Einzelne Produktdarstellung im Grid
   -------------------------------------------------------------------------- */

.product-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal),
              box-shadow var(--transition-normal);
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.product-card:focus-within {
  box-shadow: var(--shadow-lg);
}

/* --- Bildbereich --- */
.product-card-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background-color: var(--color-bg-alt);
}

.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.product-card:hover .product-card-image img {
  transform: scale(1.05);
}

/* Ausverkauft-Overlay */
.product-card-soldout {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background-color: var(--color-error);
  color: var(--color-surface);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25em 0.625em;
  border-radius: var(--radius-sm);
}

/* --- Kartenkoerper --- */
.product-card-body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Kategorie-Tag */
.product-card-category {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

/* Produktname */
.product-card-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
  line-height: var(--line-height-tight);
}

/* Kurzbeschreibung (max 2 Zeilen) */
.product-card-description {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-md);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* --- Kartenfuss (Preis + Button) --- */
.product-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

/* Preis */
.product-card-price {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}

/* Preis: "Auf Anfrage"-Variante */
.product-card-price--inquiry {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-muted);
  font-style: italic;
  font-family: var(--font-body);
}


/* --------------------------------------------------------------------------
   5. Produktdetail-Modal
   Grosses Dialog-Fenster mit Bildkarussell und Produktinformationen
   -------------------------------------------------------------------------- */

/* Modal breiter als Standard */
.product-detail-modal {
  max-width: 900px;
}

/* Zweispaltiges Layout: Bilder links, Infos rechts */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

/* --- Bild-Karussell --- */
.product-carousel {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--color-bg-alt);
  aspect-ratio: 4 / 3;
}

.product-carousel-images {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform var(--transition-normal);
}

.product-carousel-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Karussell-Buttons (Vor / Zurueck) */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  background-color: rgba(255, 255, 255, 0.85);
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--text-2xl);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast),
              opacity var(--transition-fast);
  opacity: 0;
  z-index: 2;
}

.product-carousel:hover .carousel-btn {
  opacity: 1;
}

.carousel-btn:hover {
  background-color: var(--color-surface);
}

.carousel-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  opacity: 1;
}

.carousel-btn-prev {
  left: var(--space-sm);
}

.carousel-btn-next {
  right: var(--space-sm);
}

/* Karussell-Punkte (Dot-Indikatoren) */
.carousel-dots {
  position: absolute;
  bottom: var(--space-sm);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-xs);
  z-index: 2;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast);
}

.carousel-dot:hover {
  background-color: rgba(255, 255, 255, 0.8);
}

.carousel-dot.active {
  background-color: var(--color-surface);
  transform: scale(1.25);
}

/* Karussell-Buttons ausblenden wenn nur 1 Bild */
.carousel-single .carousel-btn,
.carousel-single .carousel-dots {
  display: none;
}

/* --- Produktinfos (rechte Spalte) --- */
.product-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.product-info-category {
  align-self: flex-start;
}

.product-info-price {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0;
}

.product-info-price--inquiry {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  font-style: italic;
  font-family: var(--font-body);
}

.product-info-description {
  font-size: var(--text-base);
  color: var(--color-text-light);
  line-height: var(--line-height-relaxed);
  margin-bottom: 0;
}

/* Detailtabelle (Material, Masse, etc.) */
.product-details-table {
  width: 100%;
  border-collapse: collapse;
}

.product-details-table td {
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.product-details-table td:first-child {
  font-weight: 600;
  color: var(--color-text);
  width: 40%;
  padding-right: var(--space-md);
}

.product-details-table td:last-child {
  color: var(--color-text-light);
}

/* Aktions-Bereich (Buttons) */
.product-info-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: auto;
  padding-top: var(--space-md);
}


/* --------------------------------------------------------------------------
   6. Warenkorb-Sidebar
   Einschiebbares Panel von rechts
   -------------------------------------------------------------------------- */

/* Verdunkelungs-Overlay */
.cart-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(44, 24, 16, 0.5);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal),
              visibility var(--transition-normal);
}

.cart-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Sidebar-Panel */
.cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background-color: var(--color-surface);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.cart-sidebar.open {
  transform: translateX(0);
}

/* Sidebar-Kopf */
.cart-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.cart-sidebar-header h3 {
  margin-bottom: 0;
  font-size: var(--text-xl);
}

.cart-sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.cart-sidebar-close:hover {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
}

/* Warenkorbinhalte (scrollbar) */
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
}

/* Leere-Warenkorb-Meldung */
.cart-empty-message {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-2xl) 0;
  font-size: var(--text-sm);
}

/* Einzelner Warenkorb-Eintrag */
.cart-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
}

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

/* Artikelbild im Warenkorb */
.cart-item-image {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--color-bg-alt);
}

/* Artikeldetails */
.cart-item-details {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  line-height: var(--line-height-tight);
}

.cart-item-price {
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: 600;
}

/* Mengensteuerung */
.cart-item-quantity {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.cart-item-quantity button {
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  background-color: var(--color-surface);
  cursor: pointer;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast);
}

.cart-item-quantity button:hover {
  background-color: var(--color-bg-alt);
  border-color: var(--color-primary);
}

.cart-item-qty-value {
  font-size: var(--text-sm);
  font-weight: 600;
  min-width: 1.5rem;
  text-align: center;
}

/* Entfernen-Button */
.cart-item-remove {
  flex-shrink: 0;
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  cursor: pointer;
  padding: var(--space-xs);
  transition: color var(--transition-fast);
  align-self: flex-start;
}

.cart-item-remove:hover {
  color: var(--color-error);
}

/* Zusammenfassung am unteren Rand */
.cart-summary {
  padding: var(--space-lg);
  border-top: 2px solid var(--color-border);
  flex-shrink: 0;
  background-color: var(--color-bg-alt);
}

.cart-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-weight: 600;
}

.cart-subtotal {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--color-primary);
}

.cart-shipping-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.cart-checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}


/* ==========================================================================
   7. Responsive Anpassungen
   ========================================================================== */

/* --- Tablet (max 1024px) --- */
@media (max-width: 1024px) {
  /* Detailansicht: einspaltig */
  .product-detail {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .product-detail-modal {
    max-width: 600px;
  }
}

/* --- Mobile (max 768px) --- */
@media (max-width: 768px) {
  .shop-grid {
    grid-template-columns: 1fr;
  }

  .shop-header {
    padding-top: var(--space-xl);
    padding-bottom: var(--space-lg);
  }

  .filter-btn {
    padding: 0.375rem 1rem;
    font-size: var(--text-xs);
  }

  /* Modal auf Mobile nahezu volle Breite */
  .product-detail-modal {
    max-width: none;
    margin: var(--space-sm);
    max-height: calc(100vh - 2 * var(--space-sm));
  }

  .product-detail {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .product-info-price {
    font-size: var(--text-2xl);
  }

  /* Warenkorb volle Breite auf Mobilgeraeten */
  .cart-sidebar {
    width: 100vw;
  }

  /* Karussell-Buttons immer sichtbar auf Touch-Geraeten */
  .carousel-btn {
    opacity: 0.8;
  }
}

/* --- Kleines Mobile (max 480px) --- */
@media (max-width: 480px) {
  .shop-filters {
    gap: var(--space-xs);
  }

  .filter-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .product-card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .product-card-price {
    text-align: center;
  }

  .product-card-footer .btn {
    width: 100%;
  }
}


/* ==========================================================================
   8. Druckstile
   ========================================================================== */

@media print {
  .shop-filters-section,
  .cart-sidebar,
  .cart-overlay,
  .modal-overlay {
    display: none !important;
  }

  .product-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .product-card:hover {
    transform: none;
  }

  .product-card:hover .product-card-image img {
    transform: none;
  }
}
