/* =========================================================
   message-modal.css — Universal contact form modal
   Uses existing site CSS variables. No new color system.
   ========================================================= */

/* ── Overlay ─────────────────────────────────────────────── */
.mm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 25, 20, 0.54);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 280ms step-end;
  overscroll-behavior: contain;
}

.mm-overlay.mm--open {
  opacity: 1;
  visibility: visible;
  transition: opacity 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0ms;
}

/* ── Dialog ──────────────────────────────────────────────── */
.mm-dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-white, #ffffff);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(10, 40, 30, 0.22),
              0 4px 16px rgba(10, 40, 30, 0.1);
  transform: scale(0.94) translateY(10px);
  transition: transform 300ms cubic-bezier(0.34, 1.32, 0.64, 1);
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border, #ebebeb) transparent;
}

.mm-overlay.mm--open .mm-dialog {
  transform: scale(1) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .mm-overlay,
  .mm-overlay.mm--open,
  .mm-dialog,
  .mm-overlay.mm--open .mm-dialog {
    transition: none;
  }
}

/* ── Header ──────────────────────────────────────────────── */
.mm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.75rem 1.75rem 0;
}

.mm-header__titles {
  flex: 1;
}

.mm-header__eyebrow {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-color, #d7b39a);
  margin-bottom: 0.375rem;
}

.mm-header__title {
  margin: 0;
  font-size: clamp(1.125rem, 2.5vw, 1.375rem);
  font-weight: 700;
  color: var(--color-primary, #155945);
  line-height: 1.25;
}

.mm-header__sub {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-light, #787878);
  line-height: 1.5;
}

.mm-header__contacts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.625rem;
}

.mm-header__contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 0.18s;
  min-height: 28px;
}

.mm-header__contact-link--phone {
  color: var(--color-primary, #155945);
}

.mm-header__contact-link--phone:hover {
  color: #1b7059;
}

.mm-header__contact-link--tg {
  color: #229ed9;
}

.mm-header__contact-link--tg:hover {
  color: #1a8bbf;
}

/* ── Close button ────────────────────────────────────────── */
.mm-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border, #ebebeb);
  background: var(--color-gray-bg, #f2f2f2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light, #787878);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  padding: 0;
  margin-top: 2px;
}

.mm-close:hover,
.mm-close:focus-visible {
  background: var(--color-primary, #155945);
  color: var(--color-white, #fff);
  border-color: var(--color-primary, #155945);
  outline: none;
}

.mm-close svg {
  pointer-events: none;
}

/* ── Body ────────────────────────────────────────────────── */
.mm-body {
  padding: 1.5rem 1.75rem 1.75rem;
}

/* ── Form fields ─────────────────────────────────────────── */
.mm-field {
  position: relative;
  margin-bottom: 1rem;
}

.mm-field:last-of-type {
  margin-bottom: 0;
}

.mm-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-light, #787878);
  margin-bottom: 0.375rem;
  letter-spacing: 0.04em;
  transition: color 0.18s;
}

.mm-field:focus-within .mm-label {
  color: var(--color-primary, #155945);
}

.mm-input,
.mm-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-family: var(--font-main, 'Inter', sans-serif);
  color: var(--color-text-main, #000);
  background: var(--color-bg-light, #fff5f0);
  border: 1.5px solid var(--color-border, #ebebeb);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.mm-input::placeholder,
.mm-textarea::placeholder {
  color: #aaa;
}

.mm-input:hover,
.mm-textarea:hover {
  border-color: #ccc;
}

.mm-input:focus,
.mm-textarea:focus {
  border-color: var(--color-primary, #155945);
  background: var(--color-white, #fff);
  box-shadow: 0 0 0 3px rgba(21, 89, 69, 0.12);
}

.mm-input.mm--error,
.mm-textarea.mm--error {
  border-color: #e05252;
  background: #fff8f8;
}

.mm-input.mm--error:focus,
.mm-textarea.mm--error:focus {
  box-shadow: 0 0 0 3px rgba(224, 82, 82, 0.12);
}

.mm-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.55;
}

.mm-field-error {
  display: block;
  font-size: 0.75rem;
  color: #e05252;
  margin-top: 0.3rem;
  min-height: 1em;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s, transform 0.18s;
}

.mm-field-error.mm--show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Optional badge ──────────────────────────────────────── */
.mm-label__opt {
  font-weight: 400;
  color: #bbb;
  font-size: 0.7rem;
  margin-left: 0.25rem;
  letter-spacing: 0;
}

/* ── Consent row ─────────────────────────────────────────── */
.mm-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--color-border, #ebebeb);
}

.mm-consent__input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--color-primary, #155945);
  cursor: pointer;
}

.mm-consent__label {
  font-size: 0.75rem;
  color: var(--color-text-light, #787878);
  line-height: 1.5;
  cursor: pointer;
}

.mm-consent__label a {
  color: var(--color-primary, #155945);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mm-consent.mm--error .mm-consent__label {
  color: #e05252;
}

.mm-consent-error {
  display: block;
  font-size: 0.75rem;
  color: #e05252;
  margin-top: 0.25rem;
  opacity: 0;
  transition: opacity 0.18s;
}

.mm-consent-error.mm--show {
  opacity: 1;
}

/* ── Submit button ───────────────────────────────────────── */
.mm-submit {
  width: 100%;
  margin-top: 1.125rem;
  padding: 0.9375rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font-main, 'Inter', sans-serif);
  letter-spacing: 0.06em;
  color: var(--color-white, #fff);
  background: var(--color-primary, #155945);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.mm-submit:hover:not(:disabled) {
  background: #1b7359;
  box-shadow: 0 6px 20px rgba(21, 89, 69, 0.25);
}

.mm-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.mm-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Loading spinner inside button */
.mm-submit__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mm-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.mm-submit.mm--loading .mm-submit__spinner {
  display: block;
}

@keyframes mm-spin {
  to { transform: rotate(360deg); }
}

/* ── Success screen ──────────────────────────────────────── */
.mm-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1.75rem 2.75rem;
  gap: 0.75rem;
}

.mm-success.mm--show {
  display: flex;
}

.mm-success__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(21, 89, 69, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  animation: mm-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

.mm-success__icon svg {
  color: var(--color-primary, #155945);
}

.mm-success__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary, #155945);
}

.mm-success__text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-light, #787878);
  max-width: 320px;
  line-height: 1.55;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Sheet slides up from bottom */
  .mm-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .mm-dialog {
    max-width: 100%;
    max-height: 94dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    /* iOS safe area — bottom home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mm-overlay.mm--open .mm-dialog {
    transform: translateY(0);
  }

  /* Drag handle hint */
  .mm-dialog::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border, #e0e0e0);
    margin: 0.75rem auto 0;
    flex-shrink: 0;
  }

  .mm-header {
    padding: 0.75rem 1.25rem 0;
  }

  .mm-header__title {
    font-size: 1.125rem;
  }

  /* Contacts stack nicely on narrow screens */
  .mm-header__contacts {
    gap: 0.375rem 0.875rem;
    margin-top: 0.5rem;
  }

  .mm-header__contact-link {
    font-size: 0.875rem;
    /* Larger tap target without extra visual size */
    padding: 4px 0;
    min-height: 36px;
  }

  .mm-body {
    padding: 1.125rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  /* Prevent iOS auto-zoom on focus (needs ≥16px) */
  .mm-input,
  .mm-textarea {
    font-size: 1rem;
  }

  /* Shorter textarea saves vertical space */
  .mm-textarea {
    min-height: 80px;
  }

  /* Bigger submit tap target */
  .mm-submit {
    min-height: 52px;
    font-size: 1rem;
  }

  .mm-success {
    padding: 2rem 1.25rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
  }

  .mm-close {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 360px) {
  .mm-header {
    padding: 0.625rem 1rem 0;
  }

  .mm-body {
    padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }

  .mm-header__contact-link {
    font-size: 0.8125rem;
  }
}
