/**
 * Stilurile formularului de retragere.
 *
 * Neutre intenționat: formularul apare în tema comerciantului, deci moștenește fontul temei și
 * folosește doar culoarea de brand configurată. Zero dependențe, zero webfonts — extensiile de
 * temă nu au voie să scadă scorul Lighthouse cu mai mult de 10 puncte.
 */

[data-retragere-form] {
  --rt-brand: #1f2937;
  --rt-border: #e5e7eb;
  --rt-muted: #6b7280;
  --rt-bg-soft: #f9fafb;
  --rt-danger: #b42318;

  font-family: inherit;
  color: inherit;
  max-width: 42rem;
  margin: 0 auto;
}

[data-retragere-form] * {
  box-sizing: border-box;
}

.rt-card {
  padding: 1.5rem 0;
}

.rt-kind {
  display: inline-block;
  margin: 0 0 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--rt-brand);
}
.rt-kind-cancel {
  background: #b45309;
}

.rt-h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}
/* Titlurile primesc focus programatic la schimbarea pasului (a11y). Nu sunt ținte de tastatură
   (tabindex="-1"), deci suprimăm conturul de focus care ar apărea inutil. */
.rt-h1:focus, .rt-h2:focus { outline: none; }

.rt-h2 {
  font-size: 1.125rem;
  margin: 0 0 1rem;
}

.rt-h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

.rt-intro {
  margin: 0 0 1.5rem;
  line-height: 1.6;
  color: var(--rt-muted);
}

.rt-field {
  margin-bottom: 1rem;
}

.rt-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.rt-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--rt-border);
  border-radius: 0.375rem;
  font: inherit;
  font-size: 1rem; /* previne zoom-ul automat pe iOS */
  background: #fff;
  color: inherit;
}

.rt-input:focus-visible {
  outline: 2px solid var(--rt-brand);
  outline-offset: 1px;
}

.rt-help {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--rt-muted);
  line-height: 1.5;
}

.rt-error {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--rt-danger);
}

.rt-status {
  margin: 0.75rem 0;
  font-size: 0.875rem;
  color: var(--rt-muted);
  line-height: 1.5;
  min-height: 1.25rem;
}

.rt-btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-right: 0.5rem;
  margin-top: 0.5rem;
}

.rt-btn-primary {
  background: var(--rt-brand);
  color: #fff;
}

.rt-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rt-btn-secondary {
  background: transparent;
  border-color: var(--rt-border);
  color: inherit;
}

.rt-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--rt-brand);
  text-decoration: underline;
  cursor: pointer;
}

.rt-fallback {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rt-border);
  font-size: 0.875rem;
  color: var(--rt-muted);
  line-height: 1.6;
}

.rt-lines {
  margin: 1rem 0;
}

.rt-line {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rt-border);
}

.rt-thumb {
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: 0.375rem;
  flex-shrink: 0;
}

.rt-thumb-empty {
  background-color: var(--rt-bg-soft);
  border: 1px solid var(--rt-border);
  /* Liniile fără imagine (taxe, ramburs) primesc un placeholder intenționat, nu un pătrat gol
     care pare stricat. Iconița e un „poză lipsă" discret, în gri. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2.5'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 1.5rem;
}

.rt-line-body {
  flex: 1;
  min-width: 0;
}

.rt-line-title {
  display: block;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
}

.rt-line-meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--rt-muted);
}

.rt-line-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.625rem;
}

/* Checkbox propriu: bifă albă clară pe fundal de brand când e selectat, contur curat când nu e.
   Checkbox-ul nativ desena un pătrat plin fără bifă vizibilă — arăta stricat, inconsecvent. */
.rt-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  border: 1.5px solid var(--rt-border);
  border-radius: 0.375rem;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.rt-checkbox:hover {
  border-color: var(--rt-brand);
}
.rt-checkbox:checked {
  background-color: var(--rt-brand);
  border-color: var(--rt-brand);
  /* Bifa vine din background-image, NU din ::after: pseudo-elementele nu se randează pe <input>
     în majoritatea browserelor, de-aia checkbox-ul apărea negru plin, fără bifă. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.8rem;
}
.rt-checkbox:focus-visible {
  outline: 2px solid var(--rt-brand);
  outline-offset: 2px;
}

.rt-qty {
  width: 4.5rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--rt-border);
  border-radius: 0.375rem;
  font: inherit;
}

.rt-line-price {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/**
 * Avertismentele (produs exceptat, termen posibil expirat) sunt informative, nu blocante.
 * De aceea nu au stil de eroare: nu semnalăm un refuz, ci o informație pe care consumatorul
 * o ia în calcul înainte să transmită declarația — pe care o poate transmite oricum.
 */
.rt-notice {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  background: var(--rt-bg-soft);
  border-left: 3px solid var(--rt-border);
  border-radius: 0 0.25rem 0.25rem 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--rt-muted);
}

.rt-notice-window {
  margin-bottom: 1rem;
}

.rt-subcard {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--rt-bg-soft);
  border-radius: 0.5rem;
}

.rt-declaration {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--rt-bg-soft);
  border-left: 3px solid var(--rt-brand);
  border-radius: 0 0.375rem 0.375rem 0;
  line-height: 1.7;
}

.rt-decl-items {
  margin: 0;
  padding-left: 1.25rem;
}

.rt-btn-confirm {
  display: block;
  width: 100%;
  margin-right: 0;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

.rt-reference {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  font-variant-numeric: tabular-nums;
}

.rt-timestamp {
  font-size: 1rem;
  margin: 0 0 1.25rem;
}

.rt-done .rt-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--rt-muted);
  margin-bottom: 0.25rem;
}

@media (max-width: 480px) {
  .rt-line {
    flex-wrap: wrap;
  }

  .rt-line-price {
    width: 100%;
    padding-left: 5rem;
  }

  .rt-btn {
    width: 100%;
    margin-right: 0;
  }
}

/* ─────────────────────────────────────────────────────────── Modal
 *
 * Formularul se deschide peste pagină, nu într-o pagină nouă: clientul nu-și pierde contextul
 * (coșul, produsul la care se uita) și nu are impresia că a plecat de pe magazin.
 *
 * Fallback-ul rămâne pagina completă de pe App Proxy — fără JS, linkul duce acolo. Un modal
 * care ar fi singura cale de acces ar face funcția indisponibilă pentru cine are JS blocat,
 * iar indisponibilitatea e chiar fapta sancționată.
 */
.rt-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 700px) {
  .rt-modal {
    align-items: center;
    padding: 24px;
  }
}

.rt-modal[hidden] {
  display: none;
}

.rt-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  animation: rt-fade-in 200ms ease-out;
}

.rt-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 44rem;
  max-height: 92vh;
  overflow: hidden;
  background: #fff;
  color: #111827;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  /* Pe mobil urcă de jos (gestul nativ de sheet), pe desktop apare în centru. */
  animation: rt-sheet-up 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 700px) {
  .rt-modal__panel {
    border-radius: 16px;
    animation: rt-pop-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
  }
}

.rt-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rt-border, #e5e7eb);
}

.rt-modal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.rt-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--rt-muted, #6b7280);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 8px;
  transition: background 150ms ease, color 150ms ease;
}

.rt-modal__close:hover,
.rt-modal__close:focus-visible {
  color: #111827;
  background: #f3f4f6;
}

.rt-modal__body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Pașii formularului intră cu un fade scurt, ca trecerea să se simtă, nu să clipească. */
.rt-modal__body .rt-card,
.rt-modal__body .rt-form {
  animation: rt-step-in 220ms ease-out;
}

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

@keyframes rt-sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes rt-pop-in {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes rt-step-in {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Animația e ornament, nu funcție: cine a cerut mai puțină mișcare primește tot conținutul, instant. */
@media (prefers-reduced-motion: reduce) {
  .rt-modal__backdrop,
  .rt-modal__panel,
  .rt-modal__body .rt-card,
  .rt-modal__body .rt-form {
    animation: none;
  }
}

/* În modal, cardul nu-și mai adaugă propria ramă și lățime — le dă panoul. */
.rt-modal__body [data-retragere-form] {
  max-width: none;
}
