/**
 * Valet AI Assistant - Public Styles
 *
 * Premium dark/gold frontend chat widget.
 */

/**
 * Prevent horizontal movement when the chat is opened.
 * This class is added/removed by JavaScript.
 */
html.valet-ai-chat-open,
body.valet-ai-chat-open {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/**
 * Strong reset only inside the widget.
 */
.valet-ai-widget,
.valet-ai-widget *,
.valet-ai-widget *::before,
.valet-ai-widget *::after {
    box-sizing: border-box;
}

/**
 * Main widget wrapper.
 */
.valet-ai-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    width: auto;
    max-width: calc(100vw - 32px);
    font-family: Arial, Helvetica, sans-serif;
    color: #ffffff;
    cursor: default !important;
}

/**
 * Force visible cursor inside the widget.
 */
.valet-ai-widget,
.valet-ai-widget div,
.valet-ai-widget span,
.valet-ai-widget form {
    cursor: default !important;
}

.valet-ai-widget button,
.valet-ai-widget .valet-ai-toggle,
.valet-ai-widget .valet-ai-close,
.valet-ai-widget .valet-ai-send,
.valet-ai-widget .valet-ai-quick-btn {
    cursor: pointer !important;
}

.valet-ai-widget input,
.valet-ai-widget .valet-ai-input {
    cursor: text !important;
}

/**
 * Basic element reset.
 */
.valet-ai-widget button,
.valet-ai-widget input {
    font-family: inherit;
    margin: 0;
}

/**
 * Floating open button.
 */
.valet-ai-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    background: #111111;
    color: #ffffff;
    padding: 14px 18px;
    min-height: 52px;
    max-width: 100%;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.valet-ai-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
}

.valet-ai-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 50%;
    background: #bf9b30;
    color: #111111;
    font-size: 15px;
    font-weight: 700;
}

.valet-ai-toggle-text {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/**
 * Chat panel desktop.
 */
.valet-ai-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    background: #101010;
    color: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
    border: 1px solid rgba(191, 155, 48, 0.32);
}

.valet-ai-panel.is-open {
    display: flex;
}

/**
 * Header.
 */
.valet-ai-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #111111, #1f1f1f);
    border-bottom: 1px solid rgba(191, 155, 48, 0.24);
}

.valet-ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.valet-ai-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    background: #bf9b30;
    color: #111111;
    font-weight: 800;
    font-size: 18px;
}

.valet-ai-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.valet-ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.valet-ai-status-dot {
    width: 7px;
    height: 7px;
    min-width: 7px;
    border-radius: 50%;
    background: #28c76f;
}

.valet-ai-close {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    padding: 4px 6px;
    opacity: 0.75;
    width: 36px;
    height: 36px;
}

.valet-ai-close:hover {
    opacity: 1;
    color: #bf9b30;
}

/**
 * Messages area.
 */
.valet-ai-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 18px;
    background:
        radial-gradient(circle at top right, rgba(191, 155, 48, 0.09), transparent 35%),
        #101010;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.valet-ai-messages::-webkit-scrollbar {
    width: 7px;
}

.valet-ai-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

.valet-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(191, 155, 48, 0.65);
    border-radius: 999px;
}

.valet-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #bf9b30;
}

.valet-ai-message {
    width: 100%;
    max-width: 100%;
    margin-bottom: 14px;
    clear: both;
}

.valet-ai-message-label {
    margin-bottom: 5px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.62);
}

.valet-ai-message-bubble {
    display: inline-block;
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.valet-ai-message-assistant .valet-ai-message-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-top-left-radius: 4px;
}

.valet-ai-message-user {
    text-align: right;
}

.valet-ai-message-user .valet-ai-message-label {
    text-align: right;
}

.valet-ai-message-user .valet-ai-message-bubble {
    background: #bf9b30;
    color: #111111;
    border-top-right-radius: 4px;
    text-align: left;
}

/**
 * Quick action buttons.
 */
.valet-ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    margin-top: 14px;
    padding: 0;
    overflow: visible;
}

.valet-ai-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    min-height: 34px;
    border: 1px solid rgba(191, 155, 48, 0.45);
    border-radius: 999px;
    background: rgba(191, 155, 48, 0.08);
    color: #f5f5f5;
    padding: 8px 11px;
    font-size: 12px;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.valet-ai-quick-btn:hover,
.valet-ai-quick-btn:focus,
.valet-ai-quick-btn.is-selected {
    background: #bf9b30;
    border-color: #bf9b30;
    color: #111111;
    transform: translateY(-1px);
    outline: none;
}

/**
 * Input form.
 */
.valet-ai-form {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    background: #151515;
    border-top: 1px solid rgba(191, 155, 48, 0.22);
    overflow: hidden;
}

#valet-ai-widget .valet-ai-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 999px !important;
    background: #ffffff !important;
    color: #111111 !important;
    padding: 0 14px !important;
    font-size: 16px !important;
    line-height: 40px !important;
    outline: none !important;
    box-shadow: none;
    -webkit-text-fill-color: #111111 !important;
    caret-color: #111111 !important;
    appearance: none;
    -webkit-appearance: none;
    transform: translateZ(0);
}

#valet-ai-widget .valet-ai-input::placeholder {
    color: rgba(17, 17, 17, 0.55) !important;
    opacity: 1;
}

#valet-ai-widget .valet-ai-input:focus {
    border-color: #bf9b30 !important;
    box-shadow: 0 0 0 2px rgba(191, 155, 48, 0.18) !important;
}

.valet-ai-send {
    flex: 0 0 auto;
    width: auto;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    border: none !important;
    border-radius: 999px !important;
    background: #bf9b30 !important;
    color: #111111 !important;
    padding: 0 14px !important;
    font-size: 12px !important;
    line-height: 40px !important;
    font-weight: 800;
    white-space: nowrap;
    appearance: none;
    -webkit-appearance: none;
}

.valet-ai-send:hover,
.valet-ai-send:focus {
    background: #d4af37 !important;
    color: #111111 !important;
    outline: none;
}

/**
 * Mobile layout.
 */
@media (max-width: 768px) {
    /**
     * Critical mobile fix:
     * The widget wrapper takes the full viewport width but does not create overflow.
     */
    .valet-ai-widget {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        pointer-events: none;
        overflow: visible !important;
    }

    /**
     * The floating button is positioned separately inside the full-width wrapper.
     */
    .valet-ai-toggle {
        position: fixed !important;
        right: 18px !important;
        bottom: 22px !important;
        width: 58px !important;
        height: 58px !important;
        min-width: 58px !important;
        min-height: 58px !important;
        padding: 0 !important;
        border-radius: 50%;
        pointer-events: auto;
    }

    .valet-ai-toggle-text {
        display: none;
    }

    .valet-ai-toggle-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
        font-size: 16px;
    }

    /**
     * Mobile chat panel.
     */
    .valet-ai-panel {
        position: fixed !important;
        left: 50% !important;
        right: auto !important;
        top: 72px !important;
        bottom: 88px !important;
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        height: auto !important;
        max-height: none !important;
        transform: translateX(-50%) translateZ(0) !important;
        border-radius: 20px;
        pointer-events: auto;
        overflow: hidden !important;
        /* JS (adjustPanelForKeyboard) sets an inline "bottom" while the
           on-screen keyboard is open, lifting the input above it. */
        transition: bottom .15s ease-out;
    }

    .valet-ai-header {
        padding: 14px;
    }

    .valet-ai-avatar {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .valet-ai-title {
        font-size: 14px;
    }

    .valet-ai-messages {
        padding: 14px;
    }

    /**
     * On mobile, quick buttons become clean stacked rows.
     */
    .valet-ai-quick-actions {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        overflow: visible;
    }

    .valet-ai-quick-btn {
        width: 100%;
        max-width: 100%;
        justify-content: center;
        white-space: normal;
        min-height: 38px;
        padding: 9px 12px;
        font-size: 12px;
    }

    /**
     * Mobile form:
     * input + submit stay inside the panel.
     */
    .valet-ai-form {
        align-items: center;
        gap: 8px;
        padding: 10px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    /**
     * IMPORTANT:
     * On iPhone/Safari, inputs below 16px font-size trigger automatic zoom/viewport shift.
     * We keep font-size at 16px to prevent the viewport from breaking when the user taps the input.
     */
    .valet-ai-input {
        flex: 1 1 auto;
        min-width: 0 !important;
        width: auto !important;
        height: 42px !important;
        min-height: 42px !important;
        max-height: 42px !important;
        line-height: 42px !important;
        font-size: 16px !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .valet-ai-send {
        flex: 0 0 76px;
        width: 76px !important;
        max-width: 76px !important;
        height: 42px !important;
        min-height: 42px !important;
        max-height: 42px !important;
        line-height: 42px !important;
        padding: 0 !important;
        font-size: 11px !important;
        text-align: center;
        overflow: hidden;
    }

    .valet-ai-message-bubble {
        max-width: 94%;
    }
}

/**
 * Very small mobile screens.
 */
@media (max-width: 390px) {
    .valet-ai-toggle {
        right: 16px !important;
        bottom: 20px !important;
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }

    .valet-ai-panel {
        top: 64px !important;
        bottom: 82px !important;
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        border-radius: 18px;
    }

    .valet-ai-form {
        gap: 6px;
        padding: 9px;
    }

    .valet-ai-input {
        font-size: 16px !important;
    }

    .valet-ai-send {
        flex-basis: 70px;
        width: 70px !important;
        max-width: 70px !important;
        font-size: 10px !important;
    }
}