/* Mentex Cart-Validator: Modal & Drawer
   --------------------------------------------------------------
   Styling für das Premium-Credit-Shortfall-Popup und den
   Warenkorb-Drawer aus static/js/cart-validator.js. CSP-konform
   (alle Styles in dieser Datei, keine inline-style-Attribute).
   Wird auf templates/index.html und templates/buy_credits.html
   per <link rel="stylesheet"> eingebunden. */

/* ---- Overlay & Modal-Container ------------------------------ */

.cv-modal-overlay,
.cv-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 12, 22, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #F5F5F5;
  animation: cv-fade-in 140ms ease-out;
}

.cv-drawer-overlay {
  align-items: flex-start;
  padding-top: clamp(1.25rem, 6vh, 4rem);
}

@keyframes cv-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.cv-modal,
.cv-drawer {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  background: #0C1220;
  color: #F5F5F5;
  border: 1px solid rgba(197, 160, 89, 0.4);
  border-radius: 0.9rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  padding: 1.75rem 1.6rem 1.5rem;
  animation: cv-slide-up 180ms ease-out;
}

.cv-drawer {
  max-width: 640px;
}

@keyframes cv-slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ---- Schließen-Button --------------------------------------- */

.cv-modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: none;
  color: #C5A059;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 0.4rem;
}
.cv-modal-close:hover { color: #d4b978; background: rgba(197, 160, 89, 0.08); }
.cv-modal-close:focus-visible {
  outline: 2px solid #C5A059;
  outline-offset: 2px;
}

/* ---- Typografie --------------------------------------------- */

.cv-modal h3,
.cv-drawer h3 {
  margin: 0 0 0.65rem;
  padding-right: 1.5rem;
  color: #C5A059;
  font-size: 1.15rem;
  line-height: 1.35;
  font-weight: 600;
}

.cv-modal-lead {
  margin: 0 0 1rem;
  color: #cbd1d8;
  font-size: 0.92rem;
  line-height: 1.5;
}

.cv-drawer-info {
  margin: 0 0 0.85rem;
  color: #cbd1d8;
  font-size: 0.88rem;
}

.cv-drawer-muted {
  color: #8a93a0;
  font-size: 0.82rem;
}

/* ---- Tabellen ----------------------------------------------- */

.cv-modal-table,
.cv-drawer-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0 1.1rem;
  font-size: 0.92rem;
}

.cv-modal-table td,
.cv-drawer-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.cv-modal-table td:last-child,
.cv-drawer-table td:last-child {
  text-align: right;
}

.cv-modal-table tr:last-child td,
.cv-drawer-table tr:last-child td {
  border-bottom: none;
}

.cv-modal-shortfall td {
  color: #fb7185;
  font-weight: 600;
}

.cv-drawer-table tfoot td {
  border-top: 1px solid rgba(197, 160, 89, 0.35);
  padding-top: 0.7rem;
  font-size: 1rem;
}

.cv-drawer-price {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.cv-drawer-qty {
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cv-drawer-qty input,
.cv-drawer-qty button {
  font-family: inherit;
}

.cv-drawer-qty input[type="number"] {
  width: 3.2rem;
  margin: 0 0.3rem;
  padding: 0.25rem 0.35rem;
  background: rgba(255, 255, 255, 0.05);
  color: #F5F5F5;
  border: 1px solid rgba(197, 160, 89, 0.35);
  border-radius: 0.35rem;
  text-align: center;
  font-size: 0.9rem;
}

.cv-drawer-qty button {
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  background: rgba(197, 160, 89, 0.12);
  color: #C5A059;
  border: 1px solid rgba(197, 160, 89, 0.4);
  border-radius: 0.35rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.cv-drawer-qty button:hover { background: rgba(197, 160, 89, 0.22); }
.cv-drawer-qty button:focus-visible {
  outline: 2px solid #C5A059;
  outline-offset: 1px;
}

.cv-drawer-topup--short td {
  color: #fbbf6f;
}

.cv-drawer-discount td {
  color: #6ee7b7;
}

/* ---- Discount-Eingabezeile ---------------------------------- */

.cv-drawer-discount-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.4rem 0 0.9rem;
  flex-wrap: wrap;
}

.cv-drawer-discount-row input[type="text"] {
  flex: 1 1 160px;
  min-width: 140px;
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  color: #F5F5F5;
  border: 1px solid rgba(197, 160, 89, 0.35);
  border-radius: 0.4rem;
  font-size: 0.9rem;
  font-family: inherit;
}

.cv-drawer-discount-row button {
  padding: 0.45rem 0.85rem;
  background: rgba(197, 160, 89, 0.12);
  color: #C5A059;
  border: 1px solid rgba(197, 160, 89, 0.4);
  border-radius: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.cv-drawer-discount-row button:hover { background: rgba(197, 160, 89, 0.22); }

/* ---- Warn- / OK-Hinweise ------------------------------------ */

.cv-drawer-warn {
  margin: 0.4rem 0 0.85rem;
  padding: 0.6rem 0.75rem;
  background: rgba(251, 113, 133, 0.08);
  border: 1px solid rgba(251, 113, 133, 0.4);
  border-radius: 0.45rem;
  color: #fda4af;
  font-size: 0.88rem;
  line-height: 1.45;
}

.cv-drawer-ok {
  margin: 0.4rem 0 0.85rem;
  padding: 0.6rem 0.75rem;
  background: rgba(110, 231, 183, 0.08);
  border: 1px solid rgba(110, 231, 183, 0.35);
  border-radius: 0.45rem;
  color: #86efac;
  font-size: 0.88rem;
  line-height: 1.45;
}

/* ---- Action-Buttons ----------------------------------------- */

.cv-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.cv-btn-primary,
.cv-btn-secondary,
.cv-btn-link {
  padding: 0.65rem 1.1rem;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cv-btn-primary {
  background: linear-gradient(135deg, #C5A059, #a8884a);
  color: #ffffff;
  border: 1px solid rgba(197, 160, 89, 0.5);
  box-shadow: 0 4px 14px rgba(197, 160, 89, 0.25);
}
.cv-btn-primary:hover { filter: brightness(1.08); }
.cv-btn-primary:disabled,
.cv-btn-primary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.3);
}

.cv-btn-secondary {
  background: transparent;
  color: #C5A059;
  border: 1px solid #C5A059;
}
.cv-btn-secondary:hover { background: rgba(197, 160, 89, 0.12); }

.cv-btn-link {
  background: transparent;
  color: #cbd1d8;
  border: none;
  padding: 0.65rem 0.6rem;
}
.cv-btn-link:hover { color: #ffffff; }

.cv-btn-primary:focus-visible,
.cv-btn-secondary:focus-visible,
.cv-btn-link:focus-visible {
  outline: 2px solid #F5F5F5;
  outline-offset: 2px;
}

/* ---- Mobile -------------------------------------------------- */

@media (max-width: 540px) {
  .cv-modal,
  .cv-drawer {
    padding: 1.4rem 1.1rem 1.2rem;
  }
  .cv-modal h3,
  .cv-drawer h3 {
    font-size: 1.05rem;
  }
  .cv-modal-actions {
    justify-content: stretch;
  }
  .cv-btn-primary,
  .cv-btn-secondary,
  .cv-btn-link {
    flex: 1 1 100%;
    text-align: center;
  }
}

/* ---- Stepper-Karte (freie Stückzahl 1–4) -------------------- */
/* Wird auf templates/index.html (Registration-Form) und
   templates/buy_credits.html (Credit-Karten) genutzt. */

.package-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.package-stepper .stepper-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: rgba(197, 160, 89, 0.12);
  color: #C5A059;
  border: 1px solid rgba(197, 160, 89, 0.5);
  border-radius: 0.4rem;
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.package-stepper .stepper-btn:hover { background: rgba(197, 160, 89, 0.24); }
.package-stepper .stepper-btn:focus-visible {
  outline: 2px solid #C5A059;
  outline-offset: 2px;
}

.package-stepper .stepper-value {
  display: inline-block;
  min-width: 1.6rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 600;
  color: #F5F5F5;
}

.package-stepper .package-desc {
  margin-left: 0.4rem;
  color: #8a93a0;
  font-size: 0.8rem;
}

.package-option--stepper .package-stepper {
  margin-top: 0.5rem;
}

.credit-option--stepper .package-stepper {
  margin: 0 0.6rem 0 0;
}

/* Mobile: Stepper-Karte in buy_credits.html (Layout mit .row-bare).
   Auf schmalen Viewports stapeln wir Stepper / Preis / Kaufen-Button
   in zwei Zeilen, damit die Pluszählerei nicht in eine 40px-Spalte
   gequetscht wird. Höhere Spezifität als die globale
   `.btn-buy { width: 100% }`-Regel aus templates/buy_credits.html. */
@media (max-width: 600px) {
  .credit-option--stepper .row-bare {
    flex-wrap: wrap;
    justify-content: flex-start;
    column-gap: 0.75rem;
    row-gap: 0.5rem;
  }
  .credit-option--stepper .package-stepper {
    flex: 1 1 100%;
    margin: 0;
    flex-wrap: nowrap;
  }
  .credit-option--stepper .credit-price {
    flex: 1 1 auto;
    white-space: nowrap;
  }
  .credit-option--stepper .btn-buy {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 0.55rem 1.1rem;
  }
}

/* Mobile: Stepper-Karte in templates/index.html (Registrierungs-Form).
   Verhindert, dass der Hilfetext "Reports (1–4 …)" hinter dem +-Button
   in eine zweite, schmale Spalte umbricht. */
@media (max-width: 480px) {
  .package-option--stepper .package-stepper {
    width: 100%;
    flex-wrap: nowrap;
  }
  .package-option--stepper .package-stepper .package-desc {
    margin-left: auto;
    font-size: 0.72rem;
    text-align: right;
    flex: 0 1 auto;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cv-modal-overlay,
  .cv-drawer-overlay,
  .cv-modal,
  .cv-drawer {
    animation: none;
  }
  .cv-btn-primary,
  .cv-btn-secondary,
  .cv-btn-link {
    transition: none;
  }
}
