/* ════════════════════════════════════════════════════════════════════════
   BobrCraft Auth Modal — 10 states (Sign in / Register / Verify / Reset / …)
   Tokens 1:1 з Figma "Create account / Login" section (1682:181871).
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --otam-modal-w: 480px;
  --otam-modal-pad: 24px;
  --otam-modal-radius: 8px;
  --otam-modal-gap: 24px;
  --otam-backdrop: rgba(0, 0, 0, .2);

  --otam-input-border: #DDDDDD;
  --otam-input-border-focus: #131314;
  --otam-input-radius: 8px;
  --otam-input-pad: 12px;
  --otam-input-h: 48px;
  --otam-input-text: #131314;
  --otam-input-placeholder: #7D7D7D;

  --otam-btn-radius: 10px;
  --otam-btn-h: 48px;
  --otam-btn-primary: #392923;
  --otam-btn-primary-hover: #4d382e;
  --otam-btn-primary-text: #FFFFFF;
  --otam-btn-outline-border: #DDDDDD;
  --otam-btn-outline-text: #131314;

  --otam-text: #131314;
  --otam-text-body: #606162;
  --otam-text-muted: #7D7D7D;
  --otam-link: #392923;
}

/* ═══ Backdrop + Modal container ═══ */
.otam-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--otam-backdrop);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: 16px;
}
.otam-backdrop.is-open { display: flex; }
body.otam-open { overflow: hidden; }

.otam-modal {
  width: var(--otam-modal-w);
  max-width: 100%;
  padding: var(--otam-modal-pad);
  background: #FFFFFF;
  border-radius: var(--otam-modal-radius);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--otam-modal-gap);
  box-sizing: border-box;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

/* ═══ Top bar: title + close ═══ */
.otam-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.otam-top__row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.otam-title {
  flex: 1;
  margin: 0;
  font: 500 24px/1.21 'Inter', sans-serif;
  color: var(--otam-text);
}
.otam-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.otam-close:hover { background: rgba(0, 0, 0, .06); }
.otam-close svg { width: 24px; height: 24px; color: var(--otam-text); }

.otam-subtitle {
  margin: 0;
  font: 400 16px/1.375 'Inter', sans-serif;
  color: var(--otam-text-muted);
}

.otam-heading-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.otam-heading {
  margin: 0;
  font: 600 16px/1.375 'Inter', sans-serif;
  color: var(--otam-text);
}

/* ═══ Center state (success / expired) — icon + texts ═══ */
.otam-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.otam-state__icon {
  width: 80px;
  height: 80px;
  display: block;
  flex-shrink: 0;
}
.otam-state__title {
  margin: 0;
  font: 500 24px/1.21 'Inter', sans-serif;
  color: var(--otam-text);
  text-align: center;
}
.otam-state__sub {
  margin: 0;
  font: 400 16px/1.375 'Inter', sans-serif;
  color: var(--otam-text-muted);
  text-align: center;
}

/* ═══ Social row (4 icon-only buttons) ═══ */
.otam-social {
  display: flex;
  align-items: center;
  gap: 8px;
}
.otam-social__btn {
  flex: 1;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border: 1px solid var(--otam-input-border);
  border-radius: var(--otam-input-radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  padding: 0;
  color: var(--otam-text);
  font-size: 18px;
}
.otam-social__btn:hover { border-color: #b5b5b5; background: #fafafa; }
.otam-social__btn svg,
.otam-social__btn i { width: 20px; height: 20px; }

/* ═══ Divider "Or" ═══ */
.otam-or {
  display: flex;
  align-items: center;
  gap: 10px;
}
.otam-or::before,
.otam-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--otam-input-border);
}
.otam-or__label {
  font: 400 16px/1.375 'Inter', sans-serif;
  color: var(--otam-text-muted);
}

/* ═══ Fields container ═══ */
.otam-fields {
  display: flex;
  flex-direction: column;
  gap: 24px;                /* between field blocks (Figma "Sing in" auto-layout gap) */
}
.otam-fields .otam-row--2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.otam-field {
  display: flex;
  flex-direction: column;
  gap: 4px;                 /* label → input = 4px (Figma input component) */
}
.otam-field__label {
  font: 500 16px/1.375 'Inter', sans-serif;
  color: var(--otam-text);
  margin: 0;                /* drop browser-default label margin so 4px gap is exact */
  padding: 0;
  text-transform: none;     /* theme.css may force uppercase on form labels — override */
  letter-spacing: 0;
}
.otam-field__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.otam-field__input {
  width: 100%;
  height: var(--otam-input-h);
  padding: 12px;
  border: 1px solid var(--otam-input-border);
  border-radius: var(--otam-input-radius);
  background: #FFFFFF;
  font: 400 16px/1.375 'Inter', sans-serif;
  color: var(--otam-input-text);
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.otam-field__input::placeholder { color: var(--otam-input-placeholder); }
.otam-field__input:focus { border-color: var(--otam-input-border-focus); }
.otam-field__input:disabled { background: #f6f6f6; color: var(--otam-text-muted); }
.otam-field--err .otam-field__input { border-color: #d33; }
.otam-field__helper {
  font: 400 12px/1.4 'Inter', sans-serif;
  color: var(--otam-text-muted);
  margin-top: 2px;
}
.otam-field__helper--err { color: #d33; }

/* Right icon inside input (eye toggle, flag picker, search) */
.otam-field__input--with-right { padding-right: 44px; }
.otam-field__right-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--otam-text);
}
.otam-field__right-btn svg { width: 24px; height: 24px; }

/* ═══ Phone field — country flag + prefix ═══ */
.otam-phone {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--otam-input-h);
  padding: 0 12px;
  border: 1px solid var(--otam-input-border);
  border-radius: var(--otam-input-radius);
  background: #FFFFFF;
  position: relative;
}
.otam-phone__picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.otam-phone__picker-visual {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  pointer-events: none;        /* clicks pass through to the <select> overlay */
}
/* Native <select> overlay — invisible but fires native dropdown on click anywhere
   within the picker box (flag / +32 / chev). */
.otam-phone__picker > .otam-phone__select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  font: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.otam-phone__prefix {
  display: inline-flex;
  align-items: center;
  height: 100%;
  font: 400 16px/1 'Inter', sans-serif;
  color: var(--otam-input-text);
}
.otam-phone__flag {
  width: 22px;
  height: 16px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  border-radius: 2px;
}
.otam-phone__input {
  flex: 1;
  border: 0;
  outline: 0;
  padding: 0;
  height: 100%;
  font: 400 16px/1 'Inter', sans-serif;
  background: transparent;
  color: var(--otam-input-text);
  min-width: 0;
}
.otam-phone__input::placeholder { color: var(--otam-input-placeholder); }
.otam-phone__chev {
  width: 12px;
  height: 12px;
  color: var(--otam-text-muted);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.otam-phone__chev svg { display: block; width: 12px; height: 12px; }

/* ═══ Forgot row (remember me checkbox + forgot link) ═══ */
.otam-forgot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.otam-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;        /* override global Bootstrap `label { margin-bottom: 20px }` */
  font-weight: 400;        /* same — global label is bold */
  cursor: pointer;
  user-select: none;
  font: 400 14px/1.43 'Inter', sans-serif;
  color: var(--otam-text);
}
.otam-check input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid var(--otam-input-border);
  border-radius: 4px;
  background: #FFFFFF;
  cursor: pointer;
  position: relative;
  margin: 0;
  flex-shrink: 0;
}
.otam-check input[type="checkbox"]:checked {
  background: var(--otam-btn-primary);
  border-color: var(--otam-btn-primary);
}
.otam-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 2px;
  width: 6px; height: 10px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.otam-forgot {
  font: 400 14px/1.43 'Inter', sans-serif;
  color: var(--otam-text);
  text-decoration: none;
  cursor: pointer;
}
.otam-forgot:hover { text-decoration: underline; }

/* ═══ OTP segments (6 single-char inputs) ═══ */
.otam-otp {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.otam-otp__input {
  flex: 1;
  min-width: 0;
  max-width: 56px;
  height: 56px;
  text-align: center;
  font: 600 24px/1 'Inter', sans-serif;
  color: var(--otam-input-text);
  border: 1px solid var(--otam-input-border);
  border-radius: var(--otam-input-radius);
  background: #FFFFFF;
  outline: none;
  padding: 0;
  transition: border-color .15s;
}
.otam-otp__input:focus { border-color: var(--otam-input-border-focus); }
.otam-otp__input.is-filled { border-color: var(--otam-input-border-focus); }

.otam-resend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 400 16px/1.375 'Inter', sans-serif;
  color: var(--otam-text-body);
  justify-content: center;
}
.otam-resend__btn {
  background: 0;
  border: 0;
  padding: 0;
  font: 500 16px/1.375 'Inter', sans-serif;
  color: var(--otam-link);
  cursor: pointer;
  text-decoration: none;
}
.otam-resend__btn:disabled { color: var(--otam-text-muted); cursor: not-allowed; }
.otam-resend__btn:hover:not(:disabled) { text-decoration: underline; }

/* ═══ Actions ═══ */
.otam-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.otam-btn {
  height: var(--otam-btn-h);
  padding: 12px;
  border-radius: var(--otam-btn-radius);
  font: 500 16px/1.25 'Inter', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, border-color .15s, color .15s;
  border: 1px solid transparent;
  width: 100%;
  box-sizing: border-box;
}
.otam-btn--primary {
  background: var(--otam-btn-primary);
  color: var(--otam-btn-primary-text);
}
.otam-btn--primary:hover { background: var(--otam-btn-primary-hover); }
.otam-btn--primary:disabled { opacity: .5; cursor: not-allowed; }
/* ═══ Loading state сабмита (ТЗ FR-14, BR-24): спиннер перед текстом ═══ */
.otam-btn.is-loading { pointer-events: none; }
.otam-btn.is-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: otam-spin .7s linear infinite;
}
@keyframes otam-spin {
  to { transform: rotate(360deg); }
}
.otam-btn--outline {
  background: #FFFFFF;
  border-color: var(--otam-btn-outline-border);
  color: var(--otam-btn-outline-text);
}
.otam-btn--outline:hover { border-color: #b5b5b5; background: #fafafa; }

/* ═══ Bottom footer link ═══ */
.otam-footer-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font: 400 14px/1.43 'Inter', sans-serif;
  color: var(--otam-text-body);
}
.otam-footer-link a {
  font-weight: 500;
  color: var(--otam-link);
  text-decoration: none;
}
.otam-footer-link a:hover { text-decoration: underline; }

/* ═══ Mobile ═══ */
@media (max-width: 575px) {
  /* Mobile: keep modal CENTERED with overlay (not fullscreen page-takeover) so the
     visual model matches desktop and other site popups (.acc-modal). 12px padding
     so the dialog never touches the edge; max-height 92vh allows internal scroll. */
  .otam-backdrop { padding: 12px; background: var(--otam-backdrop); align-items: center; justify-content: center; }
  .otam-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--otam-modal-radius);
    padding: 24px 16px;
  }
  .otam-title { font-size: 22px; }
  .otam-state__title { font-size: 22px; }
}
