/*!
 * Pxcraftt Booking & Chat — Frontend Widget Scoped CSS
 *
 * Every selector is prefixed with #px-booking-widget-wrapper so the theme's
 * global styles (which often use broad selectors like `* {}` or `button {}`)
 * cannot leak INTO our widget. Conversely, our styles cannot leak OUT.
 *
 * The CSS is intentionally vanilla — no Tailwind here, because the widget is
 * the most fragile surface area for theme conflicts (it appears on every page).
 */

/* --------------------------------------------------- *
 * GLOBAL RESET (scoped to the widget)
 * --------------------------------------------------- */
#px-booking-widget-wrapper,
#px-booking-widget-wrapper *,
#px-booking-widget-wrapper *::before,
#px-booking-widget-wrapper *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 0;
    color: #0f0f0f;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    vertical-align: baseline;
    list-style: none;
    transition: none;
    outline: 0;
}

/* --------------------------------------------------- *
 * SHELL
 * --------------------------------------------------- */
#px-booking-widget-wrapper.pxc-widget-shell {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99998;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
    --pxc-ink: #0f0f0f;
    --pxc-paper: #ffffff;
    --pxc-line: #e5e5e5;
    --pxc-faint: #f8f9fa;
    --pxc-mute: #777777;
    --pxc-fade: #aaaaaa;
}

#px-booking-widget-wrapper * { pointer-events: auto; }

#px-booking-widget-wrapper .pxc-widget-panel {
    height: 540px;
    max-height: min(680px, calc(100vh - 100px));
    overflow: hidden;
    border: 1px solid var(--pxc-line);
    border-radius: 18px;
    background: var(--pxc-paper);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    box-shadow: 0 8px 32px rgba(15, 15, 15, 0.18);
}

#px-booking-widget-wrapper .pxc-widget-panel[hidden] { display: none; }

#px-booking-widget-wrapper .pxc-widget-fab {
    display: none;
    width: 58px;
    height: 58px;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid var(--pxc-ink);
    border-radius: 999px;
    background: var(--pxc-ink);
    color: #ffffff;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 160ms ease, transform 160ms ease;
    box-shadow: 0 4px 16px rgba(15, 15, 15, 0.22);
}
#px-booking-widget-wrapper .pxc-widget-fab svg { color: #ffffff; width: 26px; height: 26px; }
#px-booking-widget-wrapper .pxc-widget-fab:hover { background: #292929; transform: translateY(-2px); }
#px-booking-widget-wrapper .pxc-widget-fab.is-visible { display: flex; }
#px-booking-widget-wrapper .pxc-widget-fab-dot {
    position: absolute;
    right: 3px;
    top: 3px;
    height: 12px;
    width: 12px;
    border-radius: 999px;
    border: 2px solid var(--pxc-ink);
    background: #ffffff;
}

/* --------------------------------------------------- *
 * HEADER
 * --------------------------------------------------- */
#px-booking-widget-wrapper .pxc-widget-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--pxc-line);
    padding: 16px 20px;
    background: var(--pxc-paper);
}
#px-booking-widget-wrapper .pxc-widget-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
#px-booking-widget-wrapper .pxc-widget-brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pxc-line);
    border-radius: 999px;
    background: var(--pxc-paper);
}
#px-booking-widget-wrapper .pxc-widget-brand-icon svg { width: 18px; height: 18px; color: var(--pxc-ink); }
#px-booking-widget-wrapper .pxc-widget-brand-name {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--pxc-ink);
}
#px-booking-widget-wrapper .pxc-widget-presence {
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--pxc-mute);
}
#px-booking-widget-wrapper .pxc-widget-presence-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--pxc-ink);
}
#px-booking-widget-wrapper .pxc-widget-icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: transparent;
    color: var(--pxc-mute);
    cursor: pointer;
    transition: background-color 120ms ease;
}
#px-booking-widget-wrapper .pxc-widget-icon-btn:hover { background: var(--pxc-faint); color: var(--pxc-ink); }
#px-booking-widget-wrapper .pxc-widget-icon-btn svg { width: 17px; height: 17px; }

/* --------------------------------------------------- *
 * CONTENT — TABS
 * --------------------------------------------------- */
#px-booking-widget-wrapper .pxc-widget-content {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--pxc-paper);
}
#px-booking-widget-wrapper .pxc-chat-view,
#px-booking-widget-wrapper .pxc-booking-view {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}
#px-booking-widget-wrapper .pxc-booking-view { padding: 16px 20px; }
#px-booking-widget-wrapper [hidden] { display: none !important; }

/* --------------------------------------------------- *
 * CHAT VIEW
 * --------------------------------------------------- */
#px-booking-widget-wrapper .pxc-chat-view-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
}
#px-booking-widget-wrapper .pxc-chat-view-label { font-size: 11px; font-weight: 500; color: var(--pxc-ink); }
#px-booking-widget-wrapper .pxc-chat-view-hint { font-size: 10px; color: var(--pxc-fade); }
#px-booking-widget-wrapper .pxc-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d7d7d7 transparent;
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
#px-booking-widget-wrapper .pxc-chat-messages::-webkit-scrollbar { width: 5px; }
#px-booking-widget-wrapper .pxc-chat-messages::-webkit-scrollbar-thumb { border-radius: 8px; background: #d7d7d7; }
#px-booking-widget-wrapper .pxc-chat-day { text-align: center; font-size: 10px; color: var(--pxc-fade); }
#px-booking-widget-wrapper .pxc-chat-bubble {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
#px-booking-widget-wrapper .pxc-chat-bubble-incoming .pxc-chat-avatar {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 999px;
    background: #f2f2f2;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 600;
}
#px-booking-widget-wrapper .pxc-chat-bubble p { margin: 0; }
#px-booking-widget-wrapper .pxc-chat-meta {
    font-size: 10px;
    color: var(--pxc-mute);
    margin-bottom: 4px;
}
#px-booking-widget-wrapper .pxc-chat-bubble-body {
    max-width: 240px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 12px;
    line-height: 1.55;
}
#px-booking-widget-wrapper .pxc-chat-bubble-incoming .pxc-chat-bubble-body {
    border: 1px solid var(--pxc-line);
    background: var(--pxc-paper);
    color: #333333;
    border-bottom-left-radius: 5px;
}
#px-booking-widget-wrapper .pxc-chat-bubble-outgoing {
    justify-content: flex-end;
}
#px-booking-widget-wrapper .pxc-chat-bubble-outgoing .pxc-chat-bubble-body {
    border: 1px solid var(--pxc-ink);
    background: var(--pxc-ink);
    color: #ffffff;
    border-bottom-right-radius: 5px;
}
#px-booking-widget-wrapper .pxc-chat-form {
    flex-shrink: 0;
    border-top: 1px solid var(--pxc-line);
    padding: 12px 16px;
}
#px-booking-widget-wrapper .pxc-chat-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--pxc-line);
    border-radius: 8px;
    padding: 8px 12px;
}
#px-booking-widget-wrapper .pxc-chat-input-wrap:focus-within { border-color: #999; }
#px-booking-widget-wrapper .pxc-chat-input-wrap input {
    min-width: 0;
    flex: 1;
    background: transparent;
    border: 0;
    outline: 0;
    font-size: 12px;
    color: var(--pxc-ink);
}
#px-booking-widget-wrapper .pxc-chat-input-wrap input::placeholder { color: var(--pxc-fade); }
#px-booking-widget-wrapper .pxc-chat-send {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 0;
    border-radius: 6px;
    background: var(--pxc-ink);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#px-booking-widget-wrapper .pxc-chat-send:hover { background: #333; }
#px-booking-widget-wrapper .pxc-chat-send svg { width: 14px; height: 14px; }
#px-booking-widget-wrapper .pxc-chat-form-hint {
    margin-top: 8px;
    text-align: center;
    font-size: 9px;
    color: var(--pxc-fade);
}

/* --------------------------------------------------- *
 * BOOKING VIEW
 * --------------------------------------------------- */
#px-booking-widget-wrapper .pxc-booking-head { margin-bottom: 16px; }
#px-booking-widget-wrapper .pxc-booking-title { font-size: 14px; font-weight: 600; letter-spacing: -0.03em; }
#px-booking-widget-wrapper .pxc-booking-subtitle { margin-top: 4px; font-size: 11px; color: var(--pxc-mute); }

#px-booking-widget-wrapper .pxc-booking-calendar-card {
    border: 1px solid var(--pxc-line);
    border-radius: 12px;
    padding: 16px;
}
#px-booking-widget-wrapper .pxc-booking-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
#px-booking-widget-wrapper .pxc-booking-month { font-size: 12px; font-weight: 600; }
#px-booking-widget-wrapper .pxc-booking-month-nav { display: flex; gap: 4px; }
#px-booking-widget-wrapper .pxc-booking-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    justify-items: center;
    margin-bottom: 8px;
    font-size: 9px;
    text-transform: uppercase;
    color: var(--pxc-fade);
    letter-spacing: 0.08em;
}
#px-booking-widget-wrapper .pxc-booking-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    justify-items: center;
    gap: 4px 0;
}
#px-booking-widget-wrapper .pxc-day-button {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: #333;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
#px-booking-widget-wrapper .pxc-day-button:hover:not(:disabled) { background: #f3f3f3; }
#px-booking-widget-wrapper .pxc-day-button.selected { background: var(--pxc-ink); color: #ffffff; }
#px-booking-widget-wrapper .pxc-day-button.today:not(.selected) { border-color: var(--pxc-ink); }
#px-booking-widget-wrapper .pxc-day-button:disabled { cursor: default; color: #c4c4c4; }
#px-booking-widget-wrapper .pxc-day-spacer { width: 34px; height: 34px; }

#px-booking-widget-wrapper .pxc-booking-slots-wrap { margin-top: 16px; }
#px-booking-widget-wrapper .pxc-booking-slots-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
#px-booking-widget-wrapper .pxc-booking-slots-label { font-size: 11px; font-weight: 500; }
#px-booking-widget-wrapper .pxc-booking-slots-date { font-size: 10px; color: var(--pxc-mute); }
#px-booking-widget-wrapper .pxc-booking-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
#px-booking-widget-wrapper .pxc-time-slot {
    min-height: 38px;
    border: 1px solid var(--pxc-line);
    border-radius: 8px;
    background: var(--pxc-paper);
    color: #333;
    font-size: 11px;
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
#px-booking-widget-wrapper .pxc-time-slot:hover { border-color: var(--pxc-ink); background: var(--pxc-faint); }
#px-booking-widget-wrapper .pxc-time-slot.selected { border-color: var(--pxc-ink); background: var(--pxc-ink); color: #ffffff; }
#px-booking-widget-wrapper .pxc-booking-slots-empty { margin-top: 8px; font-size: 10px; color: var(--pxc-mute); }

#px-booking-widget-wrapper .pxc-booking-form { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
#px-booking-widget-wrapper .pxc-field-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--pxc-ink);
}
#px-booking-widget-wrapper .pxc-field-label input {
    display: block;
    width: 100%;
    margin-top: 4px;
    border: 1px solid var(--pxc-line);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    background: var(--pxc-paper);
    color: var(--pxc-ink);
}
#px-booking-widget-wrapper .pxc-field-label input::placeholder { color: var(--pxc-fade); }
#px-booking-widget-wrapper .pxc-field-label input:focus { border-color: var(--pxc-ink); outline: 0; }

#px-booking-widget-wrapper .pxc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--pxc-ink);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
#px-booking-widget-wrapper .pxc-btn-primary { background: var(--pxc-ink); color: #ffffff; }
#px-booking-widget-wrapper .pxc-btn-primary:hover { background: #333; }
#px-booking-widget-wrapper .pxc-btn-primary:disabled { background: #bdbdbd; border-color: #bdbdbd; cursor: not-allowed; }
#px-booking-widget-wrapper .pxc-btn-block { width: 100%; }
#px-booking-widget-wrapper .pxc-booking-message { margin-top: 8px; min-height: 14px; text-align: center; font-size: 10px; color: var(--pxc-mute); }

/* --------------------------------------------------- *
 * TAB BAR
 * --------------------------------------------------- */
#px-booking-widget-wrapper .pxc-widget-tabs {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-top: 1px solid var(--pxc-line);
    background: var(--pxc-paper);
}
#px-booking-widget-wrapper .pxc-widget-tab {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--pxc-mute);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 120ms ease;
}
#px-booking-widget-wrapper .pxc-widget-tab svg { width: 16px; height: 16px; }
#px-booking-widget-wrapper .pxc-widget-tab:hover { color: var(--pxc-ink); }
#px-booking-widget-wrapper .pxc-widget-tab.is-active { border-bottom-color: var(--pxc-ink); color: var(--pxc-ink); }

/* --------------------------------------------------- *
 * TOASTS + MODAL (re-used inside the widget)
 * --------------------------------------------------- */
#px-booking-widget-wrapper .pxc-toast-region {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(360px, calc(100vw - 40px));
    pointer-events: none;
}
#px-booking-widget-wrapper .pxc-toast-region * { pointer-events: auto; }
#px-booking-widget-wrapper .pxc-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--pxc-ink);
    background: var(--pxc-paper);
    padding: 12px 16px;
    color: var(--pxc-ink);
    box-shadow: 0 4px 16px rgba(15, 15, 15, 0.12);
    animation: pxc-toast-in 180ms ease-out both;
}
@keyframes pxc-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

#px-booking-widget-wrapper .pxc-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 15, 0.25);
    padding: 24px;
}
#px-booking-widget-wrapper .pxc-modal-panel {
    width: 100%;
    max-width: 420px;
    border: 1px solid #DCDCDC;
    background: var(--pxc-paper);
    padding: 24px;
}
#px-booking-widget-wrapper .pxc-modal-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--pxc-line);
    color: var(--pxc-ink);
}
#px-booking-widget-wrapper .pxc-modal-icon svg { width: 18px; height: 18px; }
#px-booking-widget-wrapper .pxc-modal-title { margin-top: 20px; font-size: 17px; font-weight: 600; }
#px-booking-widget-wrapper .pxc-modal-description { margin-top: 8px; font-size: 12px; color: var(--pxc-mute); }
#px-booking-widget-wrapper .pxc-modal-actions {
    margin-top: 28px;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 8px;
}
#px-booking-widget-wrapper .pxc-btn-secondary {
    background: var(--pxc-paper);
    color: #222;
    border: 1px solid #D8D8D8;
    border-radius: 4px;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}
#px-booking-widget-wrapper .pxc-btn-secondary:hover { background: var(--pxc-faint); }

/* --------------------------------------------------- *
 * RESPONSIVE
 * --------------------------------------------------- */
@media (max-width: 480px) {
    #px-booking-widget-wrapper.pxc-widget-shell {
        right: 16px;
        bottom: 16px;
        width: min(350px, calc(100vw - 32px));
    }
    #px-booking-widget-wrapper .pxc-widget-panel {
        height: min(540px, calc(100dvh - 88px));
        border-radius: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #px-booking-widget-wrapper *,
    #px-booking-widget-wrapper *::before,
    #px-booking-widget-wrapper *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Utility */
#px-booking-widget-wrapper .pxc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
#px-booking-widget-wrapper .pxc-hidden { display: none !important; }

/* =========================================================
 * AI typing indicator (v1.1.0) — shown while Groq generates a reply.
 * ======================================================= */
#px-booking-widget-wrapper .pxc-chat-typing .pxc-chat-bubble-body {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 44px;
}
#px-booking-widget-wrapper .pxc-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: .3;
    animation: pxcTypingBlink 1.2s infinite ease-in-out;
}
#px-booking-widget-wrapper .pxc-typing-dot:nth-child(2) { animation-delay: .18s; }
#px-booking-widget-wrapper .pxc-typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes pxcTypingBlink {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}
