/* TFW Eve Chat Widget — externalized 2026-04-25 */
/* Canonical source. Edit and re-run _widget_refactor.py if regenerating. */
  /* ========== TFW CHAT WIDGET — SCOPED STYLES ========== */
  :root {
    --tfw-cream: rgb(250, 248, 245);
    --tfw-cream-dark: rgb(240, 235, 228);
    --tfw-copper: rgb(212, 165, 116);
    --tfw-copper-hover: rgb(195, 148, 100);
    --tfw-copper-light: rgba(212, 165, 116, 0.12);
    --tfw-copper-border: rgba(212, 165, 116, 0.3);
    --tfw-text-dark: rgb(44, 44, 44);
    --tfw-text-muted: rgb(138, 117, 96);
    --tfw-text-light: rgba(44, 44, 44, 0.5);
    --tfw-border-warm: rgb(232, 224, 216);
    --tfw-avatar-orange: rgb(255, 164, 33);
    --tfw-white: #fff;
  }

  /* ===== MINI PANEL (State 1 — page load default) ===== */
  .tfw-mini-panel {
    position: fixed; bottom: 24px; right: 24px; width: 340px; max-width: calc(100vw - 48px);
    background: var(--tfw-cream); border: 1px solid var(--tfw-border-warm);
    border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,0.15);
    overflow: hidden; cursor: pointer; z-index: 99999;
    font-family: -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    display: none; /* shown by JS after delay */
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .tfw-mini-panel:hover { transform: translateY(-2px); box-shadow: 0 16px 56px rgba(0,0,0,0.2); }
  .tfw-mini-panel.tfw-entering { animation: tfwMiniSlide 0.5s ease; }
  .tfw-mini-panel.tfw-exiting { animation: tfwMiniExit 0.3s ease forwards; }
  @keyframes tfwMiniSlide { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes tfwMiniExit { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(20px); } }

  .tfw-mini-close {
    position: absolute; top: 10px; right: 12px;
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,0.6); font-size: 18px; line-height: 1;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.15s, color 0.15s; z-index: 2;
  }
  .tfw-mini-close:hover { background: none; color: #fff; }

  .tfw-mini-header {
    padding: 16px 20px 12px;
    border-bottom: 2px solid var(--tfw-copper);
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #2c2c2c, #3a3530);
    border-radius: 16px 16px 0 0;
  }
  .tfw-mini-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--tfw-copper), var(--tfw-copper-hover));
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white; flex-shrink: 0; position: relative;
  }
  .tfw-mini-avatar .tfw-dot {
    position: absolute; top: 0; right: 0; width: 9px; height: 9px;
    background: #4ade80; border-radius: 50%; border: 2px solid #2c2c2c;
  }
  .tfw-mini-header-text h3 { font-family: Georgia, serif; font-size: 16px; color: #fff; font-weight: 700; margin: 0; }
  .tfw-mini-header-text p { font-size: 11px; color: var(--tfw-copper); margin: 2px 0 0; font-style: italic; }

  .tfw-mini-message { padding: 16px 20px; display: flex; gap: 10px; }
  .tfw-mini-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--tfw-copper), var(--tfw-copper-hover));
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: white; flex-shrink: 0; margin-top: 2px;
  }
  .tfw-mini-msg-text {
    background: var(--tfw-white); border: 1px solid var(--tfw-border-warm);
    border-radius: 12px; border-top-left-radius: 4px;
    padding: 12px 16px; font-size: 14px; line-height: 1.5; color: var(--tfw-text-dark);
  }

  .tfw-mini-cta { padding: 12px 20px 16px; display: flex; align-items: center; gap: 10px; }
  .tfw-mini-cta-input {
    flex: 1; background: var(--tfw-cream); border: 1px solid var(--tfw-border-warm);
    border-radius: 10px; padding: 10px 14px; font-size: 13px;
    color: var(--tfw-text-light); font-family: inherit;
  }
  .tfw-mini-cta-btn {
    background: var(--tfw-copper); border: none; color: white;
    padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
    font-family: inherit; cursor: pointer; transition: background 0.15s;
  }
  .tfw-mini-cta-btn:hover { background: var(--tfw-copper-hover); }

  /* ===== BUBBLE (State 2 — after dismiss or on mobile) ===== */
  .tfw-chat-bubble {
    position: fixed; bottom: 24px; right: 24px;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--tfw-copper);
    box-shadow: 0 4px 20px rgba(212, 165, 116, 0.4), 0 0 0 0 rgba(212, 165, 116, 0.3);
    cursor: pointer; display: none; /* shown by JS */
    align-items: center; justify-content: center;
    z-index: 99999; transition: transform 0.2s, box-shadow 0.2s;
    animation: tfwBubblePulse 3.5s infinite;
    border: none; padding: 0; margin: 0;
    font-family: -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  }
  .tfw-chat-bubble:hover { transform: scale(1.06); box-shadow: 0 6px 28px rgba(212, 165, 116, 0.5); animation: none; }
  .tfw-chat-bubble svg { width: 24px; height: 24px; fill: white; }
  .tfw-chat-bubble .tfw-close-icon { display: none; }
  .tfw-chat-bubble.tfw-open svg.tfw-chat-icon { display: none; }
  .tfw-chat-bubble.tfw-open .tfw-close-icon { display: block; font-size: 24px; color: white; font-weight: 300; line-height: 1; }

  @keyframes tfwBubblePulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(212, 165, 116, 0.4), 0 0 0 0 rgba(212, 165, 116, 0.25); }
    50% { box-shadow: 0 4px 20px rgba(212, 165, 116, 0.4), 0 0 0 10px rgba(212, 165, 116, 0); }
  }

  .tfw-chat-bubble .tfw-online-dot {
    position: absolute; top: 1px; right: 1px;
    width: 13px; height: 13px; background: #4ade80;
    border-radius: 50%; border: 2.5px solid #000;
  }

  /* ===== CHAT PANEL (State 3 — full chat) ===== */
  .tfw-chat-panel {
    position: fixed; bottom: 96px; right: 24px; width: 390px; max-width: calc(100vw - 48px); max-height: 500px;
    background: var(--tfw-cream); border: 1px solid var(--tfw-border-warm);
    border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,0.15);
    display: none; flex-direction: column; z-index: 99999;
    animation: tfwPanelSlide 0.3s ease; overflow: hidden;
    font-family: -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  }
  .tfw-chat-panel.tfw-open { display: flex; }
  @keyframes tfwPanelSlide { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

  /* Header — compressed 2026-04-24 */
  .tfw-chat-header {
    background: linear-gradient(135deg, #2c2c2c, #3a3530);
    padding: 12px 18px 10px;
    border-bottom: 2px solid var(--tfw-copper);
  }
  .tfw-chat-header-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
  .tfw-chat-header-logo {
    width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--tfw-copper), var(--tfw-copper-hover));
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
  }
  .tfw-chat-header-text h3 { font-family: Georgia, serif; font-size: 15px; color: #fff; font-weight: 700; margin: 0; }
  .tfw-chat-header-text p { font-size: 11px; color: var(--tfw-copper); margin-top: 0; font-style: italic; margin-bottom: 0; }
  .tfw-chat-header .tfw-status-row { display: flex; align-items: center; gap: 5px; font-size: 10px; color: rgba(255,255,255,0.6); }
  .tfw-chat-header .tfw-status-dot { width: 5px; height: 5px; background: #4ade80; border-radius: 50%; }

  /* Stat badges — single-row, compressed */
  .tfw-chat-badges {
    display: flex; justify-content: center; gap: 5px; padding: 8px 12px;
    background: var(--tfw-cream); border-bottom: 1px solid var(--tfw-border-warm); flex-wrap: nowrap;
  }
  .tfw-chat-badge {
    font-size: 10px; color: var(--tfw-text-dark); background: var(--tfw-white);
    border: 1px solid var(--tfw-border-warm); border-radius: 20px; padding: 3px 9px; font-weight: 500;
    white-space: nowrap;
  }

  /* Messages */
  .tfw-chat-messages {
    flex: 1; padding: 20px 24px 8px; overflow-y: auto; min-height: 100px; background: var(--tfw-cream);
  }
  .tfw-chat-messages::-webkit-scrollbar { width: 4px; }
  .tfw-chat-messages::-webkit-scrollbar-track { background: transparent; }
  .tfw-chat-messages::-webkit-scrollbar-thumb { background: var(--tfw-border-warm); border-radius: 4px; }

  .tfw-msg { margin-bottom: 14px; display: flex; gap: 10px; }
  .tfw-msg.tfw-bot .tfw-msg-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--tfw-copper), var(--tfw-copper-hover));
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: white; flex-shrink: 0; margin-top: 2px;
  }
  .tfw-msg .tfw-msg-text {
    border-radius: 12px; padding: 12px 16px; font-size: 14px; line-height: 1.6; max-width: 275px;
    /* Hard break long URLs / unbroken strings so they never overflow the bubble. */
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
  }
  .tfw-msg.tfw-bot .tfw-msg-text {
    background: var(--tfw-white); color: var(--tfw-text-dark);
    border: 1px solid var(--tfw-border-warm); border-top-left-radius: 4px;
  }
  .tfw-msg.tfw-bot .tfw-msg-text a {
    color: var(--tfw-copper); text-decoration: underline; font-weight: 600; cursor: pointer;
    /* Long affiliate URLs must wrap inside the bubble. (2026-04-25 hardened) */
    overflow-wrap: anywhere !important;
    word-break: break-all !important;
    word-wrap: break-word !important;
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    -webkit-hyphens: auto;
    hyphens: auto;
    box-sizing: border-box;
  }
  /* Belt-and-braces: ensure the message text container itself never lets a child overflow. */
  .tfw-msg .tfw-msg-text { overflow-wrap: anywhere !important; word-break: break-word !important; }
  .tfw-msg .tfw-msg-text * { max-width: 100%; }
  .tfw-msg.tfw-bot .tfw-msg-text a:hover { text-decoration: underline; opacity: 0.85; }
  .tfw-msg.tfw-user { justify-content: flex-end; }
  .tfw-msg.tfw-user .tfw-msg-text {
    background: var(--tfw-copper); color: white; font-weight: 500; border-top-right-radius: 4px;
  }
  .tfw-msg-time { font-size: 10px; color: var(--tfw-text-muted); margin-top: 4px; margin-left: 40px; }

  /* Typing indicator */
  .tfw-typing { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
  .tfw-typing span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--tfw-text-muted);
    animation: tfwTypingDot 1.4s infinite ease-in-out;
  }
  .tfw-typing span:nth-child(2) { animation-delay: 0.2s; }
  .tfw-typing span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes tfwTypingDot { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

  /* Quick Replies — compressed 2026-04-24 */
  .tfw-quick-replies { padding: 4px 14px 6px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 5px; background: var(--tfw-cream); }
  .tfw-quick-replies button { background: var(--tfw-copper-light); border: 1px solid var(--tfw-copper); border-radius: 14px; padding: 4px 8px; font-size: 10.5px; line-height: 1.2; color: var(--tfw-copper); cursor: pointer; font-weight: 600; transition: all 0.15s; font-family: inherit; white-space: nowrap; }
  .tfw-quick-replies button:hover {
    background: var(--tfw-copper);
    color: var(--tfw-white);
    border-color: var(--tfw-copper);
  }

  /* Input Area — compressed */
  .tfw-chat-input {
    padding: 10px 16px; border-top: 1px solid var(--tfw-border-warm);
    display: flex; gap: 8px; background: var(--tfw-cream);
  }
  .tfw-chat-input input {
    flex: 1; background: var(--tfw-cream); border: 1px solid var(--tfw-border-warm);
    border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--tfw-text-dark);
    outline: none; transition: border-color 0.2s; font-family: inherit;
  }
  .tfw-chat-input input::placeholder { color: var(--tfw-text-light); }
  .tfw-chat-input input:focus { border-color: var(--tfw-copper); }
  .tfw-chat-input button {
    background: var(--tfw-copper); border: none; color: white; padding: 0 14px; height: 34px;
    border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; transition: background 0.15s; font-family: inherit;
  }
  .tfw-chat-input button:hover { background: var(--tfw-copper-hover); }
  .tfw-chat-input button svg { width: 14px; height: 14px; fill: white; }

  /* Footer — combined disclaimer + attribution, compressed so it always fits */
  .tfw-chat-disclaimer {
    padding: 6px 16px 4px; font-size: 9px; line-height: 1.3; color: var(--tfw-text-muted); text-align: center;
    background: var(--tfw-cream); border-top: 1px solid var(--tfw-border-warm); font-style: italic;
  }
  .tfw-chat-powered { text-align: center; padding: 2px 16px 6px; font-size: 9px; color: var(--tfw-text-muted); background: var(--tfw-cream); }

  /* Elastic scroll containment — prevent scroll bleed to page */
  .tfw-chat-messages {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tfw-chat-panel {
    overscroll-behavior: contain;
  }

  /* Body scroll lock when chat is open on mobile */
  body.tfw-chat-body-lock {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Backdrop overlay — click/tap to close */
  .tfw-chat-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99998;
    -webkit-tap-highlight-color: transparent;
  }
  .tfw-chat-backdrop.tfw-visible {
    display: block;
  }

  /* Close button on chat panel header — visible on all viewports
     so auto-opened chat is always dismissible (added 2026-04-25) */
  .tfw-chat-close-btn {
    position: absolute; top: 14px; right: 14px;
    background: rgba(0,0,0,0.18); border: none; cursor: pointer;
    color: rgba(255,255,255,0.85); font-size: 20px; line-height: 1;
    width: 30px; height: 30px; display: flex;
    align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.15s, color 0.15s; z-index: 2;
  }
  .tfw-chat-close-btn:hover { background: rgba(0,0,0,0.32); color: #fff; }

  
  @media (max-width: 768px) {
    /* Chatbot mobile — prevent overflow */
    .tfw-chat-panel { left: 12px !important; right: 12px !important; bottom: 88px !important; width: auto !important; max-width: 360px !important; margin-left: auto !important; max-height: 60vh; border-radius: 16px !important; box-sizing: border-box !important; overflow-x: hidden !important; }
    .tfw-chat-panel .tfw-chat-messages { max-height: 32vh; min-height: 100px; font-size: 13px; }
    .tfw-chat-panel .tfw-chat-header { padding: 12px 16px; }
    .tfw-chat-panel .tfw-chat-input { padding: 8px 12px; }
    .tfw-chat-panel .tfw-chat-input input { font-size: 14px; padding: 8px 12px; }
    .tfw-mini-panel { right: 12px !important; left: auto !important; bottom: 12px !important; width: 240px !important; max-width: calc(100vw - 24px) !important; font-size: 13px; }
    .tfw-mini-panel .tfw-mini-msg-text { font-size: 12px; }
    .tfw-mini-panel .tfw-mini-cta { font-size: 12px; padding: 8px 12px; }
    .tfw-chat-bubble { width: 44px !important; height: 44px !important; bottom: 12px !important; right: 12px !important; }
    .tfw-chat-bubble svg { width: 18px !important; height: 18px !important; }
    .tfw-chat-close-btn { display: flex !important; }

    /* Quick-reply pills compress further on mobile so 7 buttons fit on 2 rows
       (was wrapping to 3 rows and eating message space). 2026-04-25 */
    .tfw-quick-replies { padding: 4px 10px 5px !important; gap: 3px 4px !important; }
    .tfw-quick-replies button {
      padding: 3px 7px !important;
      font-size: 9.5px !important;
      letter-spacing: 0.1px !important;
      border-radius: 12px !important;
    }
  }

  /* ========================================================================
     iOS Safari hardening (2026-04-25): defense-in-depth against horizontal
     scroll/rubber-band drift on mobile. Headless Chromium reports zero
     overflow but iOS Safari rubber-bands when ANY descendant has wider
     intrinsic content (long URLs in FAQ answers, schema-org JSON-LD blocks
     rendered as text in some contexts, etc.). These rules force the entire
     document tree to never produce a horizontal scroll region on mobile.
     ======================================================================== */
  @media (max-width: 768px) {
    html {
      max-width: 100vw !important;
      overflow-x: clip !important;          /* stronger than hidden — disables programmatic scroll */
      overscroll-behavior-x: none !important; /* kills iOS Safari elastic side-pan */
    }
    body {
      max-width: 100vw !important;
      overflow-x: clip !important;
      overscroll-behavior-x: none !important;
      position: relative;
    }
    /* Any direct child of body must stay inside viewport. */
    body > * {
      max-width: 100vw;
    }
    /* Long URL strings in FAQ answers etc. should always wrap. */
    .faq-answer, .faq-answer * { overflow-wrap: anywhere !important; word-break: break-word !important; }
  }