/**
 * Callback Request Widget — Scoped Styles
 * All classes prefixed with .cbw- to avoid conflicts with existing page CSS.
 */

/* ─── Overlay ──────────────────────────────────────────── */
.cbw-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cbw-overlay.cbw-open {
  display: flex;
  opacity: 1;
}

/* ─── Modal card ───────────────────────────────────────── */
.cbw-modal {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  font-family: 'Montserrat', 'Lato', Arial, sans-serif;
  box-sizing: border-box;
  animation: cbw-slide-up 0.28s ease;
}

@keyframes cbw-slide-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─── Close button ─────────────────────────────────────── */
.cbw-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #888;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.cbw-close:hover {
  background: #f0f0f0;
  color: #333;
}

/* ─── Header ───────────────────────────────────────────── */
.cbw-header {
  text-align: center;
  margin-bottom: 24px;
}

.cbw-icon {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 10px;
}

.cbw-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 6px;
  line-height: 1.3;
}

.cbw-subtitle {
  font-size: 13.5px;
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* ─── Form ─────────────────────────────────────────────── */
.cbw-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cbw-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cbw-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #444;
  letter-spacing: 0.02em;
}

.cbw-input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  color: #1a1a1a;
  background: #fafafa;
}

.cbw-input:focus {
  border-color: var(--cbw-primary, #ad4e06);
  box-shadow: 0 0 0 3px var(--cbw-primary-shadow, rgba(173, 78, 6, 0.12));
  background: #fff;
  outline: none;
}

.cbw-input::placeholder {
  color: #bbb;
}

/* ─── Phone row ────────────────────────────────────────── */
.cbw-phone-row {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  /* NO overflow:hidden — it clips the dropdown panel */
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.cbw-phone-row:focus-within {
  border-color: var(--cbw-primary, #ad4e06);
  box-shadow: 0 0 0 3px var(--cbw-primary-shadow, rgba(173, 78, 6, 0.12));
  background: #fff;
}

/* ─── Country code — custom searchable dropdown ─────────── */
.cbw-cc-wrap {
  position: relative;
  flex-shrink: 0;
}

.cbw-cc-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  height: 100%;
  width: 72px;
  flex-shrink: 0;
  background: #f4f4f4;
  border: none;
  border-right: 1.5px solid #ddd;
  border-radius: 6px 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s;
  outline: none;
  text-align: center;
}

.cbw-cc-trigger:hover {
  background: #ebebeb;
}

.cbw-cc-arrow {
  font-size: 10px;
  color: #888;
  line-height: 1;
  margin-top: 1px;
}

/* Panel — absolute positioned below trigger */
.cbw-cc-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 99999;
  background: #fff;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  width: 240px;
  overflow: hidden;
}

.cbw-cc-search {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: none;
  border-bottom: 1px solid #eee;
  outline: none;
  font-family: inherit;
  color: #333;
  box-sizing: border-box;
  background: #fafafa;
}

.cbw-cc-search::placeholder {
  color: #bbb;
}

.cbw-cc-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 210px;
  /* ~5 items visible */
  overflow-y: auto;
  overscroll-behavior: contain;
}

.cbw-cc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  color: #333;
  transition: background 0.1s;
  outline: none;
}

.cbw-cc-item-flag {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}

.cbw-cc-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cbw-cc-item-code {
  font-weight: 700;
  color: #555;
  flex-shrink: 0;
}

.cbw-cc-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: #aaa;
  text-align: center;
  cursor: default;
}

/* Mobile: panel goes full width of phone row */
@media (max-width: 480px) {
  .cbw-cc-panel {
    width: 220px;
  }
}

.cbw-phone-input {
  border: none !important;
  border-radius: 0 6px 6px 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  flex: 1;
  min-width: 0;
}

.cbw-phone-input:focus {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* ─── OTP input ────────────────────────────────────────── */
.cbw-otp-input {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.35em;
  padding: 12px 14px;
}

/* ─── Field error ──────────────────────────────────────── */
.cbw-field-error {
  font-size: 12px;
  color: #d32f2f;
  display: none;
}

/* ─── Step error banner ────────────────────────────────── */
.cbw-error {
  display: none;
  padding: 10px 14px;
  background: #fff3f3;
  border: 1px solid #f5c6c6;
  border-radius: 8px;
  font-size: 13px;
  color: #c00;
  line-height: 1.4;
}

/* ─── Primary button ───────────────────────────────────── */
.cbw-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, opacity 0.15s;
  min-height: 48px;
}

.cbw-btn-primary {
  background: var(--cbw-primary, #ad4e06);
  color: #ffffff;
  width: 100%;
}

.cbw-btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ─── Spinner ──────────────────────────────────────────── */
.cbw-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cbw-spin 0.7s linear infinite;
  position: absolute;
}

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

/* ─── Consent checkbox ───────────────────────────────────── */
.cbw-consent-field {
  gap: 6px;
}

.cbw-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  color: #555;
  cursor: pointer;
  line-height: 1.5;
  font-weight: 400;
}

.cbw-consent-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  cursor: pointer;
  accent-color: var(--cbw-primary, #ad4e06);
}

/* ─── Disclaimer ───────────────────────────────────────── */
.cbw-disclaimer {
  font-size: 11.5px;
  color: #999;
  text-align: center;
  margin: 10px 0 0;
  line-height: 1.4;
}

/* ─── Resend row ───────────────────────────────────────── */
.cbw-resend-row {
  text-align: center;
  margin-top: 14px;
}

.cbw-resend-timer {
  font-size: 13px;
  color: #888;
}

.cbw-resend-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--cbw-primary, #ad4e06);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cbw-resend-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Back button ──────────────────────────────────────── */
.cbw-back-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--cbw-primary, #ad4e06);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── Step visibility ──────────────────────────────────── */
.cbw-hidden {
  display: none !important;
}

/* ─── Success screen ───────────────────────────────────── */
.cbw-success {
  text-align: center;
  padding: 16px 0 8px;
}

.cbw-success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--cbw-primary, #ad4e06);
  color: var(--cbw-primary, #ad4e06);
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.cbw-success .cbw-title {
  margin-bottom: 10px;
}

.cbw-success .cbw-subtitle {
  font-size: 14px;
}

/* ─── Mobile ───────────────────────────────────────────── */
@media (max-width: 480px) {

  /* Position dialog at top on mobile so keyboard doesn't hide content */
  .cbw-overlay {
    align-items: flex-start;
    padding-top: 20px;
    overflow-y: auto;
  }

  .cbw-modal {
    padding: 24px 18px 22px;
    border-radius: 14px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }

  .cbw-title {
    font-size: 18px;
  }

  .cbw-btn {
    font-size: 14px;
    padding: 12px 16px;
  }

  .cbw-otp-input {
    font-size: 20px;
    letter-spacing: 0.3em;
  }
}

/* ─── Floating button ─────────────────────────────────────── */
.cbw-float {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cbw-primary, #ad4e06);
  color: #fff;
  border: none;
  border-radius: 56px;
  padding: 14px 22px 14px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Montserrat', 'Lato', Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.cbw-float:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}

.cbw-float:active {
  transform: translateY(0);
}

.cbw-float-icon {
  font-size: 20px;
  line-height: 1;
}

.cbw-float-label {
  /* visible on desktop; hidden on smallest screens */
}

/* On mobile: pill button, icon only to save space */
@media (max-width: 480px) {
  .cbw-float {
    bottom: 20px;
    right: 20px;
    padding: 14px 16px;
    border-radius: 50px;
    gap: 8px;
    font-size: 14px;
  }
}

/* Pulse animation to draw attention on first visit */
.cbw-float-pulse {
  animation: cbw-pulse 2.5s ease-in-out 3;
}

@keyframes cbw-pulse {

  0%,
  100% {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  }

  50% {
    box-shadow: 0 6px 32px var(--cbw-primary-glow, rgba(173, 78, 6, 0.55)), 0 0 0 8px var(--cbw-primary-shadow, rgba(173, 78, 6, 0.12));
  }
}