/* ============================================================================
   OVERCROSS - the live chat widget ("Ask Luke"), Layout::parts.live-chat.

   Mobile first on the 600 / 900 / 1200 ladder (see base.css), and the phone
   is a real target now, not a width the widget hides at:

     below 600   the button sits in the thumb corner; the chat opens as a
                 full-screen sheet that follows the visual viewport, so the
                 keyboard never covers the input
     600 - 899   the floating 380px window
     900 and up  the same window, plus the one-minute teaser

   Which of those is on is decided here and nowhere else. The script reads the
   answer back from the page instead of mirroring a rung in JavaScript: the
   popup's computed `position` (fixed = the phone sheet) and `--lc-teaser` on
   the root.

   z-index: 3950 below 900 - over the tour page's action bar (3900) and the
   header (3000/3001), under the enquiry sheet (4000), the call slot's sheet
   (99999) and the cookie dialog (9999). 9999 from 900 up, as it always was.
   ========================================================================= */

#live-chat-root {
    --lc-teaser: 0;
    position: fixed;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 3950;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: bottom 0.22s ease;
}

/* The tour page's action bar (public/css/tour-action-bar.css) is 64px plus the
   safe area once the hero is behind the reader; the button stands above it
   instead of on top of its CTA. */
html.oc-tour-past-hero #live-chat-root {
    bottom: calc(64px + 12px + env(safe-area-inset-bottom, 0px));
}

/* The enquiry / call sheets and the phone's side menu own the screen. */
html.oc-tour-form-open #live-chat-root,
body.menu-open #live-chat-root {
    display: none;
}

@media (min-width: 900px) {
    #live-chat-root {
        --lc-teaser: 1;
        right: 24px;
        bottom: 24px;
        z-index: 9999;
    }

    html.oc-tour-past-hero #live-chat-root { bottom: 24px; }

    html.oc-tour-form-open #live-chat-root,
    body.menu-open #live-chat-root {
        display: block;
    }
}

/* The page under the phone sheet stays where it is. Set by the script only
   while the sheet (not the floating window) is open. */
html.lc-lock,
html.lc-lock body {
    overflow: hidden;
}

/* ---- Toggle button wrapper ---- */
.lc-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* CTA label beside the button */
.lc-toggle-label {
    display: none;
}

/* Toggle button - circular with chat icon */
.lc-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #f97316;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(249,115,22,0.40);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.lc-toggle:active { transform: scale(0.95); }

@media (hover: hover) {
    .lc-toggle:hover {
        transform: scale(1.07);
        box-shadow: 0 6px 24px rgba(249,115,22,0.50);
    }
}

@media (min-width: 600px) {
    .lc-toggle { width: 56px; height: 56px; }
}

/* Unread badge */
.lc-unread-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ---- Teaser card: the one nudge after a minute on the site ---- */
.lc-teaser {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 306px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 30px 13px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(17,18,20,0.16), 0 2px 6px rgba(17,18,20,0.05);
    cursor: pointer;
    text-align: left;
    opacity: 0;
    transform: translateY(14px) scale(0.94);
    transition: opacity 0.28s ease, transform 0.34s cubic-bezier(0.34,1.4,0.64,1),
                border-color 0.2s ease, box-shadow 0.2s ease;
}
.lc-teaser.is-on { opacity: 1; transform: translateY(0) scale(1); }
.lc-teaser:hover {
    border-color: #fdba74;
    box-shadow: 0 14px 44px rgba(249,115,22,0.18), 0 2px 6px rgba(17,18,20,0.05);
}
/* Pointer towards the toggle button */
.lc-teaser::after {
    content: '';
    position: absolute;
    right: 22px;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    transform: rotate(45deg);
}
.lc-teaser-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: #9ca3af;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.lc-teaser-close:hover { background: #f3f4f6; color: #111214; }
.lc-teaser-avatar { position: relative; flex-shrink: 0; }
.lc-teaser-photo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid #f97316;
}
.lc-teaser-dot {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}
.lc-teaser-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lc-teaser-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #111214;
    line-height: 1.3;
}
.lc-teaser-text {
    font-size: 12.5px;
    color: #4b5563;
    line-height: 1.45;
}
.lc-teaser-cta {
    margin-top: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #f97316;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* The button breathes while the teaser is up */
@keyframes lc-pulse {
    0%   { box-shadow: 0 4px 20px rgba(249,115,22,0.40), 0 0 0 0 rgba(249,115,22,0.45); }
    70%  { box-shadow: 0 4px 20px rgba(249,115,22,0.40), 0 0 0 15px rgba(249,115,22,0); }
    100% { box-shadow: 0 4px 20px rgba(249,115,22,0.40), 0 0 0 0 rgba(249,115,22,0); }
}
.lc-toggle.lc-toggle-pulse { animation: lc-pulse 1.9s ease-out infinite; }

/* ---- Popup ----
   The phone: a full-screen sheet. Its box is the visual viewport, which the
   script writes into --lc-vv-top / --lc-vv-height while it is open - with the
   keyboard up that is the part of the screen still visible, so the input sits
   right above the keyboard. dvh is the fallback before the first write. */
.lc-popup {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--lc-vv-top, 0px);
    height: 100vh;
    height: var(--lc-vv-height, 100dvh);
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: lc-sheet-up 0.28s cubic-bezier(0.22,1,0.36,1);
}
@keyframes lc-sheet-up {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes lc-slide-up {
    0%   { opacity: 0; transform: translateY(32px) scale(0.88); }
    100% { opacity: 1; transform: translateY(0)   scale(1); }
}
@keyframes lc-slide-down {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(22px) scale(0.92); }
}

/* Behind the sheet the button has nothing to do; the header closes it. */
#live-chat-root.lc-is-open .lc-toggle-wrap { display: none; }

@media (min-width: 600px) {
    .lc-popup {
        position: absolute;
        left: auto;
        top: auto;
        right: 0;
        bottom: 70px;
        width: 380px;
        height: auto;
        border-radius: 14px;
        border: 1px solid #e5e7eb;
        box-shadow: 0 12px 48px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.06);
        animation: lc-slide-up 0.42s cubic-bezier(0.34,1.56,0.64,1);
    }

    #live-chat-root.lc-is-open .lc-toggle-wrap { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
    .lc-teaser { transition: opacity 0.2s ease; transform: none; }
    .lc-teaser.is-on { transform: none; }
    .lc-toggle.lc-toggle-pulse { animation: none; }
    .lc-popup { animation: none; }
}

/* ---- Header ---- */
.lc-header {
    flex-shrink: 0;
    padding: calc(12px + env(safe-area-inset-top, 0px))
             max(12px, env(safe-area-inset-right, 0px))
             12px
             max(16px, env(safe-area-inset-left, 0px));
    background: #f97316;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
@media (min-width: 600px) {
    .lc-header { padding: 16px 16px 14px; }
}
.lc-header-info { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Avatar with photo + online dot */
.lc-header-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.lc-header-photo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid rgba(255,255,255,0.15);
}
.lc-header-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lc-header-name  { color: #fff; font-weight: 600; font-size: 14px; line-height: 1.3; }
.lc-header-role  { color: rgba(255,255,255,0.8); font-size: 11px; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.lc-header-status {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.lc-online-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
}
.lc-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
/* A thumb-sized close on the phone; the small square from 600 up. */
.lc-header-reset,
.lc-header-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.lc-header-close svg { width: 18px; height: 18px; }
@media (min-width: 600px) {
    .lc-header-actions { align-self: flex-start; }
    .lc-header-reset,
    .lc-header-close {
        width: auto;
        height: auto;
        padding: 6px;
        border-radius: 6px;
        color: rgba(255,255,255,0.8);
    }
    .lc-header-close svg { width: 15px; height: 15px; }
}
.lc-header-reset:hover,
.lc-header-close:hover { background: rgba(255,255,255,0.25); color: #fff; }

/* ---- Info form ----
   On the phone it shares the sheet with the keyboard, so it scrolls rather
   than pushing the start button out of sight. */
.lc-info-form {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
}
@media (min-width: 600px) {
    .lc-info-form { flex: none; overflow: visible; padding: 18px 18px 16px; }
}

.lc-intro {
    font-size: 14px;
    color: #4b5563;
    margin: 0 0 14px;
    line-height: 1.6;
    font-weight: 400;
}

/* Field group with icon wrappers */
.lc-field-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lc-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.lc-field-icon {
    position: absolute;
    left: 13px;
    color: #b0b7c3;
    pointer-events: none;
    flex-shrink: 0;
    transition: color 0.15s;
}
.lc-field-wrap:focus-within .lc-field-icon {
    color: #f97316;
}
/* 16px on the phone: anything smaller and iOS zooms the page on focus. */
.lc-field {
    width: 100%;
    min-height: 48px;
    padding: 12px 12px 12px 38px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    color: #111;
    box-sizing: border-box;
    background: #f9fafb;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    font-family: inherit;
}
.lc-field:focus {
    border-color: #f97316;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(249,115,22,0.10);
}
.lc-field::placeholder { color: #b0b7c3; }

@media (min-width: 600px) {
    .lc-intro { font-size: 13px; line-height: 1.65; }
    .lc-field-group { gap: 9px; }
    .lc-field-icon { left: 12px; }
    .lc-field {
        min-height: 0;
        padding: 10px 12px 10px 36px;
        border-radius: 8px;
        font-size: 13.5px;
    }
}

/* ---- Messages ---- */
.lc-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px max(12px, env(safe-area-inset-right, 0px)) 14px max(12px, env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}
@media (min-width: 600px) {
    .lc-messages {
        flex: 1;
        min-height: 180px;
        max-height: 260px;
        padding: 14px;
    }
}
.lc-messages::-webkit-scrollbar { width: 4px; }
.lc-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }

.lc-msg {
    display: flex;
    gap: 7px;
    max-width: 88%;
}
.lc-msg.from-visitor  { align-self: flex-end;  flex-direction: row-reverse; }
.lc-msg.from-operator { align-self: flex-start; }

.lc-msg-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
}
@media (min-width: 600px) {
    .lc-msg-bubble {
        padding: 9px 12px;
        border-radius: 12px;
        font-size: 13px;
    }
}
.lc-msg-bubble a { color: inherit; text-decoration: underline; }
.from-visitor .lc-msg-bubble {
    background: #f97316;
    color: #fff;
    border-bottom-right-radius: 3px;
}
.from-operator .lc-msg-bubble {
    background: #fff;
    color: #111;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.from-operator .lc-msg-bubble a { color: #c2410c; }
.lc-msg-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    text-align: right;
}
.from-operator .lc-msg-time { text-align: left; }
.lc-typing {
    align-self: flex-start;
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
    padding: 4px 0;
}

/* ---- Closed notice ---- */
.lc-closed-notice {
    flex-shrink: 0;
    background: #fef3c7;
    border-top: 1px solid #fde68a;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    font-size: 12px;
    color: #92400e;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
}
@media (min-width: 600px) {
    .lc-closed-notice { padding: 10px 16px; }
}
.lc-new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 7px 18px;
    background: #f97316;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.01em;
    transition: background 0.15s, transform 0.1s;
}
@media (min-width: 600px) {
    .lc-new-chat-btn { min-height: 0; padding: 7px 14px; font-size: 12px; border-radius: 7px; }
}
.lc-new-chat-btn:hover  { background: #ea6c0a; }
.lc-new-chat-btn:active { transform: scale(0.97); }

/* ---- Input ----
   The safe area under the last row, except while the keyboard is up (lc-kb):
   then the keyboard is the edge and the inset would be a gap above it. */
.lc-input-wrap {
    flex-shrink: 0;
    display: flex;
    padding: 8px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
    gap: 8px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    align-items: flex-end;
}
#live-chat-root.lc-kb .lc-input-wrap,
#live-chat-root.lc-kb .lc-closed-notice {
    padding-bottom: 8px;
}
@media (min-width: 600px) {
    .lc-input-wrap { padding: 10px 12px; }
}
.lc-input {
    flex: 1;
    resize: none;
    border: 1px solid #e5e7eb;
    border-radius: 22px;
    padding: 11px 15px;
    font-size: 16px;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    font-family: inherit;
    color: #111;
    background: #f9fafb;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.35;
    box-sizing: border-box;
}
@media (min-width: 600px) {
    .lc-input {
        border-radius: 8px;
        padding: 8px 11px;
        font-size: 13px;
        min-height: 36px;
        max-height: 100px;
        line-height: 1.45;
    }
}
.lc-input:focus { border-color: #f97316; background: #fff; box-shadow: 0 0 0 3px rgba(249,115,22,0.10); }
.lc-input:disabled { background: #f3f4f6; color: #9ca3af; }

.lc-send-btn {
    width: 44px;
    height: 44px;
    background: #f97316;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.lc-send-btn svg { width: 18px; height: 18px; }
@media (min-width: 600px) {
    .lc-send-btn { width: 36px; height: 36px; border-radius: 8px; }
    .lc-send-btn svg { width: 15px; height: 15px; }
}
.lc-book-btn {
    background: #f97316;
    color: white;
    border: none;
    border-radius: 8px;
    min-height: 44px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.lc-book-btn:hover {
    background: #ea6c0a;
}
@media (hover: hover) {
    .lc-send-btn:hover { background: #ea6c0a; transform: scale(1.05); }
}
.lc-send-btn:active { transform: scale(0.97); }
.lc-send-btn:disabled { background: #d1d5db; cursor: not-allowed; transform: none; }

/* ---- Start chat button (inside contact form) ---- */
.lc-start-btn {
    width: 100%;
    min-height: 48px;
    margin-top: 14px;
    padding: 11px 16px;
    background: #f97316;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    letter-spacing: 0.01em;
    transition: background 0.15s, transform 0.1s;
}
@media (min-width: 600px) {
    .lc-start-btn { min-height: 0; border-radius: 8px; font-size: 13.5px; }
}
.lc-start-btn:hover  { background: #ea6c0a; }
.lc-start-btn:active { transform: scale(0.98); }

/* ---- Cookie consent gate ---- */
#lc-cookie-gate {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 24px calc(26px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    flex: 1;
    min-height: 240px;
    overflow-y: auto;
}
@media (min-width: 600px) {
    #lc-cookie-gate { padding: 28px 24px 26px; }
}
.lc-cg-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 360px;
}
.lc-cg-icon {
    width: 58px;
    height: 58px;
    background: #fff7ed;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f97316;
    margin-bottom: 16px;
    border: 1.5px solid #fed7aa;
    flex-shrink: 0;
}
.lc-cg-title {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    margin: 0 0 10px;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.lc-cg-desc {
    font-size: 12.5px;
    color: #6b7280;
    line-height: 1.65;
    margin: 0 0 20px;
}
.lc-cg-accept-btn {
    width: 100%;
    min-height: 48px;
    padding: 11px 16px;
    background: #f97316;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: inherit;
    letter-spacing: 0.01em;
    transition: background 0.15s, transform 0.1s;
    margin-bottom: 9px;
}
.lc-cg-accept-btn:hover  { background: #ea6c0a; }
.lc-cg-accept-btn:active { transform: scale(0.98); }
.lc-cg-settings-btn {
    width: 100%;
    min-height: 44px;
    padding: 9px 16px;
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 12.5px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
}
@media (min-width: 600px) {
    .lc-cg-accept-btn,
    .lc-cg-settings-btn { min-height: 0; }
}
.lc-cg-settings-btn:hover { border-color: #9ca3af; color: #374151; }
