---
import Base from '../layouts/Base.astro';
const main = `<div class="cart-page">
    <h1 class="cart-page-heading">Warenkorb</h1>

    <!-- Cart Items -->
    <div class="cart-main">
      <div id="cart-items" aria-live="polite" aria-label="Artikel im Warenkorb"></div>

      <div id="cart-empty" role="status">
        <h2>Dein Warenkorb ist leer.</h2>
        <p>Noch nichts drin? Das lässt sich ändern.<br>Hier ist die Pumpenzange noch kein Klischee.</p>
        <a href="/shop" class="btn btn-primary">Zum Shop</a>
      </div>

      <a href="/shop" class="continue-btn" aria-label="Zurück zum Shop">Weiter einkaufen</a>
    </div>

    <!-- Order Summary -->
    <aside class="cart-summary" id="cart-summary" aria-label="Bestellübersicht">
      <div class="summary-heading">Bestellübersicht</div>

      <div class="summary-line">
        <span>Zwischensumme</span>
        <strong class="js-cart-subtotal">0,00 €</strong>
      </div>
      <div class="summary-line">
        <span>Versand (DE)</span>
        <span class="js-shipping-display">wird berechnet</span>
      </div>

      <div class="summary-divider"></div>

      <div class="summary-total">
        <span class="summary-total-label">Gesamt</span>
        <span class="summary-total-price js-cart-total-display">0,00 €</span>
      </div>

      <p class="summary-note">Inkl. MwSt. · Versandkosten werden an der Kasse berechnet. Kostenloser Versand ab 50 €.</p>

      <div class="promo-form" role="form" aria-label="Rabattcode einlösen">
        <input type="text" class="promo-input" id="promo-input" placeholder="Rabattcode" aria-label="Rabattcode eingeben" autocomplete="off" spellcheck="false">
        <button type="button" class="promo-btn" id="promo-btn">Einlösen</button>
      </div>

      <div class="summary-cta">
        <a href="/checkout" class="btn btn-primary btn-full btn-lg" id="checkout-link">
          Zur Kasse →
        </a>
        <button class="btn btn-outline btn-full" onclick="window.location='shop.html'">
          Weiter einkaufen
        </button>
      </div>

      <div class="cart-trust-row">
        <span class="cart-trust-item">SSL-verschlüsselt · sicher bezahlen</span>
        <span class="cart-trust-item">30 Tage Rückgaberecht</span>
        <span class="cart-trust-item">Versand innerhalb von 2–4 Werktagen</span>
      </div>
    </aside>
  </div>`;
---
<Base title={"Warenkorb — PMPNZNG"} page="cart" active="">
  <Fragment set:html={main} />
</Base>

<style is:global>

.cart-page {
  max-width: var(--max-w); margin: 0 auto;
  padding: var(--sp-lg) var(--gutter) var(--sp-2xl);
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: clamp(32px, 4vw, 64px);
  align-items: start;
}
.cart-page-heading {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 900; text-transform: uppercase; line-height: 1;
  grid-column: 1 / -1;
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--c-border);
}
/* Cart items */
#cart-items { display: flex; flex-direction: column; gap: 2px; }
.cart-item {
  display: grid; grid-template-columns: 100px 1fr auto;
  gap: 20px; align-items: center;
  background: var(--c-surface-1);
  padding: 16px;
  border: 1px solid var(--c-border);
}
.cart-item-img { background: var(--c-card); aspect-ratio: 4/5; overflow: hidden; }
.cart-item-img img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.cart-item-info { display: flex; flex-direction: column; gap: 6px; }
.cart-item-name {
  font-family: var(--font-display); font-size: 14px; font-weight: 900;
  text-transform: uppercase; line-height: 1.2;
}
.cart-item-size { font-size: 10px; letter-spacing: 0.14em; color: var(--c-text-muted); text-transform: uppercase; }
.cart-item-qty { display: flex; align-items: center; gap: 0; margin-top: 4px; }
.qty-btn {
  width: 32px; height: 32px; background: var(--c-surface-2);
  border: 1px solid var(--c-border-mid);
  font-size: 14px; font-weight: 900; color: var(--c-text);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.qty-btn:hover { background: var(--c-surface-3); }
.qty-val {
  width: 36px; text-align: center; font-size: 13px; font-weight: 700;
  border-top: 1px solid var(--c-border-mid);
  border-bottom: 1px solid var(--c-border-mid);
  height: 32px; line-height: 30px;
  background: var(--c-surface-1);
}
.cart-item-price {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.cart-item-price > span {
  font-family: var(--font-display); font-size: 16px; font-weight: 900;
}
.cart-remove {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--c-text-dim); text-decoration: underline;
  transition: color 0.15s;
}
.cart-remove:hover { color: var(--c-red-bright); }

#cart-empty {
  display: none; text-align: center;
  padding: var(--sp-2xl) var(--gutter);
  border: 1px dashed var(--c-border-mid);
}
#cart-empty p { color: var(--c-text-muted); font-size: 14px; line-height: 1.7; margin-bottom: var(--sp-md); }
#cart-empty h2 { font-family: var(--font-display); font-size: clamp(20px,2.5vw,28px); font-weight: 900; text-transform: uppercase; margin-bottom: 12px; }

/* Order Summary */
.cart-summary {
  background: var(--c-surface-1);
  border: 1px solid var(--c-border);
  padding: var(--sp-md);
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex; flex-direction: column; gap: 16px;
}
.summary-heading {
  font-family: var(--font-display); font-size: 12px; font-weight: 900;
  letter-spacing: 0.22em; text-transform: uppercase;
  padding-bottom: 12px; border-bottom: 1px solid var(--c-border);
}
.summary-line {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--c-text-muted);
}
.summary-line strong { color: var(--c-text); }
.summary-free { color: #22c55e; font-weight: 700; font-size: 11px; }
.summary-divider { height: 1px; background: var(--c-border); }
.summary-total {
  display: flex; align-items: baseline; justify-content: space-between;
}
.summary-total-label {
  font-family: var(--font-display); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 900;
}
.summary-total-price {
  font-family: var(--font-display); font-size: 24px; font-weight: 900;
}
.summary-note {
  font-size: 10px; color: var(--c-text-muted); line-height: 1.6;
}
.summary-cta {
  display: flex; flex-direction: column; gap: 8px;
}

/* Promo code */
.promo-form {
  display: flex; gap: 0; border: 1px solid var(--c-border-mid);
}
.promo-input {
  flex: 1; background: var(--c-surface-2); border: none;
  padding: 10px 14px; font-size: 12px; letter-spacing: 0.1em;
  color: var(--c-text); text-transform: uppercase;
}
.promo-input:focus { outline: none; }
.promo-input::placeholder { color: var(--c-text-dim); }
.promo-btn {
  background: var(--c-surface-3); border: none;
  padding: 10px 16px; font-size: 10px; font-weight: 900;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--c-text-muted); transition: all 0.15s;
}
.promo-btn:hover { background: var(--c-red); color: #fff; }

/* Trust mini */
.cart-trust-row {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--c-border);
}
.cart-trust-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--c-text-muted);
}
.cart-trust-item::before { content:'✓'; color: var(--c-red-bright); font-weight: 900; flex-shrink: 0; }

/* Continue shopping */
.continue-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--c-text-muted); font-weight: 700;
  margin-top: var(--sp-sm);
  transition: color 0.15s;
}
.continue-btn::before { content:'←'; }
.continue-btn:hover { color: var(--c-text); }

@media (max-width: 900px) {
  .cart-page { grid-template-columns: 1fr; }
  .cart-summary { position: static; }
}
@media (max-width: 640px) {
  .cart-item { grid-template-columns: 80px 1fr; }
  .cart-item-price { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
}

</style>