/* ============================================================
   DASTAGIR MACHINES — Brochure Lead Form Modal
   Scoped to .bm-* namespace. Uses Dastagir design tokens only.
   ============================================================ */

/* ── Backdrop ────────────────────────────────────────────── */
.bm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.bm-backdrop.is-open { opacity: 1; }
.bm-backdrop[hidden] { display: none !important; }

/* ── Dialog ──────────────────────────────────────────────── */
.bm-dialog {
  background: var(--c-n0);
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.22s ease;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.12);
}
.bm-backdrop.is-open .bm-dialog { transform: translateY(0); }

/* ── Header ──────────────────────────────────────────────── */
.bm-header {
  padding: 28px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.bm-header__titles { flex: 1; }
.bm-header__eyebrow {
  display: block;
  font-size: var(--t-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-primary);
  margin-bottom: 6px;
}
.bm-header__title {
  font-size: var(--t-xl);
  font-weight: var(--fw-semibold);
  color: var(--c-n100);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}
.bm-header__sub {
  font-size: var(--t-sm);
  color: var(--c-n70);
  margin: 6px 0 0;
  line-height: 1.5;
}

/* ── Close button ────────────────────────────────────────── */
.bm-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--c-n40);
  background: transparent;
  cursor: pointer;
  color: var(--c-n80);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-top: -2px;
}
.bm-close:hover { background: var(--c-n20); color: var(--c-n100); }
.bm-close:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ── Divider ─────────────────────────────────────────────── */
.bm-divider { height: 1px; background: var(--c-n40); margin: 20px 28px 0; }

/* ── Form body ───────────────────────────────────────────── */
.bm-body { padding: 22px 28px 28px; }

/* ── Field group ─────────────────────────────────────────── */
.bm-field { margin-bottom: 18px; }
.bm-field:last-of-type { margin-bottom: 0; }
.bm-label {
  display: block;
  font-size: var(--t-sm);
  font-weight: var(--fw-medium);
  color: var(--c-n100);
  margin-bottom: 6px;
}
.bm-label__req { color: var(--c-primary); margin-left: 2px; }
.bm-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-family: var(--f-body);
  font-size: var(--t-base);
  color: var(--c-n100);
  background: var(--c-n0);
  border: 1px solid var(--c-n60);
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.bm-input:focus { border-color: var(--c-n100); }
.bm-input[aria-invalid="true"], .bm-input.is-invalid { border-color: #e53e3e; }
.bm-input::placeholder { color: var(--c-n70); }

/* ── Phone field ─────────────────────────────────────────── */
.bm-phone-wrap {
  display: flex;
  border: 1px solid var(--c-n60);
  height: 44px;
  transition: border-color 0.15s;
}
.bm-phone-wrap:focus-within { border-color: var(--c-n100); }
.bm-phone-wrap.is-invalid { border-color: #e53e3e; }
.bm-phone-prefix {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  background: var(--c-n20);
  border-right: 1px solid var(--c-n60);
  white-space: nowrap;
  font-size: var(--t-sm);
  font-weight: var(--fw-medium);
  color: var(--c-n100);
  min-width: 86px;
  flex-shrink: 0;
  user-select: none;
}
.bm-phone-prefix__flag { font-size: 1rem; line-height: 1; }
.bm-phone-num {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 12px;
  font-family: var(--f-body);
  font-size: var(--t-base);
  color: var(--c-n100);
  background: var(--c-n0);
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
.bm-phone-num::placeholder { color: var(--c-n70); }

/* ── Country display ─────────────────────────────────────── */
.bm-country-display {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: var(--c-n20);
  border: 1px solid var(--c-n40);
  font-size: var(--t-base);
  color: var(--c-n100);
  cursor: default;
  user-select: none;
}
.bm-country-display__flag { font-size: 1.1rem; line-height: 1; }
.bm-country-display__name { font-weight: var(--fw-medium); flex: 1; }
.bm-country-display__badge { font-size: var(--t-xs); color: var(--c-n70); letter-spacing: 0.03em; }

/* ── Detecting spinner ───────────────────────────────────── */
.bm-country-detecting {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: var(--c-n20);
  border: 1px solid var(--c-n40);
  font-size: var(--t-sm);
  color: var(--c-n70);
}
.bm-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--c-n40);
  border-top-color: var(--c-n80);
  border-radius: 50%;
  animation: bm-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes bm-spin { to { transform: rotate(360deg); } }

/* ── Errors ──────────────────────────────────────────────── */
.bm-error {
  display: block;
  font-size: var(--t-xs);
  color: #e53e3e;
  margin-top: 5px;
  line-height: 1.4;
}

/* ── Submit ──────────────────────────────────────────────── */
.bm-submit {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  background: var(--c-primary);
  color: var(--c-n0);
  border: none;
  font-family: var(--f-body);
  font-size: var(--t-base);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.bm-submit:hover:not(:disabled) { background: var(--c-primary-dark); }
.bm-submit:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.bm-submit:disabled { opacity: 0.65; cursor: not-allowed; }

/* ── API error banner ────────────────────────────────────── */
.bm-api-error {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  font-size: var(--t-sm);
  color: #c53030;
  line-height: 1.5;
  display: none;
}
.bm-api-error.is-visible { display: block; }

/* ── Success state ───────────────────────────────────────── */
.bm-success {
  padding: 36px 28px;
  text-align: center;
  display: none;
}
.bm-success.is-visible { display: block; }
.bm-success__icon { margin: 0 auto 16px; display: block; }
.bm-success__title { font-size: var(--t-xl); font-weight: var(--fw-semibold); color: var(--c-n100); margin-bottom: 8px; }
.bm-success__body { font-size: var(--t-sm); color: var(--c-n70); line-height: 1.6; }

/* ── Privacy note ────────────────────────────────────────── */
.bm-privacy {
  margin-top: 16px;
  font-size: var(--t-xs);
  color: var(--c-n70);
  line-height: 1.55;
  border-top: 1px solid var(--c-n40);
  padding-top: 14px;
}

/* ── Honeypot ────────────────────────────────────────────── */
.bm-honeypot {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .bm-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .bm-dialog {
    max-width: 100%;
    max-height: 95vh;
    transform: translateY(100%);
  }
  .bm-backdrop.is-open .bm-dialog { transform: translateY(0); }
  .bm-header { padding: 24px 20px 0; }
  .bm-divider { margin-left: 20px; margin-right: 20px; }
  .bm-body { padding: 20px 20px 32px; }
}

/* ── RTL ─────────────────────────────────────────────────── */
[dir="rtl"] .bm-phone-prefix { border-right: none; border-left: 1px solid var(--c-n60); }
[dir="rtl"] .bm-header { flex-direction: row-reverse; }
