/* Sekcja newslettera (resources/views/sections/newsletter.blade.php).
   Wygląd wzorowany na projekcie referencyjnym (dimaq-mocha.vercel.app).

   Selektory celują w natywną strukturę CF7, a nie w klasy z szablonu
   formularza trzymanego w bazie - treść formularza różni się między
   środowiskami, więc stylowanie nie może od niej zależeć. */

/* --- Karta: obraz + panel formularza --- */

.formularz-newsletter .newsletter-card {
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.04);
}

.formularz-newsletter .newsletter-panel {
  padding: 32px 24px;
}

@media (min-width: 1024px) {
  /* Pionowy odstęp był zerowy - dopóki panel był niższy od zdjęcia, nie było
     tego widać (wyśrodkowanie dawało luz). Po dodaniu pola "Imię" panel
     wyznacza wysokość karty i nagłówek dochodził do górnej krawędzi. */
  .formularz-newsletter .newsletter-panel {
    padding: 56px 64px;
  }

  /* lg:h-full na obrazku nie działał (rodzic bez określonej wysokości), więc
     przy wyższym panelu - np. po dodaniu pola "Imię" - pod zdjęciem zostawała
     pusta przestrzeń. Wysokość karty wyznacza panel, zdjęcie ją wypełnia. */
  .formularz-newsletter .newsletter-card > :first-child {
    position: relative;
    min-height: 100%;
  }

  .formularz-newsletter .newsletter-card > :first-child > div {
    position: absolute;
    inset: 0;
  }

  .formularz-newsletter .newsletter-card > :first-child img {
    height: 100%;
  }
}

/* --- Układ formularza ---
   display:contents na wrapperach sprawia, że same kontrolki stają się
   elementami jednego grida - niezależnie od tego, czy szablon formularza
   używa domyślnego <p> CF7, czy własnych divów (.nl-form/.nl-row).
   Etykieta pola jest w domyślnym szablonie gołym tekstem (nie da się jej
   wskazać selektorem), więc jej typografię trzyma <form>, a każda
   kontrolka nadpisuje ją własną. */

.newsletter-form .wpcf7-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 8px;
  margin: 0;
  padding: 0;
  color: #212121;
  font-family: "Fira Sans", sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.newsletter-form .wpcf7-form > p,
.newsletter-form .nl-form,
.newsletter-form .nl-row {
  display: contents;
}

.newsletter-form .wpcf7-form br {
  display: none;
}

/* Wiersze: 1 imię (własny wrapper z etykietą), 2 etykieta e-maila
   (umieszczana automatycznie - w domyślnym szablonie to goły tekst/span),
   3 e-mail + przycisk, 4 reCAPTCHA, 5 zgoda, 6 komunikat. */

/* Wrapper zajmuje cały wiersz (inaczej etykieta e-maila wskoczyłaby obok),
   a subgrid trzyma pole imienia w kolumnie 1 - ta sama szerokość co e-mail. */
.newsletter-form .nl-name-field {
  grid-row: 1;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  min-width: 0;
}

.newsletter-form .nl-name-field label {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.newsletter-form .wpcf7-form-control-wrap:has(input[type="email"]) {
  grid-row: 3;
  grid-column: 1;
  align-self: start;
  min-width: 0;
}

.newsletter-form .wpcf7-form-control-wrap:has(.wpcf7-acceptance) {
  grid-row: 5;
  grid-column: 1 / -1;
}

/* reCAPTCHA (app/newsletter-recaptcha.php) - pod e-mailem, nad zgodą. */
.newsletter-form .nl-recaptcha {
  grid-row: 4;
  grid-column: 1 / -1;
  min-width: 0;
  font-weight: 400;
}

.newsletter-form .nl-recaptcha .wpcf7-not-valid-tip {
  margin-top: 4px;
}

/* Widżet ma stałe 304px - na bardzo wąskich ekranach zmniejszamy go. */
@media (max-width: 359px) {
  .newsletter-form .dimaq-nl-recaptcha {
    display: block;
    transform: scale(0.85);
    transform-origin: 0 0;
  }
}

.newsletter-form .wpcf7-response-output {
  grid-row: 6;
  grid-column: 1 / -1;
}

/* --- Pola imię i e-mail --- */

.newsletter-form .wpcf7-form .nl-name-field input[type="text"],
.newsletter-form .wpcf7-form input[type="email"] {
  width: 100%;
  height: 48px;
  padding: 12px;
  border: 1px solid #EEEEEE;
  border-radius: 12px;
  background: #FFFFFF;
  color: #212121;
  font-family: "Fira Sans", sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: 0.2px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.newsletter-form .wpcf7-form .nl-name-field input[type="text"]::placeholder,
.newsletter-form .wpcf7-form input[type="email"]::placeholder {
  color: #9E9E9E;
}

.newsletter-form .wpcf7-form .nl-name-field input[type="text"]:focus,
.newsletter-form .wpcf7-form input[type="email"]:focus {
  border-color: #EF1800;
  box-shadow: 0 0 0 3px rgba(239, 24, 0, 0.08);
}

/* --- Przycisk --- */

.newsletter-form .wpcf7-form input.wpcf7-submit {
  grid-row: 3;
  grid-column: 2;
  align-self: start;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  width: auto;
  max-width: none;
  height: 48px;
  padding: 8px 16px;
  background: #EF1800;
  border: 1px solid #EF1800;
  border-radius: 999px;
  color: #FFFFFF;
  font-family: "Fira Sans", sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
}

.newsletter-form .wpcf7-form input.wpcf7-submit:hover:not(:disabled) {
  background: #D01500;
  border-color: #D01500;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(239, 24, 0, 0.35);
}

.newsletter-form .wpcf7-form input.wpcf7-submit:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(239, 24, 0, 0.2);
}

/* CF7 trzyma przycisk zablokowany do czasu zaznaczenia zgody */
.newsletter-form .wpcf7-form input.wpcf7-submit:disabled {
  background: #BDBDBD;
  border-color: #BDBDBD;
  cursor: not-allowed;
}

/* --- Zgoda marketingowa --- */

.newsletter-form .wpcf7-acceptance {
  display: block;
}

.newsletter-form .wpcf7-acceptance .wpcf7-list-item {
  margin: 0;
}

.newsletter-form .wpcf7-acceptance .wpcf7-list-item label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

/* .wpcf7-form w selektorze podbija wagę ponad regułę z bundla motywu
   (.wpcf7 .wpcf7-list-item input[type="checkbox"]), który ładuje się później */
.newsletter-form .wpcf7-form .wpcf7-acceptance input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid #BDBDBD;
  border-radius: 6px;
  box-shadow: 0 2px 1px rgba(58, 57, 76, 0.08);
  background: #FFFFFF;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.newsletter-form .wpcf7-form .wpcf7-acceptance input[type="checkbox"]:checked {
  background: #EF1800;
  border-color: #EF1800;
}

.newsletter-form .wpcf7-form .wpcf7-acceptance input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.newsletter-form .wpcf7-list-item-label {
  flex: 1;
  min-width: 0;
  color: #212121;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: 0.2px;
}

/* --- Walidacja i komunikaty --- */

.newsletter-form .wpcf7-not-valid {
  border-color: #EF1800 !important;
}

.newsletter-form .wpcf7-not-valid-tip {
  display: block;
  margin-top: 4px;
  color: #EF1800;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.newsletter-form .wpcf7-response-output {
  margin: 0;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

/* CF7 6.x sygnalizuje wynik klasą na <form>, nie na samym komunikacie */
.newsletter-form form.sent .wpcf7-response-output {
  background: #E8F5E9;
  color: #2E7D32;
}

.newsletter-form form.invalid .wpcf7-response-output,
.newsletter-form form.unaccepted .wpcf7-response-output,
.newsletter-form form.failed .wpcf7-response-output,
.newsletter-form form.aborted .wpcf7-response-output {
  background: #FFEBEE;
  color: #C62828;
}

/* Zamiast domyślnej małej ikonki CF7 obok przycisku (mało widoczna, stąd
   wrażenie "zawieszenia" przy 3-5s odpowiedzi backendu) - napis w przycisku
   znika, a POŚRODKU (bez zmiany rozmiaru/kształtu przycisku) pojawia się
   wirujące kółko, na czas wysyłki. CF7 6.x samo ustawia
   data-status="submitting" na <form> podczas AJAX-a (i z powrotem na
   mail-sent/mail-failed/validation-failed po odpowiedzi) - nie trzeba do
   tego żadnego JS. [submit] renderuje się jako <input>, który nie wspiera
   ::after/generated content ani dzieci - stąd kółko jako background-image
   (samoanimujące się SVG z <animateTransform>, nie CSS @keyframes - tego
   drugiego tło i tak by nie odtworzyło). */
.newsletter-form .wpcf7-spinner {
  display: none;
}

.newsletter-form .wpcf7-form[data-status="submitting"] input.wpcf7-submit {
  color: transparent;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8' fill='none' stroke='rgba(255,255,255,0.35)' stroke-width='3'/%3E%3Cpath d='M10 2 A8 8 0 0 1 18 10' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 10 10' to='360 10 10' dur='0.6s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

/* Od lg formularz z polem "Imię" jest zwarty jak przed jego dodaniem - na
   końcu pliku, żeby wygrać z regułami bazowymi o tej samej wadze. */
@media (min-width: 1024px) {
  .formularz-newsletter .newsletter-panel .wysiwyg-field {
    margin-bottom: 24px;
  }

  .newsletter-form .wpcf7-form {
    row-gap: 12px;
  }

  .newsletter-form .nl-name-field label {
    gap: 8px;
  }
}
