/**
 * Docked site assistant (3.1.74, core/ai/platform/class-chat-dock.php + assets/js/tripways-dock.js).
 *
 * html.tw-dock-open     the panel is open
 * html.tw-dock-docked   and pushes the page (1200px and up; the width is in Chat_Dock::DOCK_MIN_WIDTH too)
 * html.tw-dock-overlay  or covers it: a drawer, or a full-screen sheet on phones
 *
 * Dark mode (3.1.75) works like the theme's main content: the panel is inverted and its photos and frames are
 * inverted back (assets/theme-dark.css in TripWays Theme).
 */

:root {
    --tw-dock-panel-w: clamp(380px, 27vw, 480px);
}

html.tw-dock-docked {
    --tw-dock-w: var(--tw-dock-panel-w);
}

html.tw-dock-docked body {
    margin-right: var(--tw-dock-w);
}

/* Painted with the page, before the panel markup (footer) arrives, so a restored panel never flashes empty. */
html.tw-dock-docked body::after {
    content: "";
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--tw-dock-w);
    background: #fff;
    border-left: 1px solid #e5e7eb;
    z-index: 99899;
    pointer-events: none;
}

/* Fixed page chrome moves left of the docked panel. */
html.tw-dock-docked .tripways-sticky-top-cta,
html.tw-dock-docked .tripways-sticky-cta,
html.tw-dock-docked .tripways-compare-panel__toggle,
html.tw-dock-docked .tripways-compare-panel__body {
    right: var(--tw-dock-w);
}

html.tw-dock-docked .twnc-minicart {
    right: calc(var(--tw-dock-w) + 16px);
}

html.tw-dock-docked #bokun-widgets-root .bokun-widgets-cart-wrapper {
    right: calc(var(--tw-dock-w) + 16px) !important;
}

html.tw-dock-docked #credential_picker_container {
    right: calc(var(--tw-dock-w) + 20px) !important;
}

/* The cart is a tab of the open panel; the tour page's edge tab would point at itself. */
html.tw-dock-open .tripways-tour-cart-panel__toggle {
    display: none;
}

/* === Header "Ask AI" === */
.tripways-header-ask {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px 0 12px;
    margin: 0 4px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    color: #1f4f8a;
    background: #f3f6fb;
    border: 1px solid #c9d7ea;
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tripways-header-ask:hover {
    background: #e7eef9;
    border-color: #9db8de;
}

.tripways-header-ask:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary, #2563eb);
    outline-offset: 2px;
}

.tripways-header-ask.is-active {
    color: #fff;
    background: #2f68b2;
    border-color: #2f68b2;
}

.tripways-header-ask__icon {
    display: inline-flex;
    line-height: 0;
}

html[data-theme="dark"] .tripways-header-ask:not(.is-active) {
    color: #e8eef4;
    background: transparent;
    border-color: rgba(232, 238, 244, 0.35);
}

/* Docked, the page is narrower and the open panel names itself: icon only, so the menu stays on one line. */
html.tw-dock-docked .tripways-header__actions .tripways-header-ask {
    width: 40px;
    height: 40px;
    padding: 0;
}

html.tw-dock-docked .tripways-header__actions .tripways-header-ask__label {
    display: none;
}

/* Mobile header tools: icon only, same 44px circle as the cart and theme toggles. */
.tripways-header__mobile-tools .tripways-header-ask,
.tripways-header__mobile-actions .tripways-header-ask {
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    color: inherit;
}

.tripways-header__mobile-tools .tripways-header-ask__label,
.tripways-header__mobile-actions .tripways-header-ask__label {
    display: none;
}

.tripways-header__mobile-tools .tripways-header-ask.is-active,
.tripways-header__mobile-actions .tripways-header-ask.is-active {
    color: #2f68b2;
    background: none;
}

/* === Panel === */
.tripways-dock {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 99900;
    width: var(--tw-dock-panel-w);
    display: flex;
    flex-direction: column;
    color: #111827;
    font-size: 15px;
    line-height: 1.5;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    box-sizing: border-box;
}

.tripways-dock[hidden],
.tripways-dock-backdrop[hidden] {
    display: none !important;
}

body.admin-bar .tripways-dock {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .tripways-dock {
        top: 46px;
    }
}

.tripways-dock.is-entering {
    animation: tripways-dock-in 0.24s ease-out;
}

@keyframes tripways-dock-in {
    from {
        opacity: 0;
        transform: translateX(28px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tripways-dock.is-entering {
        animation: none;
    }
}

/* Drawer (below the docking width) and full-screen sheet (phones). */
html.tw-dock-overlay .tripways-dock {
    width: min(420px, 100vw);
    box-shadow: -12px 0 36px rgba(15, 23, 42, 0.18);
}

.tripways-dock-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99890;
    background: rgba(15, 23, 42, 0.35);
}

@media (max-width: 782px) {
    html.tw-dock-overlay .tripways-dock {
        left: 0;
        width: 100vw;
        border-left: 0;
        box-shadow: none;
    }

    html.tw-dock-overlay,
    html.tw-dock-overlay body {
        overflow: hidden;
    }
}

/* Head: Assistant | Cart, new chat, close. */
.tripways-dock__head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 10px 10px 12px;
    border-bottom: 1px solid #eef0f3;
}

.tripways-dock__tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: #f1f5f9;
    border-radius: 999px;
}

.tripways-dock__tab {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: #475569;
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.tripways-dock__tab[hidden] {
    display: none;
}

.tripways-dock__tab:hover {
    color: #0f172a;
}

.tripways-dock__tab.is-active {
    color: #0f172a;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.tripways-dock__tab:focus-visible,
.tripways-dock__icon:focus-visible {
    outline: 2px solid #2f68b2;
    outline-offset: 1px;
}

.tripways-dock__tab-icon {
    display: inline-flex;
    line-height: 0;
    color: #2f68b2;
}

.tripways-dock__badge {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    box-sizing: border-box;
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-radius: 999px;
}

.tripways-dock__badge[hidden] {
    display: none;
}

.tripways-dock__tools {
    display: flex;
    gap: 2px;
}

.tripways-dock__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #64748b;
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.tripways-dock__icon:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.tripways-dock[data-tab="cart"] [data-dock-new] {
    visibility: hidden;
}

/* Panes */
.tripways-dock__pane {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.tripways-dock__pane[hidden] {
    display: none;
}

.tripways-dock__context {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 0;
    padding: 8px 16px;
    font-size: 12.5px;
    color: #64748b;
    white-space: nowrap;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.tripways-dock__context strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: #0f172a;
}

/* === Chat inside the panel === */
.tripways-dock .tripways-chat-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.tripways-dock .tripways-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 16px 6px;
}

.tripways-dock .tripways-chat-composer {
    position: static;
    flex: 0 0 auto;
    padding: 10px 12px 12px;
    background: #fff;
    border-top: 1px solid #eef0f3;
}

.tripways-dock .tripways-chat-wrap:not(.is-started) .tripways-chat-composer {
    border-top: 0;
}

.tripways-dock .tripways-chat-intro {
    margin: 0 4px 12px;
    font-size: 15px;
    line-height: 1.5;
    color: #334155;
}

.tripways-dock .tripways-chat-wrap.is-started .tripways-chat-intro {
    display: none;
}

.tripways-dock .tripways-chat-starters {
    margin: 0 0 10px;
}

.tripways-dock .tripways-chat-starters__label {
    margin-left: 4px;
}

.tripways-dock .tripways-chat-starters__list {
    flex-direction: column;
    align-items: stretch;
}

.tripways-dock .tripways-chat-starter {
    padding: 9px 12px;
    font-size: 14px;
    text-align: left;
    border-radius: 12px;
}

.tripways-dock .tripways-chat-input {
    min-width: 0;
    font-size: 16px; /* 16px keeps iOS from zooming on focus */
}

.tripways-dock .tripways-chat-message {
    max-width: 92%;
    font-size: 14.5px;
}

.tripways-dock .tripways-chat-message.assistant {
    max-width: 100%;
}

.tripways-dock .tripways-chat-message.assistant:not(.tripways-chat-message--thinking) .tripways-chat-message__text {
    display: block;
}

/* Tour cards: one swipe row, edge to edge. */
.tripways-dock .tripways-chat-cards,
.tripways-dock .tripways-tour-grid--chat {
    display: flex;
    gap: 10px;
    margin: 0 -16px 2px;
    padding: 2px 16px 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 16px;
}

.tripways-dock .tripways-chat-cards .tripways-tour-card,
.tripways-dock .tripways-tour-grid--chat .tripways-tour-card {
    flex: 0 0 232px;
    width: 232px;
    height: auto;
    scroll-snap-align: start;
}

/* Quote card: stacked, full width, and light (in dark mode the whole panel is inverted, cards included). */
.tripways-dock .tripways-quote-cards {
    max-width: none;
    margin: 0.25rem 0 0;
}

.tripways-dock .tripways-quote-card {
    grid-template-columns: 1fr;
    padding: 14px;
}

.tripways-dock .tripways-quote-card__side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.tripways-dock .tripways-quote-card__book {
    flex: 1 1 100%;
}

html[data-theme="dark"] .tripways-dock .tripways-quote-card {
    background: #fff;
    border-color: #bae6fd;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] .tripways-dock .tripways-quote-card__title {
    color: #0f172a;
}

html[data-theme="dark"] .tripways-dock .tripways-quote-card__when,
html[data-theme="dark"] .tripways-dock .tripways-quote-card__rate {
    color: #475569;
}

html[data-theme="dark"] .tripways-dock .tripways-quote-card__note,
html[data-theme="dark"] .tripways-dock .tripways-quote-card__total span {
    color: #64748b;
}

html[data-theme="dark"] .tripways-dock .tripways-quote-card__total strong {
    color: #047857;
}

/* === Dark mode: invert the panel like #primary, keep photos and the checkout frame as they are === */
html[data-theme="dark"] .tripways-dock {
    filter: invert(1) hue-rotate(180deg);
    isolation: isolate;
}

html[data-theme="dark"] .tripways-dock :is(img, video, picture, iframe) {
    filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"].tw-dock-docked body::after {
    background: #000;
    border-left-color: #1f2937;
}

/* A message waiting for the chat script (tripways-dock.js holdEarlyInput()). */
.tripways-dock .tripways-chat-wrap[data-pending] .tripways-chat-form button {
    opacity: 0.6;
    cursor: progress;
}

/* === Cart tab: the drawer body, flattened into the pane === */
.tripways-dock .tripways-dock__pane .tripways-tour-cart-panel__body {
    position: static;
    flex: 1 1 auto;
    min-height: 0;
    width: auto;
    min-width: 0;
    max-height: none;
    border: 0;
    box-shadow: none;
    transform: none;
    transition: none;
    z-index: auto;
}

.tripways-dock .tripways-tour-cart-panel__head {
    display: none;
}
