/* ===========================================================
   Customer Landing Page + Chatbot Widget Styles
   =========================================================== */

/* --- Page layout --- */
.customer-body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f8f9fb;
  color: #1e293b;
}

/* Lock page scroll only when chat panel is open; chatbot panel scrolls independently (fixed positioning) */
.customer-body.chat-panel-open {
  overflow: hidden;
}

/* --- Header / Logo --- */
.customer-header {
  padding: 1rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.customer-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tenant-logo {
  max-height: 48px;
  object-fit: contain;
}

.tenant-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0c3b5d;
}

/* --- Footer --- */
.customer-footer {
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2rem;
}

/* --- Carousel --- */
.carousel-section {
  max-width: 900px;
  margin: 2rem auto;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.carousel {
  position: relative;
  width: 100%;
  min-height: 300px;
  background: #e2e8f0;
}

.carousel-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
}

.carousel-img.active {
  opacity: 1;
}

/* --- Landing content --- */
.landing-content {
  max-width: 800px;
  margin: 2rem auto;
  padding: 1.5rem 2rem;
  line-height: 1.7;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  color: #1e293b;
}

/* Override global p { color: var(--muted) } so landing text is readable */
.landing-content p {
  color: #1e293b;
}

.landing-content h1,
.landing-content h2,
.landing-content h3 {
  color: #0c3b5d;
}

/* --- Contact info --- */
.contact-section {
  max-width: 800px;
  margin: 1rem auto 4rem;
  padding: 1rem 2rem;
  text-align: center;
  color: #64748b;
}

/* =========================================================
   Chatbot Widget — Bottom-right corner with expand to 70%
   ========================================================= */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: inherit;
  max-width: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.chat-widget:has(.chat-widget-panel:not([hidden])) {
  bottom: max(24px, env(safe-area-inset-bottom, 0));
}

/* Toggle button */
.chat-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: #0c3b5d;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(12, 59, 93, 0.35);
  transition: background 0.2s, transform 0.15s;
  max-width: 100%;
  text-align: center;
}

/* Ensure hidden attribute works even when display:flex is set */
.chat-toggle-btn[hidden] {
  display: none !important;
}

.chat-toggle-btn:hover {
  background: #0a2f4b;
  transform: translateY(-1px);
}

.chat-toggle-btn svg {
  flex-shrink: 0;
}

/* ---- Panel (default / collapsed) ---- */
.chat-widget-panel {
  width: 100%;
  max-width: 380px;
  max-height: 520px;
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  transition: width 0.35s ease, max-height 0.35s ease, border-radius 0.25s ease;
}

/* Ensure hidden attribute works even when display:flex is set */
.chat-widget-panel[hidden] {
  display: none !important;
}

/* Hidden elements in chat widget must not block clicks or take space */
.chat-widget [hidden],
.chat-widget-panel [hidden] {
  display: none !important;
  pointer-events: none !important;
}

/* ---- Panel (expanded to 70%) ---- */
.chat-widget-panel.expanded {
  width: 70vw;
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
}

/* Header */
.chat-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #0c3b5d;
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  min-width: 0;
  gap: 8px;
}

.chat-widget-header > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.book-appointment-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.book-appointment-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
}

.book-appointment-header-btn[hidden] {
  display: none !important;
}

.chat-expand-btn {
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.chat-expand-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  min-width: 28px;
  min-height: 28px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s;
  text-align: center;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Prevent SVGs inside header buttons from intercepting clicks */
.chat-header-actions button svg {
  pointer-events: none;
}

/* Messages area — scrollable body */
.chat-widget-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  background: #f1f5f9;
  transition: max-height 0.35s ease;
  -webkit-overflow-scrolling: touch;
}

.chat-widget-panel.expanded .chat-widget-messages {
  max-height: none;
  min-height: 400px;
}

.chat-msg {
  max-width: 80%;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.chat-msg-user {
  align-self: flex-end;
  background: #0c3b5d;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-msg-assistant h2,
.chat-msg-assistant h3 {
  margin: 0.3em 0;
  font-size: 1rem;
}

.chat-msg-assistant p {
  margin: 0.4em 0;
}

.chat-msg-assistant ul,
.chat-msg-assistant ol {
  padding-left: 1.2em;
  margin: 0.3em 0;
}

/* Input area */
.chat-widget-input {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
  min-width: 0;
}

.chat-widget-input input {
  flex: 1;
  min-width: 0;
  width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
  max-width: 100%;
}

.chat-widget-input input:focus {
  border-color: #0c3b5d;
}

.chat-send-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #0c3b5d;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s;
  max-width: 100%;
  text-align: center;
}

.chat-send-btn:hover {
  background: #0a2f4b;
}

/* =========================================================
   Responsive — Mobile (320–480) / Tablet (481–1024) / Desktop (1024+)
   ========================================================= */

@media (max-width: 1024px) {
  .chat-widget-panel {
    max-width: min(380px, calc(100vw - 32px));
  }

  .chat-widget-panel.expanded {
    width: min(70vw, calc(100vw - 32px));
    max-height: 82vh;
    max-height: 82dvh;
  }
}

@media (max-width: 768px) {
  .chat-widget {
    bottom: 16px;
    right: 16px;
    left: 16px;
    padding-left: 0;
    padding-right: 0;
  }

  .chat-widget-panel {
    max-width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    margin: 0 auto;
  }

  .chat-widget-panel.expanded {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    max-height: 85dvh;
  }

  .chat-widget-messages {
    padding: 12px;
    min-height: 240px;
    max-height: 320px;
  }

  .chat-widget-panel.expanded .chat-widget-messages {
    min-height: 320px;
  }

  .chat-msg {
    max-width: 90%;
    font-size: 0.9rem;
    padding: 10px 12px;
  }

  .chat-widget-header {
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  .chat-widget-input {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0));
  }

  .chat-widget-input input {
    padding: 8px 10px;
    font-size: 16px;
  }

  .book-appointment-header-btn {
    font-size: 0.75rem;
    padding: 5px 8px;
  }
}

@media (max-width: 480px) {
  .chat-widget:has(.chat-widget-panel:not([hidden])) {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .chat-widget:has(.chat-widget-panel:not([hidden])) .chat-widget-panel {
    flex: 1;
    min-height: 0;
    max-height: none;
    height: 100%;
  }

  .chat-widget-panel {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
  }

  .chat-widget-panel.expanded {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }

  .appointment-form-container {
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0));
  }

  .chat-widget-header {
    padding: 10px 12px;
    min-height: 44px;
  }

  .chat-widget-header > span {
    font-size: 0.9rem;
  }

  .chat-widget-messages {
    min-height: 200px;
    max-height: min(360px, 50dvh);
  }

  .chat-widget-panel.expanded .chat-widget-messages {
    min-height: 40dvh;
  }

  .chat-msg {
    max-width: 90%;
    font-size: 0.875rem;
  }

  .chat-toggle-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .carousel-section {
    margin: 1rem;
    border-radius: 8px;
  }

  .landing-content {
    margin: 1rem;
    padding: 1rem;
  }
}

@media (max-width: 360px) {
  .chat-widget-messages {
    padding: 10px;
  }

  .chat-msg {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .chat-widget-input {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0));
  }

  .chat-send-btn {
    padding: 8px 12px;
    font-size: 0.875rem;
  }
}

@media (min-width: 1440px) {
  .chat-widget-panel {
    max-width: 420px;
  }

  .chat-widget-panel.expanded {
    width: min(70vw, 900px);
  }
}

/* =========================================================
   Single-form appointment (calendar form) — responsive
   ========================================================= */
/* Appointment form wrapper — must scroll when content exceeds height */
.appointment-form-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0));
  background: #f8fafc;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* When form is shown below chat (messages above, form below) — form area must still scroll */
.appointment-form-container.form-below-chat {
  flex: 1;
  min-height: 0;
  max-height: 100%;
}

.chat-widget-panel.expanded .appointment-form-container {
  min-height: 400px;
  padding: 20px;
}

.appointment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 95%;
  max-width: 500px;
  min-width: 0;
  margin: 0 auto;
  flex-shrink: 0;
}

.appointment-form-title {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0c3b5d;
}

.appointment-form-intro {
  margin: 0 0 12px 0;
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.4;
}

.appointment-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.appointment-form-field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
}

.appointment-form-field .required {
  color: #dc2626;
}

.appointment-form-field input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
  background: #fff;
  transition: border-color 0.2s;
}

.appointment-form-field input:focus {
  outline: none;
  border-color: #0c3b5d;
  box-shadow: 0 0 0 2px rgba(12, 59, 93, 0.15);
}

.appointment-form-field input.invalid {
  border-color: #dc2626;
}

.appointment-form-field input.invalid:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.field-error {
  font-size: 0.8rem;
  color: #dc2626;
  min-height: 1.2em;
  display: none;
}

.field-error.field-error-visible {
  display: block;
}

.age-display {
  font-size: 0.8rem;
  color: #64748b;
}

.age-display[hidden] {
  display: none;
}

/* Submit button — full width, hover/active/disabled (override .btn.primary) */
.appointment-form .appointment-submit,
button.appointment-submit {
  margin-top: 4px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  background: #0c3b5d;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
  min-height: 44px;
  text-align: center;
}

.appointment-form .appointment-submit:hover:not(:disabled),
button.appointment-submit:hover:not(:disabled) {
  background: #0a2f4b;
}

.appointment-form .appointment-submit:active:not(:disabled),
button.appointment-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.appointment-form .appointment-submit:disabled,
.appointment-form .appointment-submit[aria-busy="true"],
button.appointment-submit:disabled,
button.appointment-submit[aria-busy="true"] {
  opacity: 0.8;
  cursor: wait;
  transform: none;
}

.appointment-form .appointment-submit:disabled:not([aria-busy="true"]),
button.appointment-submit:disabled:not([aria-busy="true"]) {
  cursor: pointer;
}

.appointment-form-skip {
  margin: 8px 0 0 0;
  font-size: 0.85rem;
}

.appointment-form-skip .link-btn + .link-btn {
  margin-left: 12px;
}

.appointment-form-cancel {
  color: #64748b;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: #0c3b5d;
  text-decoration: underline;
  cursor: pointer;
  max-width: 100%;
  text-align: center;
}

.link-btn:hover {
  color: #0a2f4b;
}

/* ——— Responsive: 768px and below ——— */
@media (max-width: 768px) {
  .appointment-form-container {
    padding: 16px;
  }

  .appointment-form {
    gap: 12px;
  }

  .appointment-form .appointment-submit,
  button.appointment-submit {
    width: 100%;
    padding: 12px 14px;
  }
}

/* ——— Responsive: 480px and below (mobile) ——— */
@media (max-width: 480px) {
  .appointment-form-container {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0));
    min-height: 240px;
  }

  .appointment-form {
    width: 95%;
    max-width: 100%;
  }

  .appointment-form-field input {
    padding: 10px 12px;
  }

  .appointment-form .appointment-submit,
  button.appointment-submit {
    width: 100%;
    padding: 14px 16px;
    min-height: 48px;
  }

  .appointment-form-skip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .appointment-form-skip .link-btn + .link-btn {
    margin-left: 0;
  }
}

/* ——— 320px (extra small) ——— */
@media (max-width: 360px) {
  .appointment-form-container {
    padding: 12px;
  }

  .appointment-form {
    gap: 10px;
  }

  .appointment-form .appointment-submit,
  button.appointment-submit {
    padding: 12px;
  }
}

/* ——— Ensure no overlay blocks form (submit remains clickable) ——— */
.appointment-form-container * {
  pointer-events: auto;
}

.appointment-form .appointment-submit:focus-visible,
button.appointment-submit:focus-visible {
  outline: 2px solid #0c3b5d;
  outline-offset: 2px;
}
