/* ==========================================================================
  AIclinics Popup  Premium modal
  ========================================================================== */

/* --- Overlay --- */
.aic-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,12,16,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aic-popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* --- Popup Container --- */
.aic-popup {
  position: relative;
  max-width: 440px;
  width: 92%;
  background: #fff;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 0 0 1px rgba(255,255,255,.08);
  transform: translateY(24px) scale(.97);
  opacity: 0;
  transition: transform .4s cubic-bezier(.16,1,.3,1), opacity .3s ease;
  overflow: hidden;
}

.aic-popup-overlay.active .aic-popup {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Gradient accent top bar */
.aic-popup::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #09CA8F, #08AB79, #06d6a0);
  z-index: 2;
}

/* --- Close Button --- */
.aic-popup__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0,0,0,.05);
  color: #888;
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: background .2s, color .2s, transform .15s;
  padding: 0;
  z-index: 3;
}

.aic-popup__close:hover {
  background: rgba(0,0,0,.1);
  color: #333;
  transform: scale(1.08);
}

/* --- Popup Header --- */
.aic-popup__header {
  padding: 32px 28px 0;
  text-align: center;
}

/* Calendar icon */
.aic-popup__header::before {
  content: '';
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, rgba(9,202,143,.12), rgba(9,202,143,.05));
  border-radius: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='%2309CA8F' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 26px;
}

.aic-popup__title {
  font-size: 22px;
  font-weight: 800;
  color: #1a1a1a;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.aic-popup__subtitle {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
  margin: 0;
}

/* --- Popup Content --- */
.aic-popup__content {
  padding: 20px 28px 28px;
  line-height: 1.6;
}

.aic-popup__content > p {
  margin: 0 0 12px;
}

/* --- CF7 Form Styling --- */

/* Kill CF7 default p/br layout, use flex column */
.aic-popup__content .wpcf7-form > p {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
}

.aic-popup__content .wpcf7-form > p > br {
  display: none;
}

/* Wrap each field */
.aic-popup__content .wpcf7-form-control-wrap {
  display: block;
  position: relative;
}

/* Gap between consecutive wraps inside same <p> */
.aic-popup__content .wpcf7-form-control-wrap + .wpcf7-form-control-wrap {
  margin-top: 14px;
}

/* Gap between field and submit when in same <p> */
.aic-popup__content .wpcf7-form-control-wrap + input[type="submit"],
.aic-popup__content .wpcf7-form-control-wrap + .wpcf7-submit {
  margin-top: 18px;
}

/* Inputs */
.aic-popup__content .wpcf7-form input[type="text"],
.aic-popup__content .wpcf7-form input[type="email"],
.aic-popup__content .wpcf7-form input[type="tel"],
.aic-popup__content .wpcf7-form textarea,
.aic-popup__content .wpcf7-form .wpcf7-mask {
  width: 100%;
  padding: 14px 18px;
  border: 1.5px solid #e2e5ea;
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  color: #1a1a1a;
  background: #fff;
  outline: none;
  transition: border-color .25s, box-shadow .25s, background .25s;
  -webkit-appearance: none;
  box-sizing: border-box;
  margin-bottom: 0;
}

/* Fallback spacing: if fields are siblings (no wraps) */
.aic-popup__content .wpcf7-form input[type="text"] + input,
.aic-popup__content .wpcf7-form input[type="text"] + textarea,
.aic-popup__content .wpcf7-form input[type="tel"] + input,
.aic-popup__content .wpcf7-form input[type="tel"] + textarea,
.aic-popup__content .wpcf7-form input[type="email"] + input,
.aic-popup__content .wpcf7-form input[type="email"] + textarea {
  margin-top: 14px;
}

.aic-popup__content .wpcf7-form input:focus,
.aic-popup__content .wpcf7-form textarea:focus {
  border-color: var(--primary-color, #09CA8F);
  box-shadow: 0 0 0 4px rgba(9,202,143,.1);
  background: #fff;
}

.aic-popup__content .wpcf7-form input::placeholder,
.aic-popup__content .wpcf7-form textarea::placeholder {
  color: #b0b5be;
  font-weight: 400;
}

/* Textarea smaller in popup */
.aic-popup__content .wpcf7-form textarea {
  min-height: 80px;
  max-height: 120px;
  resize: vertical;
}

/* Submit button */
.aic-popup__content .wpcf7-form input[type="submit"],
.aic-popup__content .wpcf7-form .wpcf7-submit {
  width: 100%;
  padding: 15px 24px;
  background: linear-gradient(135deg, #09CA8F, #08AB79);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, filter .2s;
  box-shadow: 0 4px 16px rgba(9,202,143,.3);
  letter-spacing: 0.01em;
  -webkit-appearance: none;
  margin-top: 8px;
}

.aic-popup__content .wpcf7-form input[type="submit"]:hover,
.aic-popup__content .wpcf7-form .wpcf7-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(9,202,143,.35);
  filter: brightness(1.05);
}

.aic-popup__content .wpcf7-form input[type="submit"]:active,
.aic-popup__content .wpcf7-form .wpcf7-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(9,202,143,.2);
}

/* Privacy text inside form */
.aic-popup__content .wpcf7-form > p:last-of-type:not(:first-of-type) {
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  line-height: 1.5;
  margin-top: 4px;
}

.aic-popup__content .wpcf7-form > p:last-of-type:not(:first-of-type) a {
  color: var(--primary-color, #09CA8F);
  text-decoration: underline;
  text-decoration-color: rgba(9,202,143,.3);
  transition: text-decoration-color .2s;
}

.aic-popup__content .wpcf7-form > p:last-of-type:not(:first-of-type) a:hover {
  text-decoration-color: var(--primary-color, #09CA8F);
}

/* CF7 validation */
.aic-popup__content .wpcf7-not-valid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.08) !important;
}

.aic-popup__content .wpcf7-not-valid-tip {
  font-size: 12px;
  color: #ef4444;
  margin-top: 2px;
  display: block;
}

.aic-popup__content .wpcf7-response-output {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  border: none;
  text-align: center;
}

.aic-popup__content .wpcf7-mail-sent-ok,
.aic-popup__content .wpcf7 form.sent .wpcf7-response-output {
  background: rgba(9,202,143,.08);
  color: #059669;
}

.aic-popup__content .wpcf7-validation-errors,
.aic-popup__content .wpcf7 form.invalid .wpcf7-response-output {
  background: #fef2f2;
  color: #dc2626;
}

/* Spinner */
.aic-popup__content .wpcf7-spinner {
  margin: 8px auto 0;
  display: block;
}

/* Hide fieldset border (CF7 hidden fields) */
.aic-popup__content .wpcf7-form fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

/* ==========================================================================
  MOBILE: Bottom Sheet
  ========================================================================== */
@media (max-width: 767px) {
  .aic-popup-overlay {
    align-items: flex-end;
  }

  .aic-popup {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .aic-popup-overlay.active .aic-popup {
    transform: translateY(0);
  }

  /* Drag handle */
  .aic-popup::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 10px auto 0;
    position: relative;
    z-index: 3;
  }

  .aic-popup__header {
    padding: 16px 20px 0;
  }

  .aic-popup__header::before {
    width: 44px;
    height: 44px;
    margin-bottom: 10px;
  }

  .aic-popup__content {
    padding: 16px 20px 24px;
  }

  .aic-popup__title {
    font-size: 20px;
  }

  .aic-popup__content .wpcf7-form input[type="text"],
  .aic-popup__content .wpcf7-form input[type="email"],
  .aic-popup__content .wpcf7-form input[type="tel"],
  .aic-popup__content .wpcf7-form textarea,
  .aic-popup__content .wpcf7-form .wpcf7-mask {
    padding: 12px 14px;
    font-size: 16px; /* prevents iOS zoom */
  }

  /* Safe area for bottom sheet */
  .aic-popup__content {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
  REDUCED MOTION
  ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .aic-popup-overlay,
  .aic-popup {
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
  SOCIAL TOAST (after CF7 form submit)
  ========================================================================== */
.aic-social-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .4s ease, transform .4s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}

.aic-social-toast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.aic-social-toast__inner {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
  max-width: 320px;
}

.aic-social-toast__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: color .2s;
}

.aic-social-toast__close:hover {
  color: #333;
}

.aic-social-toast__text {
  font-size: 14px;
  line-height: 1.5;
  color: #444;
  margin: 0 0 14px;
  padding-right: 20px;
}

.aic-social-toast__links {
  display: flex;
  gap: 10px;
}

.aic-social-toast__links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #f5f5f7;
  transition: background .2s, transform .15s;
}

.aic-social-toast__links a:hover {
  background: #eee;
  transform: translateY(-2px);
}

@media (max-width: 767px) {
  .aic-social-toast {
    bottom: 80px;
    right: 16px;
    left: 16px;
  }

  .aic-social-toast__inner {
    max-width: 100%;
  }
}
