/* =============================================================================
   Book Appointment Plugin – ba-style.css
   Version: 1.2.1
   Description: Floating pop-up, modal, inline form, and responsive styles.
   Compatible with: OncoPhysio New Site / oncophysio-newsite-v1.0.0 theme.
   Colour scheme: FAB Button – Purple (#7c3aed). Text: White (#ffffff).
   Plugin Created By: OncoPhysio
   ============================================================================= */

/* ── 1. CSS Custom Properties (Design Tokens) ──────────────────────────────── */
:root {
  /* FAB Button palette – Purple */
  --ba-primary:        #7c3aed;   /* Vivid purple */
  --ba-primary-dark:   #5b21b6;   /* Deep purple for hover */
  --ba-primary-light:  #a78bfa;   /* Light purple for accents */
  --ba-accent:         #f3effe;   /* Pale purple tint background */
  --ba-gradient:       linear-gradient(135deg, #5b21b6 0%, #7c3aed 60%, #a78bfa 100%);

  /* Neutral palette – crisp clinical whites & grays */
  --ba-white:          #ffffff;
  --ba-surface:        #f5f9fa;   /* Near-white with teal warmth */
  --ba-border:         #c8dde1;   /* Soft teal-tinted border */
  --ba-text-primary:   #3b0764;   /* Deep purple dark text */
  --ba-text-secondary: #6d28d9;   /* Mid-purple text */
  --ba-text-muted:     #c4b5fd;   /* Light muted purple */

  /* Error */
  --ba-error:          #c0392b;
  --ba-error-bg:       #fdf3f3;

  /* Success */
  --ba-success:        #1a7a4a;
  --ba-success-bg:     #edfbf4;

  /* FAB */
  --ba-fab-size:       52px;
  --ba-fab-gap:        20px;

  /* Transitions */
  --ba-transition:      all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --ba-transition-fast: all 0.12s ease;

  /* Shadows */
  --ba-shadow-sm:   0 2px 6px rgba(91, 33, 182, 0.08);
  --ba-shadow-md:   0 6px 24px rgba(91, 33, 182, 0.14);
  --ba-shadow-lg:   0 16px 48px rgba(91, 33, 182, 0.20);
  --ba-shadow-fab:  0 5px 20px rgba(91, 33, 182, 0.45);

  /* Z-index layers */
  --ba-z-fab:     99998;
  --ba-z-overlay: 99999;

  /* Border radius */
  --ba-radius-xs:   4px;
  --ba-radius-sm:   6px;
  --ba-radius-md:   10px;
  --ba-radius-lg:   16px;
  --ba-radius-pill: 999px;
}

/* ── 2. Reset / Base ───────────────────────────────────────────────────────── */
.ba-fab,
.ba-modal-overlay,
.ba-modal-container,
.ba-modal-close,
.ba-submit-btn,
.ba-appointment-form *,
.ba-inline-wrapper * {
  box-sizing: border-box;
}

/* ── 3. Floating Action Button (FAB) ───────────────────────────────────────── */
.ba-fab {
  position:       fixed;
  bottom:         var(--ba-fab-gap);
  right:          var(--ba-fab-gap);
  z-index:        var(--ba-z-fab);

  display:        flex;
  align-items:    center;
  gap:            8px;
  padding:        12px 20px 12px 16px;

  background:     var(--ba-gradient);
  color:          #ffffff;
  border:         none;
  border-radius:  var(--ba-radius-pill);
  cursor:         pointer;

  font-family:    inherit;
  font-size:      14px;
  font-weight:    600;
  letter-spacing: 0.01em;
  white-space:    nowrap;
  line-height:    1;

  box-shadow:     var(--ba-shadow-fab);
  transition:     var(--ba-transition);

  animation: ba-fab-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s both;
}

.ba-fab:hover {
  transform:  translateY(-3px) scale(1.03);
  box-shadow: 0 10px 28px rgba(91, 33, 182, 0.55);
  background: var(--ba-primary-dark);
  color:      rgba(255, 255, 255, 0.85); /* keep text visible – slightly dimmed */
}

.ba-fab:active {
  transform:  translateY(-1px) scale(0.99);
  box-shadow: 0 4px 14px rgba(91, 33, 182, 0.40);
  color:      rgba(255, 255, 255, 0.85); /* keep text visible on press */
}

.ba-fab:focus-visible {
  outline:        3px solid var(--ba-primary-light);
  outline-offset: 3px;
}

.ba-fab-icon {
  display:     flex;
  align-items: center;
  flex-shrink: 0;
  width:       20px;
  height:      20px;
}

.ba-fab-icon svg {
  width:  20px;
  height: 20px;
}

.ba-fab-label {
  display: block;
}

/* FAB pulse ring */
.ba-fab::before {
  content:       '';
  position:      absolute;
  inset:         -4px;
  border-radius: var(--ba-radius-pill);
  border:        2px solid var(--ba-primary-light);
  opacity:       0;
  animation:     ba-fab-pulse 2.5s ease-out 1.5s infinite;
}

/* ── 4. Modal Overlay ──────────────────────────────────────────────────────── */
.ba-modal-overlay {
  position:        fixed;
  inset:           0;
  z-index:         var(--ba-z-overlay);
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         12px;

  visibility:  hidden;
  opacity:     0;
  transition:  visibility 0s 0.28s, opacity 0.28s ease;
}

.ba-modal-overlay.ba-is-open {
  visibility: visible;
  opacity:    1;
  transition: visibility 0s, opacity 0.28s ease;
}

/* Backdrop */
.ba-modal-backdrop {
  position:         absolute;
  inset:            0;
  background-color: rgba(10, 28, 34, 0.62);
  backdrop-filter:  blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor:           pointer;
}

/* ── 5. Modal Container ────────────────────────────────────────────────────── */
/*
   COMPACT NO-SCROLL DESIGN:
   – max-height capped at 96vh on desktop so nothing scrolls
   – overflow-y set to visible; inner content is sized to fit
*/
.ba-modal-container {
  position:   relative;
  z-index:    1;
  width:      100%;
  max-width:  440px;
  max-height: 96vh;
  overflow:   hidden;

  background:    var(--ba-white);
  border-radius: var(--ba-radius-lg);
  box-shadow:    var(--ba-shadow-lg);

  transform:  translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.26s ease;
  opacity:    0;

  /* Flex column so inner sections fill available height cleanly */
  display:        flex;
  flex-direction: column;
}

.ba-modal-overlay.ba-is-open .ba-modal-container {
  transform: translateY(0) scale(1);
  opacity:   1;
}

/* ── 6. Modal Header – compact ─────────────────────────────────────────────── */
.ba-modal-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             10px;
  padding:         16px 18px 14px;
  background:      var(--ba-gradient);
  position:        relative;
  overflow:        hidden;
  flex-shrink:     0;
}

/* Subtle decorative circle */
.ba-modal-header::before {
  content:       '';
  position:      absolute;
  width:         160px;
  height:        160px;
  border-radius: 50%;
  background:    rgba(255, 255, 255, 0.06);
  top:           -70px;
  right:         -50px;
}

.ba-modal-header-content {
  display:     flex;
  align-items: flex-start;
  gap:         10px;
  flex:        1;
  position:    relative;
  z-index:     1;
}

.ba-modal-icon {
  flex-shrink:     0;
  width:           36px;
  height:          36px;
  background:      rgba(255, 255, 255, 0.18);
  border-radius:   var(--ba-radius-sm);
  display:         flex;
  align-items:     center;
  justify-content: center;
}

.ba-modal-icon svg {
  width:  18px;
  height: 18px;
  stroke: var(--ba-white);
}

.ba-modal-title-group {
  flex: 1;
}

.ba-modal-title {
  margin:      0 0 3px;
  font-size:   16px;
  font-weight: 700;
  color:       var(--ba-white);
  line-height: 1.2;
}

.ba-modal-subtitle {
  margin:      0;
  font-size:   13.5px;
  font-weight: 600;
  color:       rgba(255, 255, 255, 0.92);
  line-height: 1.45;
}

/* Close button */
.ba-modal-close {
  flex-shrink:     0;
  width:           30px;
  height:          30px;
  background:      rgba(255, 255, 255, 0.20);
  border:          1px solid rgba(255, 255, 255, 0.35);
  border-radius:   var(--ba-radius-xs);
  cursor:          pointer;
  display:         flex;
  align-items:     center;
  justify-content: center;
  position:        relative;
  z-index:         1;
  transition:      var(--ba-transition-fast);
  color:           #ffffff; /* ensures SVG currentColor resolves to white */
}

.ba-modal-close svg {
  width:  16px;
  height: 16px;
  stroke: var(--ba-white);
}

.ba-modal-close:hover {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.60);
  transform:  rotate(90deg);
  color:      #ffffff;
}

.ba-modal-close:focus-visible {
  outline:        2px solid var(--ba-white);
  outline-offset: 2px;
}

/* ── 7. Modal Body – compact ───────────────────────────────────────────────── */
.ba-modal-body {
  padding:    12px 18px 0;
  flex:       1;
  overflow-y: auto;
}

/* ── 8. Modal Footer – compact ─────────────────────────────────────────────── */
.ba-modal-footer {
  padding:    8px 18px 14px;
  flex-shrink: 0;
}

.ba-trust-badges {
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             14px;
  flex-wrap:       wrap;
}

.ba-trust-badge {
  display:     flex;
  align-items: center;
  gap:         4px;
  font-size:   10.5px;
  color:       var(--ba-text-muted);
  font-weight: 500;
}

.ba-trust-badge svg {
  width:  12px;
  height: 12px;
  stroke: var(--ba-primary-light);
}

/* ── 9. Form Styles – compact vertical stack ───────────────────────────────── */
.ba-appointment-form {
  display:        flex;
  flex-direction: column;
  gap:            8px;         /* Tight gap – no scroll */
}

/* Form group */
.ba-form-group {
  display:        flex;
  flex-direction: column;
  gap:            3px;
}

/* Label */
.ba-label {
  font-size:   12px;
  font-weight: 600;
  color:       var(--ba-text-primary);
  line-height: 1.2;
  cursor:      pointer;
}

.ba-required {
  color:       var(--ba-error);
  margin-left: 2px;
}

/* Input wrapper */
.ba-input-wrapper {
  position:    relative;
  display:     flex;
  align-items: center;
}

.ba-input-icon {
  position:      absolute;
  left:          9px;
  top:           50%;
  transform:     translateY(-50%);
  font-size:     14px;
  line-height:   1;
  pointer-events: none;
  user-select:   none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   INPUT FIELD – DEFECT FIX:
   Explicit white background + dark text enforced on ALL states.
   No browser override, no dark-mode auto-fill, no focus colour inversion.
   ───────────────────────────────────────────────────────────────────────────── */
.ba-input {
  width:              100%;
  padding:            9px 10px 9px 34px;
  font-size:          14px;
  font-family:        inherit;
  color:              #13404c !important;          /* Navy dark text – always visible */
  background-color:   #ffffff !important;          /* Pure white – always */
  background:         #ffffff !important;
  border:             1.5px solid var(--ba-border);
  border-radius:      var(--ba-radius-xs);
  outline:            none;
  transition:         border-color 0.15s ease, box-shadow 0.15s ease;
  line-height:        1.3;
  -webkit-appearance: none;
  appearance:         none;

  /* Prevent browser dark-mode from injecting dark backgrounds */
  color-scheme:       light;
}

/* Autofill overrides – some browsers inject yellow/dark bg */
.ba-input:-webkit-autofill,
.ba-input:-webkit-autofill:hover,
.ba-input:-webkit-autofill:focus,
.ba-input:-webkit-autofill:active {
  -webkit-box-shadow:      0 0 0 60px #ffffff inset !important;
  box-shadow:              0 0 0 60px #ffffff inset !important;
  -webkit-text-fill-color: #13404c !important;
  background-color:        #ffffff !important;
}

.ba-input::placeholder {
  color:   #7fa8b0;
  opacity: 1;
}

.ba-input:hover {
  border-color:     var(--ba-primary-light);
  background-color: #ffffff !important;
  color:            #13404c !important;
}

.ba-input:focus {
  border-color:     var(--ba-primary);
  box-shadow:       0 0 0 2.5px rgba(26, 92, 106, 0.18);
  background-color: #ffffff !important;
  color:            #13404c !important;
}

.ba-input.ba-is-invalid {
  border-color:     var(--ba-error);
  box-shadow:       0 0 0 2.5px rgba(192, 57, 43, 0.12);
  background-color: #fdf3f3 !important;
  color:            #13404c !important;
}

.ba-input.ba-is-valid {
  border-color:     var(--ba-primary-light);
  box-shadow:       0 0 0 2.5px rgba(26, 92, 106, 0.12);
  background-color: #ffffff !important;
  color:            #13404c !important;
}

/* Field error message */
.ba-field-error {
  font-size:   11px;
  color:       var(--ba-error);
  font-weight: 500;
  line-height: 1.2;
  min-height:  13px;
  display:     flex;
  align-items: center;
  gap:         3px;
}

.ba-field-error:not(:empty)::before {
  content:   '⚠';
  font-size: 10px;
}

/* ── 10. Custom Checkbox – compact ─────────────────────────────────────────── */
.ba-form-group--checkbox {
  gap: 3px;
}

.ba-checkbox-label {
  display:     flex;
  align-items: flex-start;
  gap:         8px;
  cursor:      pointer;
  line-height: 1;
}

.ba-checkbox-input {
  position: absolute;
  opacity:  0;
  width:    0;
  height:   0;
}

.ba-checkbox-custom {
  flex-shrink:     0;
  width:           16px;
  height:          16px;
  border:          1.5px solid var(--ba-border);
  border-radius:   3px;
  background:      #ffffff;
  display:         flex;
  align-items:     center;
  justify-content: center;
  transition:      var(--ba-transition-fast);
  margin-top:      1px;
  position:        relative;
}

.ba-checkbox-custom::after {
  content:     '';
  width:       4px;
  height:      7px;
  border:      1.5px solid var(--ba-white);
  border-top:  none;
  border-left: none;
  transform:   rotate(45deg) scale(0) translateY(-1px);
  transition:  var(--ba-transition-fast);
  opacity:     0;
}

.ba-checkbox-input:checked ~ .ba-checkbox-custom {
  background:   var(--ba-primary);
  border-color: var(--ba-primary);
}

.ba-checkbox-input:checked ~ .ba-checkbox-custom::after {
  transform: rotate(45deg) scale(1) translateY(-1px);
  opacity:   1;
}

.ba-checkbox-input:focus-visible ~ .ba-checkbox-custom {
  outline:        2px solid var(--ba-primary-light);
  outline-offset: 2px;
}

.ba-checkbox-input.ba-is-invalid ~ .ba-checkbox-custom {
  border-color: var(--ba-error);
  box-shadow:   0 0 0 2.5px rgba(192, 57, 43, 0.12);
}

.ba-checkbox-text {
  font-size:   11.5px;
  color:       var(--ba-text-secondary);
  line-height: 1.35;
  flex:        1;
}

/* ── 11. Global Form Message ───────────────────────────────────────────────── */
.ba-form-message {
  padding:       8px 12px;
  border-radius: var(--ba-radius-xs);
  font-size:     12.5px;
  font-weight:   500;
  line-height:   1.4;
  animation:     ba-message-in 0.22s ease;
}

.ba-form-message.ba-message--success {
  background: var(--ba-success-bg);
  color:      var(--ba-success);
  border:     1px solid rgba(26, 122, 74, 0.22);
}

.ba-form-message.ba-message--error {
  background: var(--ba-error-bg);
  color:      var(--ba-error);
  border:     1px solid rgba(192, 57, 43, 0.22);
}

/* ── 12. Submit Button – teal/navy, no green ───────────────────────────────── */
.ba-form-group--submit {
  margin-top:    3px;
  margin-bottom: 4px;
}

.ba-submit-btn {
  position:        relative;
  width:           100%;
  padding:         11px 20px;
  font-family:     inherit;
  font-size:       14px;
  font-weight:     700;
  color:           #ffffff;
  background:      var(--ba-gradient);
  border:          none;
  border-radius:   var(--ba-radius-xs);
  cursor:          pointer;
  overflow:        hidden;
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             8px;
  letter-spacing:  0.02em;
  transition:      var(--ba-transition);
  box-shadow:      0 3px 12px rgba(19, 64, 76, 0.38);
}

.ba-submit-btn::before {
  content:    '';
  position:   absolute;
  inset:      0;
  background: rgba(255, 255, 255, 0);
  transition: background 0.18s ease;
}

.ba-submit-btn:hover {
  background:  var(--ba-primary-dark);
  transform:   translateY(-2px);
  box-shadow:  0 7px 20px rgba(19, 64, 76, 0.50);
}

.ba-submit-btn:hover::before {
  background: rgba(255, 255, 255, 0.07);
}

.ba-submit-btn:active {
  transform:  translateY(0);
  box-shadow: 0 2px 8px rgba(19, 64, 76, 0.30);
}

.ba-submit-btn:focus-visible {
  outline:        3px solid var(--ba-primary-light);
  outline-offset: 2px;
}

.ba-submit-btn:disabled {
  opacity:   0.65;
  cursor:    not-allowed;
  transform: none;
}

.ba-btn-text {
  position: relative;
  z-index:  1;
}

/* Loading spinner */
.ba-btn-spinner {
  display:  none;
  position: relative;
  z-index:  1;
}

.ba-submit-btn.ba-is-loading .ba-btn-text    { display: none; }
.ba-submit-btn.ba-is-loading .ba-btn-spinner { display: flex; }

.ba-spinner-svg {
  width:     20px;
  height:    20px;
  animation: ba-spin 0.9s linear infinite;
}

.ba-spinner-track { opacity: 0.25; }

.ba-spinner-arc {
  animation:        ba-spin 0.9s linear infinite;
  transform-origin: center;
}

/* ── 13. Inline Form Wrapper ───────────────────────────────────────────────── */
.ba-inline-wrapper {
  background:    var(--ba-white);
  border:        1px solid var(--ba-border);
  border-radius: var(--ba-radius-lg);
  overflow:      hidden;
  box-shadow:    0 6px 28px rgba(19, 64, 76, 0.13);
  max-width:     520px;
  margin:        0 auto;
}

.ba-inline-header {
  background: var(--ba-gradient);
  padding:    22px 28px 18px;
  position:   relative;
  overflow:   hidden;
}

.ba-inline-header::before {
  content:       '';
  position:      absolute;
  width:         160px;
  height:        160px;
  border-radius: 50%;
  background:    rgba(255, 255, 255, 0.05);
  top:           -60px;
  right:         -40px;
}

.ba-inline-title {
  margin:      0 0 5px;
  font-size:   19px;
  font-weight: 700;
  color:       var(--ba-white);
  position:    relative;
}

.ba-inline-subtitle {
  margin:    0;
  font-size: 13px;
  color:     rgba(255, 255, 255, 0.83);
  position:  relative;
}

.ba-inline-wrapper .ba-appointment-form {
  padding: 22px 28px 26px;
}

/* ── 14. Success State ─────────────────────────────────────────────────────── */
.ba-success-display {
  text-align:     center;
  padding:        18px 0 6px;
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            8px;
  animation:      ba-message-in 0.35s ease;
}

.ba-success-icon {
  width:           48px;
  height:          48px;
  background:      var(--ba-success-bg);
  border:          2px solid rgba(26, 122, 74, 0.28);
  border-radius:   50%;
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       24px;
}

.ba-success-title {
  font-size:   16px;
  font-weight: 700;
  color:       var(--ba-primary);
  margin:      0;
}

.ba-success-body {
  font-size:   13px;
  color:       var(--ba-text-secondary);
  margin:      0;
  max-width:   320px;
  line-height: 1.5;
}

/* ── 15. Keyframe Animations ───────────────────────────────────────────────── */

@keyframes ba-fab-enter {
  from { opacity: 0; transform: translateY(20px) scale(0.8); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ba-fab-pulse {
  0%   { opacity: 0.5; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.3); }
  100% { opacity: 0;   transform: scale(1.3); }
}

@keyframes ba-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes ba-message-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 16. Responsive Design ─────────────────────────────────────────────────── */

/* Tablet & Small Desktop (≤ 768px) */
@media (max-width: 768px) {
  :root {
    --ba-fab-gap: 14px;
  }

  .ba-fab-label {
    display: none;
  }

  .ba-fab {
    padding:         0;
    width:           var(--ba-fab-size);
    height:          var(--ba-fab-size);
    justify-content: center;
    border-radius:   50%;
  }

  .ba-fab-icon {
    width:  22px;
    height: 22px;
  }

  .ba-fab-icon svg {
    width:  22px;
    height: 22px;
  }

  /* Slide up from bottom on mobile */
  .ba-modal-overlay {
    align-items: flex-end;
    padding:     0;
  }

  .ba-modal-container {
    max-width:     100%;
    max-height:    94vh;
    border-radius: var(--ba-radius-lg) var(--ba-radius-lg) 0 0;
  }

  .ba-modal-header {
    padding: 14px 16px 12px;
  }

  .ba-modal-body {
    padding: 10px 16px 0;
  }

  .ba-modal-footer {
    padding: 6px 16px 12px;
  }

  .ba-modal-title {
    font-size: 15px;
  }

  .ba-inline-header,
  .ba-inline-wrapper .ba-appointment-form {
    padding-left:  18px;
    padding-right: 18px;
  }
}

/* Small mobile (≤ 480px) */
@media (max-width: 480px) {
  .ba-modal-title {
    font-size: 14px;
  }

  .ba-modal-subtitle {
    font-size: 11px;
  }

  .ba-modal-icon {
    width:  30px;
    height: 30px;
  }

  .ba-modal-icon svg {
    width:  15px;
    height: 15px;
  }

  /* Prevent iOS input auto-zoom – keep 16px minimum */
  .ba-input {
    font-size: 16px !important;
  }

  .ba-trust-badges {
    gap: 10px;
  }

  .ba-submit-btn {
    font-size: 13.5px;
    padding:   10px 16px;
  }

  .ba-appointment-form {
    gap: 6px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ba-fab,
  .ba-fab::before,
  .ba-modal-container,
  .ba-modal-close,
  .ba-submit-btn,
  .ba-input,
  .ba-checkbox-custom,
  .ba-spinner-svg {
    animation: none !important;
    transition: none !important;
  }

  .ba-modal-overlay {
    transition: visibility 0s, opacity 0.1s ease !important;
  }
}

/* High contrast */
@media (forced-colors: active) {
  .ba-fab,
  .ba-submit-btn {
    forced-color-adjust: none;
  }
}
