/*
  Contact Form Component CSS
  - Strictly Vanilla CSS
  - Mobile First approach with modern @media syntax
  - Premium look and feel matching Tunet B2B guidelines
*/

/* ── Dialog Base & Backdrop ── */
.tu-dialog {
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 12px;
  background-color: #ffffff;
  width: 90%;
  max-width: 720px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  color: #2c2c2c;
  font-family: var(--tu-font-main, "Manrope", sans-serif);

  /* Micro-animation transitions */
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tu-dialog[open] {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.tu-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tu-dialog[open]::backdrop {
  opacity: 1;
}

/* ── Dialog Inner Layout ── */
.tu-dialog__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 94vh; /* Fallback for older browsers */
  max-height: 92dvh; /* Dynamic viewport height to account for mobile toolbars */

  /* Form tek ekrana sığacak şekilde ölçüldü (375px telefon ve MacBook viewport'u);
     overflow yalnızca yatay telefon gibi uç durumlar için emniyet supabı. */
  overflow-y: auto;
}

/* ── Header ── */
.tu-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 8px 10px 20px;
  border-bottom: 1px solid var(--tu-hairline);
  background-color: var(--tu-cream);

  position: sticky;
  top: 0;
  z-index: 1;

  /* 500px: bileşen kısıtı — dialog dar telefonlarda daha az padding alıyor */
  @media (width >= 500px) {
    padding: 16px 24px;
  }

  @media (width >= 768px) {
    padding: 20px 40px;
  }
}

.tu-dialog__titles {
  padding-right: 16px;
}

/* Ölçü ortak .tu-u-heading/.tu-h4 ölçeğinden gelir; burada yalnız renk/boşluk. */
.tu-dialog__title.tu-u-heading {
  color: #d2160f;
  margin-bottom: 0;
}

/* Açıklama metni yalnızca masaüstünde ve yalnızca yer varsa. Mobilde form tek
   ekrana ancak sığıyor, bu satır oradan yer çalıyordu; boşluğu da display:none
   ile birlikte gidiyor.

   740px yükseklik koşulu bir bileşen kısıtı (bkz. AGENTS.md §10): açıklama
   ~48px ekliyor ve kısa masaüstü pencerelerinde (yer imi çubuğu + dock) formu
   tek ekrandan taşırıyordu. Yükseklik yetmiyorsa metin düşer, form sığmaya
   devam eder — müşterinin asıl şartı bu. */
.tu-dialog__desc.tu-u-caption {
  display: none;
  color: #555555;
  margin: 0;

  @media (width >= 768px) and (height >= 740px) {
    display: block;
    margin-top: 6px;
  }
}

.tu-dialog__close {
  background: none;
  border: none;
  color: #888888;
  cursor: pointer;
  padding: 4px;
  margin-top: -4px;
  margin-right: -4px;
  transition: color 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;

  &:hover {
    color: #d2160f;
    transform: rotate(90deg);
  }
}

/* ── Form Body ── */
.tu-form {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;

  @media (width >= 768px) {
    padding: 20px 40px 22px;
    gap: 18px;
  }
}

/* Intent Selection (Custom Radio Tabs) */
.tu-form__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tu-form__section-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #888;
  text-transform: uppercase;
  margin: 0;
}

/* Dört kart 375px'te üç satıra sarıyor ve formu tek ekrandan taşırıyordu:
   640px altında aynı seçenekler dropdown'dan sunuluyor (bkz. .tu-form__intent-select).
   Radio'lar DOM'da kalır — display:none bir input'un POST edilmesini engellemez. */
.tu-form__intent-group {
  display: none;

  @media (width >= 640px) {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

/* Mobil dropdown: seçili radio kartının görsel diliyle aynı (kırmızı çerçeve + açık zemin).
   `name` özniteliği yok, form.js radio grubuyla iki yönlü senkronlar. */
.tu-form__intent-select {
  appearance: none;
  width: 100%;
  padding: 11px 38px 11px 14px;
  font-family: var(--tu-font-main, "Manrope", sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: #d2160f;
  background-color: #fff5f5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M1 1L7 7L13 1' stroke='%23d2160f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: 2px solid #d2160f;
  border-radius: 8px;
  cursor: pointer;

  &:focus-visible {
    outline: 2px solid #d2160f;
    outline-offset: 2px;
  }

  @media (width >= 640px) {
    display: none;
  }
}

.tu-form__intent-item {
  position: relative;
  display: flex;
}

.tu-form__intent-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Grup yalnızca 640px ve üzerinde görünür, dolayısıyla tek bir stil yeterli:
   ikon + metin yan yana, tek satırlık kart. */
.tu-form__intent-btn {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;

  background-color: #fcfbfa;
  border: 2px solid #e8e5dc;
  border-radius: 8px;

  font-weight: 700;
  color: #555;
  cursor: pointer;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  line-height: 1.3;

  &:hover {
    border-color: #d2160f;
    color: #d2160f;
    background-color: #fffcfc;
  }
}

.tu-form__intent-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: transparent;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

/* Checked state styling */
.tu-form__intent-input:checked + .tu-form__intent-btn {
  border-color: #d2160f;
  background-color: #fff5f5;
  color: #d2160f;
  box-shadow: 0 4px 12px rgba(210, 22, 15, 0.08);

  .tu-form__intent-icon {
    background-color: #d2160f;
  }
}

/* Focus visible state */
.tu-form__intent-input:focus-visible + .tu-form__intent-btn {
  outline: 2px solid #d2160f;
  outline-offset: 2px;
}

/* Inputs Grid */
/* Iki kolon mobilde de geçerli: yetkili adı + telefon yan yana durunca form
   375px'te bir ekran boyu kısalıyor. Uzun alanlar --full ile tam satır kalır. */
.tu-form__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;

  @media (width >= 768px) {
    gap: 12px;
  }
}

.tu-form__group {
  display: flex;
  flex-direction: column;
  gap: 4px;

  @media (width >= 768px) {
    gap: 6px;
  }
}

.tu-form__group--full {
  grid-column: span 2;
}

.tu-form__label {
  font-size: 12px;
  font-weight: 700;
  color: #2c2c2c;
  margin: 0;

  @media (width >= 768px) {
    font-size: 13px;
  }
}

.tu-form__required {
  color: #d2160f;
  font-weight: bold;
}

.tu-form__optional {
  font-size: 11px;
  color: #888;
  font-weight: normal;
}

.tu-form__input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

.tu-form__input,
.tu-form__textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--tu-font-main, "Manrope", sans-serif);
  font-size: 13px;
  color: #2c2c2c;
  background-color: #ffffff;
  border: 1px solid #dcd8ce;
  border-radius: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;

  @media (width >= 768px) {
    padding: 12px 16px;
    font-size: 14px;
  }

  &:hover {
    border-color: #b8b2a5;
  }

  &:focus {
    outline: none;
    border-color: #d2160f;
    box-shadow: 0 0 0 3px rgba(210, 22, 15, 0.1);
  }

  &::placeholder {
    color: #aaa;
  }
}

.tu-form__textarea {
  resize: vertical;
  min-height: 46px;
  max-height: 200px;

  @media (width >= 768px) {
    min-height: 50px;
  }
}

/* Invalid field states Triggered by JS */
.tu-form__input.is-invalid,
.tu-form__textarea.is-invalid {
  border-color: #d2160f;
  background-color: #fffcfc;

  &:focus {
    box-shadow: 0 0 0 3px rgba(210, 22, 15, 0.15);
  }
}

.tu-form__feedback {
  font-size: 12px;
  color: #d2160f;
  margin-top: 4px;
  display: none;
  animation: tu-fadeIn 0.2s ease;
}

.tu-form__input.is-invalid ~ .tu-form__feedback,
.tu-form__textarea.is-invalid ~ .tu-form__feedback {
  display: block;
}

/* ── Actions / Submit Button ── */
.tu-form__actions {
  display: flex;
  justify-content: flex-end;
}

.tu-btn--submit {
  position: relative;
  background-color: #d2160f;
  color: #ffffff;
  font-family: var(--tu-font-main, "Manrope", sans-serif);
  font-size: 13px;
  font-weight: 800;
  padding: 11px 28px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  @media (width >= 768px) {
    font-size: 14px;
    padding: 14px 40px;
    min-width: 180px;
  }

  &:hover:not(:disabled) {
    background-color: #b0120d;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(210, 22, 15, 0.2);
  }

  &:active:not(:disabled) {
    transform: translateY(0);
  }

  &:disabled {
    opacity: 0.8;
    cursor: default;
  }
}

.tu-btn__loader {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tu-btn--submit.is-loading {
  .tu-btn__text {
    opacity: 0;
  }
  .tu-btn__loader {
    opacity: 1;
    visibility: visible;
  }
}

/* Spinner SVG animation */
.tu-spinner {
  animation: tu-rotate 2s linear infinite;
  width: 24px;
  height: 24px;

  .path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: tu-dash 1.5s ease-in-out infinite;
  }
}

@keyframes tu-rotate {
  100% { transform: rotate(360deg); }
}

@keyframes tu-dash {
  0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

@keyframes tu-fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Success View Overlay ── */
.tu-dialog__success {
  position: absolute;
  inset: 0;
  background-color: #ffffff;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.tu-dialog__success.is-visible {
  opacity: 1;
  visibility: visible;
}

.tu-success-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 440px;
}

.tu-success-card__icon {
  margin-bottom: 20px;
  animation: tu-scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Önceden mobilde 28px, masaüstünde 22px'e düşüyordu; ölçek artık ortak. */
.tu-success-card__title.tu-u-heading {
  color: #2E7D32;
  margin-bottom: 12px;
}

.tu-success-card__desc.tu-u-caption {
  color: #555555;
  margin-bottom: 28px;
}

.tu-btn--success-close {
  background-color: #f1ede1;
  color: #2c2c2c;
  font-family: var(--tu-font-main, "Manrope", sans-serif);
  font-size: 13px;
  font-weight: 800;
  padding: 12px 32px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background-color: #e2dcce;
  }
}

@keyframes tu-scaleIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
