/**
 * ESP Chat Widget Styles
 * Designer-style implementation with avatars and polished UI
 * Mobile-first responsive design with multi-breakpoint system
 *
 * @package ESP_Chat_Agent
 *
 * Breakpoints:
 * - Base: < 480px (mobile phones)
 * - sm: 481px+ (larger phones)
 * - md: 641px+ (tablets portrait)
 * - lg: 769px+ (tablets landscape / small desktop)
 * - xl: 1025px+ (desktop)
 */

/* Hide until Alpine loads */
[x-cloak] {
    display: none !important;
}

/* Screen reader only - accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* CSS Variables - ESP Brand Color Palette + Responsive Values */
:root {
    /* ESP Brand Colors */
    --esp-header-bg: #1f2937;         /* ESP secondary dark gray */
    --esp-header-hover: #111827;      /* Darker gray for hover */
    --esp-accent: #E6AC2C;            /* ESP brand gold */
    --esp-accent-hover: #C9941F;      /* Darker gold for hover */
    --esp-bot-avatar: #1f2937;        /* Dark gray avatar */
    --esp-user-bg: #f0f2f5;
    --esp-bot-bg: #ffffff;
    --esp-border: #e5e7eb;
    --esp-text: #1f2937;
    --esp-text-light: #4b5563;
    --esp-text-muted: #9ca3af;
    --esp-online: #4ade80;
    --esp-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --esp-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --esp-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Responsive sizing - Mobile first (base values) */
    --esp-chat-width: calc(100vw - 32px);
    --esp-chat-height: calc(100dvh - 100px);
    --esp-chat-max-height: none;
    --esp-chat-bottom: 70px;
    --esp-chat-radius: 12px;
    --esp-msg-max-width: 88%;
    --esp-msg-padding: 10px 14px;
    --esp-header-padding: 12px 16px;
    --esp-messages-padding: 12px;
    --esp-input-padding: 12px;
    --esp-font-base: 14px;
    --esp-font-message: 14px;
    --esp-font-title: 16px;
    --esp-avatar-size: 28px;
    --esp-avatar-margin: 8px;
    --esp-product-image-size: 64px;
    --esp-button-min-height: 44px;
    --esp-touch-target: 44px;

    /* Safe area fallbacks */
    --esp-safe-bottom: env(safe-area-inset-bottom, 0px);
    --esp-safe-right: env(safe-area-inset-right, 0px);
    --esp-safe-left: env(safe-area-inset-left, 0px);
}

/* Responsive breakpoints - update CSS variables */
@media (min-width: 481px) {
    :root {
        --esp-chat-width: min(420px, calc(100vw - 40px));
        --esp-chat-height: 550px;
        --esp-chat-max-height: calc(100vh - 120px);
        --esp-chat-radius: 16px;
        --esp-msg-max-width: 82%;
        --esp-msg-padding: 12px 16px;
        --esp-header-padding: 14px 18px;
        --esp-messages-padding: 14px 18px;
        --esp-avatar-size: 30px;
        --esp-avatar-margin: 10px;
        --esp-product-image-size: 72px;
    }
}

@media (min-width: 641px) {
    :root {
        --esp-chat-width: 480px;
        --esp-chat-height: 580px;
        --esp-msg-max-width: 78%;
        --esp-font-message: 15px;
        --esp-font-title: 17px;
        --esp-product-image-size: 80px;
    }
}

@media (min-width: 769px) {
    :root {
        --esp-chat-width: 580px;
        --esp-chat-height: 620px;
        --esp-chat-max-height: calc(100vh - 100px);
        --esp-msg-max-width: 75%;
        --esp-header-padding: 16px 20px;
        --esp-messages-padding: 16px 24px;
        --esp-avatar-size: 32px;
        --esp-avatar-margin: 12px;
    }
}

@media (min-width: 1025px) {
    :root {
        --esp-chat-width: 700px;
        --esp-chat-height: 650px;
        --esp-msg-max-width: 70%;
        --esp-font-title: 18px;
    }
}

/* Widget Container - Mobile first with safe area support */
.esp-chat-widget {
    position: fixed;
    bottom: max(16px, var(--esp-safe-bottom));
    right: max(16px, var(--esp-safe-right));
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--esp-font-base);
}

@media (min-width: 481px) {
    .esp-chat-widget {
        bottom: max(20px, var(--esp-safe-bottom));
        right: max(20px, var(--esp-safe-right));
    }
}

/* Chat Button - Gemini-inspired modern floating action button */
.esp-chat-button {
    width: 60px;
    height: 60px;
    min-width: var(--esp-touch-target);
    min-height: var(--esp-touch-target);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--esp-accent) 0%, var(--esp-accent-hover) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Colored glow shadow like Gemini */
    box-shadow:
        0 4px 14px rgba(230, 172, 44, 0.4),
        0 8px 25px rgba(230, 172, 44, 0.25),
        0 0 0 0 rgba(230, 172, 44, 0);
    transition:
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s ease,
        background 0.3s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Pop-in animation on load */
    animation: esp-badge-pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@media (min-width: 481px) {
    .esp-chat-button {
        width: 64px;
        height: 64px;
    }
}

/* Pop-in animation for initial appearance */
@keyframes esp-badge-pop-in {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(20px);
    }
    50% {
        opacity: 1;
    }
    70% {
        transform: scale(1.1) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Hover state with enhanced glow */
.esp-chat-button:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, var(--esp-accent-hover) 0%, #b8850f 100%);
    box-shadow:
        0 6px 20px rgba(230, 172, 44, 0.5),
        0 12px 35px rgba(230, 172, 44, 0.3),
        0 0 40px rgba(230, 172, 44, 0.2);
}

/* Remove hover scale on touch devices to avoid sticky states */
@media (hover: none) {
    .esp-chat-button:hover {
        transform: none;
        box-shadow:
            0 4px 14px rgba(230, 172, 44, 0.4),
            0 8px 25px rgba(230, 172, 44, 0.25);
    }
}

/* Active/pressed state */
.esp-chat-button:active {
    transform: scale(0.92);
    box-shadow:
        0 2px 8px rgba(230, 172, 44, 0.4),
        0 4px 12px rgba(230, 172, 44, 0.2);
}

/* Rotate button when chat is open */
.esp-chat-button.is-open {
    transform: rotate(90deg);
}

.esp-chat-button.is-open:hover {
    transform: rotate(90deg) scale(1.08);
}

.esp-chat-button.is-open:active {
    transform: rotate(90deg) scale(0.92);
}

/* Focus states for accessibility */
.esp-chat-button:focus {
    outline: 3px solid rgba(230, 172, 44, 0.5);
    outline-offset: 3px;
}

.esp-chat-button:focus:not(:focus-visible) {
    outline: none;
}

.esp-chat-button:focus-visible {
    outline: 3px solid rgba(230, 172, 44, 0.6);
    outline-offset: 3px;
}

/* Icon container for smooth transitions */
.esp-chat-icon-wrapper {
    position: relative;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 481px) {
    .esp-chat-icon-wrapper {
        width: 32px;
        height: 32px;
    }
}

/* Icons with smooth fade transitions */
.esp-chat-icon {
    position: absolute;
    width: 28px;
    height: 28px;
    color: white;
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 481px) {
    .esp-chat-icon {
        width: 32px;
        height: 32px;
    }
}

/* Chat icon visible by default, hidden when open */
.esp-chat-icon--chat {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.esp-chat-button.is-open .esp-chat-icon--chat {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
}

/* Close icon hidden by default, visible when open */
.esp-chat-icon--close {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
}

.esp-chat-button.is-open .esp-chat-icon--close {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

/* Notification Badge - Enhanced with ring effect */
.esp-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Ring effect like Gemini */
    box-shadow:
        0 0 0 3px white,
        0 2px 8px rgba(239, 68, 68, 0.4);
    /* Pop animation for new notifications */
    animation: esp-badge-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

@media (min-width: 481px) {
    .esp-chat-badge {
        font-size: 12px;
        width: 24px;
        height: 24px;
        top: -3px;
        right: -3px;
    }
}

/* Badge bounce animation for new notifications */
@keyframes esp-badge-bounce {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* Hide badge when chat is open */
.esp-chat-button.is-open .esp-chat-badge {
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Chat Window - Uses CSS variables for responsive sizing */
.esp-chat-window {
    position: absolute;
    bottom: var(--esp-chat-bottom);
    right: 0;
    width: var(--esp-chat-width);
    max-width: calc(100vw - 32px);
    height: var(--esp-chat-height);
    max-height: var(--esp-chat-max-height);
    background: var(--esp-bot-bg);
    border-radius: var(--esp-chat-radius);
    box-shadow: var(--esp-shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent content from extending into safe areas */
    padding-bottom: var(--esp-safe-bottom);
}

/* Ensure window doesn't overflow on landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .esp-chat-window {
        height: calc(100dvh - 80px);
        max-height: calc(100dvh - 80px);
    }
}

/* Animation */
.esp-chat-enter {
    transition: all 0.3s ease-out;
}
.esp-chat-enter-start {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}
.esp-chat-enter-end {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.esp-chat-leave {
    transition: all 0.2s ease-in;
}
.esp-chat-leave-start {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.esp-chat-leave-end {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

/* Header - Designer Style with Responsive Layout */
.esp-chat-header {
    background: var(--esp-accent);
    color: white;
    padding: var(--esp-header-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 8px;
    min-height: 52px;
}

.esp-chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* Enable text truncation */
    flex: 1;
}

@media (min-width: 481px) {
    .esp-chat-header-info {
        gap: 12px;
    }
}

.esp-chat-header-icon {
    width: 20px;
    height: 20px;
    color: white;
    flex-shrink: 0;
}

@media (min-width: 481px) {
    .esp-chat-header-icon {
        width: 24px;
        height: 24px;
    }
}

.esp-chat-title {
    margin: 0;
    font-size: var(--esp-font-title);
    font-weight: 600;
    letter-spacing: 0.025em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Action Buttons (Download, Clear) */
.esp-chat-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.esp-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.esp-chat-header-btn:active {
    transform: scale(0.95);
}

.esp-chat-header-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.esp-chat-header-btn svg {
    width: 18px;
    height: 18px;
}

/* Online Status Indicator - Responsive */
.esp-chat-status {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    flex-shrink: 0;
}

@media (min-width: 481px) {
    .esp-chat-status {
        padding: 6px 12px;
    }
}

.esp-chat-status-dot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 10px;
    margin-right: 0;
}

@media (min-width: 481px) {
    .esp-chat-status-dot {
        width: 12px;
        height: 12px;
        margin-right: 8px;
    }
}

.esp-chat-status-ping {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--esp-online);
    opacity: 0.75;
    animation: esp-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.esp-chat-status-dot-inner {
    position: relative;
    display: inline-flex;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--esp-online);
}

@media (min-width: 481px) {
    .esp-chat-status-dot-inner {
        width: 8px;
        height: 8px;
    }
}

/* Hide "Online" text on small screens */
.esp-chat-status-text {
    display: none;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

@media (min-width: 400px) {
    .esp-chat-status-text {
        display: inline;
    }
}

@keyframes esp-ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.esp-chat-close {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: white;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--esp-touch-target);
    min-height: var(--esp-touch-target);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.esp-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.esp-chat-close:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.esp-chat-close svg {
    width: 20px;
    height: 20px;
}

/* Messages Container - Responsive */
.esp-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--esp-messages-padding);
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--esp-bot-bg);
    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    /* Prevent horizontal overflow of content */
    overscroll-behavior: contain;
}

@media (min-width: 481px) {
    .esp-chat-messages {
        gap: 20px;
    }
}

@media (min-width: 769px) {
    .esp-chat-messages {
        gap: 24px;
    }
}

/* Welcome Message - Responsive */
.esp-chat-welcome {
    text-align: center;
    padding: 16px 8px;
}

@media (min-width: 481px) {
    .esp-chat-welcome {
        padding: 20px 16px;
    }
}

@media (min-width: 769px) {
    .esp-chat-welcome {
        padding: 24px 16px;
    }
}

.esp-chat-welcome p {
    margin: 0 0 12px;
    color: var(--esp-text);
    font-size: var(--esp-font-message);
    line-height: 1.5;
}

@media (min-width: 481px) {
    .esp-chat-welcome p {
        margin: 0 0 16px;
    }
}

.esp-chat-welcome-tip {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 10px 12px !important;
    font-size: 12px !important;
    color: #92400e !important;
    margin-bottom: 16px !important;
    line-height: 1.4 !important;
}

@media (min-width: 481px) {
    .esp-chat-welcome-tip {
        padding: 12px 16px !important;
        font-size: 13px !important;
        margin-bottom: 20px !important;
    }
}

/* Suggestion Chips - Responsive Touch Targets */
.esp-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

@media (min-width: 481px) {
    .esp-chat-suggestions {
        gap: 8px;
    }
}

.esp-chat-suggestion {
    background: white;
    border: 1px solid var(--esp-border);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--esp-text);
    cursor: pointer;
    transition: all 0.2s;
    min-height: var(--esp-touch-target);
    display: inline-flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (min-width: 481px) {
    .esp-chat-suggestion {
        padding: 8px 16px;
        min-height: auto;
    }
}

.esp-chat-suggestion:hover {
    background: var(--esp-accent);
    color: var(--esp-text);
    border-color: var(--esp-accent);
}

.esp-chat-suggestion:active {
    transform: scale(0.97);
}

.esp-chat-suggestion:focus-visible {
    outline: 2px solid var(--esp-accent);
    outline-offset: 2px;
}

/* Photo upload suggestion chip - highlight */
.esp-chat-suggestion-photo {
    background: var(--esp-accent);
    color: #1f2937;
    border-color: var(--esp-accent);
    font-weight: 600;
}

.esp-chat-suggestion-photo:hover {
    background: var(--esp-accent-hover);
    border-color: var(--esp-accent-hover);
}

/* Message Row - Designer Layout with Avatars */
.esp-chat-message-row {
    display: flex;
    width: 100%;
    margin-bottom: 0;
}

.esp-chat-message-row-user {
    justify-content: flex-end;
}

.esp-chat-message-row-assistant {
    justify-content: flex-start;
}

.esp-chat-message-wrapper {
    display: flex;
    max-width: var(--esp-msg-max-width);
}

.esp-chat-message-row-user .esp-chat-message-wrapper {
    flex-direction: row-reverse;
}

.esp-chat-message-row-assistant .esp-chat-message-wrapper {
    flex-direction: row;
}

/* Avatars - Responsive */
.esp-chat-avatar {
    flex-shrink: 0;
    width: var(--esp-avatar-size);
    height: var(--esp-avatar-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.esp-chat-avatar-bot {
    background: var(--esp-bot-avatar);
    color: white;
    margin-right: var(--esp-avatar-margin);
}

.esp-chat-avatar-user {
    background: #e5e7eb;
    color: #6b7280;
    margin-left: var(--esp-avatar-margin);
}

.esp-chat-avatar svg {
    width: 16px;
    height: 16px;
}

@media (min-width: 481px) {
    .esp-chat-avatar svg {
        width: 18px;
        height: 18px;
    }
}

/* Message Content Container */
.esp-chat-message-content-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Message Bubbles - Responsive */
.esp-chat-message-content {
    padding: var(--esp-msg-padding);
    border-radius: 16px;
    font-size: var(--esp-font-message);
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

@media (min-width: 481px) {
    .esp-chat-message-content {
        line-height: 1.6;
    }
}

.esp-chat-message-row-assistant .esp-chat-message-content {
    background: var(--esp-bot-bg);
    color: var(--esp-text);
    border: 1px solid var(--esp-border);
    border-top-left-radius: 4px;
}

.esp-chat-message-row-user .esp-chat-message-content {
    background: var(--esp-user-bg);
    color: var(--esp-text);
    border-top-right-radius: 4px;
}

.esp-chat-message-content a {
    color: var(--esp-header-bg);
    text-decoration: underline;
    word-break: break-all;
}

/* Ensure images in messages scale properly */
.esp-chat-message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Product Cards - New 2-Column Layout (25% image / 75% info) */
.esp-chat-products {
    margin-top: 8px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

@media (min-width: 481px) {
    .esp-chat-products {
        margin-top: 12px;
    }
}

.esp-chat-product-card {
    display: flex;
    flex-direction: row;
    background: white;
    border: 1px solid var(--esp-border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    gap: 10px;
}

@media (min-width: 481px) {
    .esp-chat-product-card {
        padding: 12px;
        margin-bottom: 12px;
        gap: 12px;
    }
}

.esp-chat-product-card:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Parent Column A - Image (25% width) */
.esp-chat-product-image-wrapper {
    flex: 0 0 25%;
    max-width: 25%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.esp-chat-product-image {
    width: 100%;
    max-width: 80px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    background: #f3f4f6;
    border: 1px solid #f3f4f6;
}

@media (min-width: 481px) {
    .esp-chat-product-image {
        max-width: 90px;
    }
}

@media (min-width: 641px) {
    .esp-chat-product-image {
        max-width: 100px;
    }
}

/* Parent Column B - Info (75% width) */
.esp-chat-product-info {
    flex: 0 0 75%;
    max-width: 75%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Row - Product Name (full width of info column) */
.esp-chat-product-name {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--esp-text);
    line-height: 1.3;
    /* Handle long product names - allow 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
    flex: 1;
    min-height: 0;
}

.esp-chat-product-name a {
    color: inherit;
    text-decoration: none;
}

@media (min-width: 481px) {
    .esp-chat-product-name {
        font-size: 14px;
    }
}

/* Hide the old description - SKU now in bottom row */
.esp-chat-product-description {
    display: none;
}

/* Bottom Row - 2 columns (SKU 30% | Button 70%) - price integrated into button */
.esp-chat-product-footer {
    display: grid;
    grid-template-columns: 3fr 7fr;
    align-items: start;
    gap: 6px;
    margin-top: 2px;
    padding-right: 4px;
}

@media (min-width: 481px) {
    .esp-chat-product-footer {
        gap: 8px;
        margin-top: 4px;
        padding-right: 6px;
    }
}

/* SKU Column (left - 30%) - top-left aligned */
.esp-chat-product-sku {
    font-size: 10px;
    color: var(--esp-text-muted);
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    align-self: start;
    justify-self: start;
    line-height: 1.2;
    padding-top: 2px;
}

@media (min-width: 481px) {
    .esp-chat-product-sku {
        font-size: 11px;
    }
}

/* Button Column (right - 70%) */
.esp-chat-product-button-col {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

/* ============================================
   TWO-PANEL DRAWER BUTTON - "Get Best Price"
   Left: Dark drawer (price/loading)
   Right: Gold action panel
   ============================================ */
.esp-chat-product-button {
    position: relative;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border-radius: 10px;
    width: 100%;
    padding: 0;
    border: none;
    outline: none;
    cursor: pointer;
    background: var(--esp-accent);
    box-shadow: 0 4px 12px rgba(230, 172, 44, 0.25);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 38px;
}

/* When drawer is open, use dark background to fill corners */
.esp-chat-btn--has-price,
.esp-chat-btn--loading {
    background: #1f2937;
}

@media (min-width: 481px) {
    .esp-chat-product-button {
        border-radius: 12px;
        min-height: 44px;
    }
}

/* Subtle hover effect - no transform to avoid bulge */
.esp-chat-product-button:hover:not(:disabled):not(.esp-chat-btn--has-price) {
    box-shadow: 0 6px 16px rgba(230, 172, 44, 0.4);
}

.esp-chat-product-button:active:not(:disabled) {
    transform: translateY(0);
}

/* --- LEFT DRAWER: Price/Loading Slot (~20% of button) --- */
.esp-chat-btn-drawer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #1f2937;
    color: #fff;
    transition: max-width 0.4s ease, opacity 0.3s ease;
    max-width: 0;
    opacity: 0;
    border-radius: 0;
    /* Use align-self: stretch (inherit from parent) instead of height: 100% */
    align-self: stretch;
}

.esp-chat-btn-drawer-inner {
    display: flex;
    align-items: center;
    align-self: stretch;
    justify-content: center;
    width: 58px;
    min-width: 58px;
    /* Match vertical padding with action panel (10px) */
    padding: 10px 8px;
    white-space: nowrap;
    background: #1f2937;
}

@media (min-width: 481px) {
    .esp-chat-btn-drawer-inner {
        width: 65px;
        min-width: 65px;
        /* Match vertical padding with action panel (12px) */
        padding: 12px 10px;
    }
}

/* Drawer open state - ~20% width */
.esp-chat-btn--loading .esp-chat-btn-drawer,
.esp-chat-btn--has-price .esp-chat-btn-drawer {
    max-width: 65px;
    opacity: 1;
}

@media (min-width: 481px) {
    .esp-chat-btn--loading .esp-chat-btn-drawer,
    .esp-chat-btn--has-price .esp-chat-btn-drawer {
        max-width: 75px;
    }
}

/* Inner shadow removed - was causing edge ghosting */

/* Price display in drawer */
.esp-chat-btn-price {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--esp-accent);
    line-height: 1;
    animation: esp-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media (min-width: 481px) {
    .esp-chat-btn-price {
        font-size: 16px;
    }
}

/* Loading spinner in drawer */
.esp-chat-btn-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(230, 172, 44, 0.3);
    border-top-color: var(--esp-accent);
    border-radius: 50%;
    animation: esp-spin 0.8s linear infinite;
}

/* --- RIGHT PANEL: Action Button --- */
.esp-chat-btn-action {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--esp-accent);
    color: #1f2937;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    border-radius: 0;
    /* Let parent's align-items: stretch handle height, not height: 100% */
    align-self: stretch;
}

@media (min-width: 481px) {
    .esp-chat-btn-action {
        padding: 12px 18px;
        font-size: 12px;
        gap: 8px;
    }
}

/* Shine effect disabled - was causing visual artifacts */

/* Laser scan effect during loading */
.esp-chat-btn--loading .esp-chat-btn-action::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.15) 30%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0.15) 70%, transparent 100%);
    filter: blur(2px);
    animation: esp-laser-scan 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Icon styling */
.esp-chat-btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    transform-origin: top center;
}

@media (min-width: 481px) {
    .esp-chat-btn-icon {
        width: 18px;
        height: 18px;
    }
}

/* Tag swing animation on hover */
.esp-chat-product-button:hover:not(.esp-chat-btn--loading):not(.esp-chat-btn--has-price):not(:disabled) .esp-chat-btn-icon {
    animation: esp-tag-swing 1.2s ease-in-out infinite;
}

/* Cart icon with plus badge */
.esp-chat-btn-cart-icon {
    position: relative;
}

.esp-chat-btn-cart-icon .esp-chat-btn-plus {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    stroke-width: 3;
}

/* Disabled state */
.esp-chat-product-button:disabled {
    cursor: not-allowed;
    box-shadow: none;
}

.esp-chat-product-button:disabled .esp-chat-btn-action {
    background: #e2e8f0;
    color: #94a3b8;
}

.esp-chat-product-button:disabled .esp-chat-btn-action::before {
    display: none;
}

/* --- DUAL PRICE / SAVINGS TEASE --- */
.esp-chat-dual-price-wrapper {
    display: block;
    width: 100%;
}

/* Savings tease appears below button */
.esp-chat-dual-price-wrapper .esp-chat-savings-tease {
    margin-top: 4px;
}

.esp-chat-savings-tease {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 8px;
    background: linear-gradient(135deg, rgba(22, 101, 52, 0.08) 0%, rgba(22, 101, 52, 0.04) 100%);
    border: 1px solid rgba(22, 101, 52, 0.15);
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.2;
}

.esp-chat-savings-text {
    color: #166534;
    font-weight: 500;
    white-space: nowrap;
}

.esp-chat-savings-cta {
    color: #166534;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

.esp-chat-savings-cta:hover {
    color: #14532d;
}

/* Quantity control with savings tease */
.esp-chat-dual-price-wrapper .esp-chat-quantity-control {
    justify-content: center;
}

/* --- ANIMATIONS --- */
@keyframes esp-tag-swing {
    0% { transform: rotate(0deg); }
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-10deg); }
    60% { transform: rotate(5deg); }
    80% { transform: rotate(-2deg); }
    100% { transform: rotate(0deg); }
}

@keyframes esp-laser-scan {
    0% { transform: translateX(-150%) skewX(-20deg); }
    100% { transform: translateX(250%) skewX(-20deg); }
}

@keyframes esp-slide-up {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes esp-spin {
    to { transform: rotate(360deg); }
}

/* Pulse animation for loading text */
.esp-chat-btn--loading .esp-chat-btn-text {
    animation: esp-pulse 1.5s ease-in-out infinite;
}

@keyframes esp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================
   RESPONSIVE BUTTON TEXT
   Show short text on narrow mobile displays
   ============================================ */

/* Default: show full text, hide short */
.esp-chat-btn-text--short {
    display: none !important;
}

.esp-chat-btn-text--full {
    display: inline !important;
}

/* Narrow mobile (< 340px): show short text, hide full */
@media (max-width: 340px) {
    .esp-chat-btn-text--short {
        display: inline !important;
    }

    .esp-chat-btn-text--full {
        display: none !important;
    }

    /* Also reduce button padding on very narrow screens */
    .esp-chat-product-button .esp-chat-btn-action {
        padding: 6px 8px !important;
        gap: 4px !important;
    }

    .esp-chat-product-button .esp-chat-btn-icon {
        width: 14px !important;
        height: 14px !important;
    }
}

/* Typing Indicator - Designer Style with Avatars */
.esp-chat-typing-row {
    display: flex;
    width: 100%;
    justify-content: flex-start;
}

.esp-chat-typing-wrapper {
    display: flex;
    max-width: 85%;
    flex-direction: row;
}

.esp-chat-typing-bubble {
    padding: 12px 16px;
    background: var(--esp-bot-bg);
    border: 1px solid var(--esp-border);
    border-radius: 16px;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 4px;
}

.esp-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--esp-text-muted);
    border-radius: 50%;
    animation: esp-bounce 1.4s infinite ease-in-out;
}

.esp-chat-typing-dot:nth-child(1) {
    animation-delay: 0ms;
}

.esp-chat-typing-dot:nth-child(2) {
    animation-delay: 150ms;
}

.esp-chat-typing-dot:nth-child(3) {
    animation-delay: 300ms;
}

/* Loading text for image uploads */
.esp-chat-loading-text {
    font-size: 14px;
    color: var(--esp-text);
    animation: esp-fade-pulse 1.5s ease-in-out infinite;
}

@keyframes esp-fade-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.esp-chat-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

@keyframes esp-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Input Form - Mobile-first Responsive */
.esp-chat-input-form {
    padding: var(--esp-input-padding);
    padding-bottom: max(var(--esp-input-padding), var(--esp-safe-bottom));
    background: white;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
    /* Allow dropdown menu to overflow above */
    overflow: visible;
    position: relative;
}

.esp-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background: white;
    /* Allow dropdown to overflow */
    overflow: visible;
    position: relative;
}

@media (min-width: 481px) {
    .esp-chat-input-wrapper {
        gap: 12px;
    }
}

.esp-chat-input-field-wrapper {
    position: relative;
    flex: 1;
    min-width: 0; /* Prevent overflow */
}

.esp-chat-input {
    width: 100%;
    padding: 12px 44px 12px 14px; /* Right padding for mic button */
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px; /* Prevent iOS zoom */
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--esp-text);
    min-height: var(--esp-touch-target);
    -webkit-appearance: none; /* iOS styling fix */
}

@media (min-width: 481px) {
    .esp-chat-input {
        padding: 12px 44px 12px 16px; /* Keep right padding for mic button */
        font-size: 14px;
    }
}

.esp-chat-input:focus {
    border-color: var(--esp-header-bg);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.esp-chat-input::placeholder {
    color: var(--esp-text-muted);
    font-size: 14px;
}

/* Send Button - Mobile-first with icon-only on mobile */
.esp-chat-send {
    padding: 10px;
    background: white;
    border: 1px solid var(--esp-border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--esp-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    min-width: var(--esp-touch-target);
    min-height: var(--esp-touch-target);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (min-width: 481px) {
    .esp-chat-send {
        padding: 12px 20px;
    }
}

@media (min-width: 641px) {
    .esp-chat-send {
        padding: 12px 24px;
    }
}

.esp-chat-send:hover:not(:disabled) {
    background: #f9fafb;
}

.esp-chat-send:active:not(:disabled) {
    background: #f3f4f6;
    transform: scale(0.97);
}

.esp-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.esp-chat-send:focus-visible {
    outline: 2px solid var(--esp-accent);
    outline-offset: 2px;
}

/* Icon-only on mobile, text+icon on larger screens */
.esp-chat-send svg {
    width: 18px;
    height: 18px;
    display: block;
}

.esp-chat-send-text {
    display: none;
}

@media (min-width: 481px) {
    .esp-chat-send-text {
        display: inline;
    }
}

/* Scrollbar Styling */
.esp-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.esp-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.esp-chat-messages::-webkit-scrollbar-thumb {
    background: var(--esp-border);
    border-radius: 3px;
}

.esp-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--esp-text-light);
}

/* =========================================
   Price Reveal & Add to Cart Styles
   ========================================= */

/* Button icon */
.esp-chat-btn-icon {
    margin-right: 6px;
    flex-shrink: 0;
}

/* Button content wrapper */
.esp-chat-btn-content {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Loading spinner */
.esp-chat-spinner {
    animation: esp-spin 1s linear infinite;
    margin-right: 6px;
}

@keyframes esp-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Loading state button */
.esp-chat-product-button--loading {
    opacity: 0.7;
    cursor: wait;
}

/* Send button loading state */
.esp-chat-send.is-loading {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 200%;
    animation: esp-send-pulse 1.5s ease-in-out infinite;
    cursor: wait;
}

@keyframes esp-send-pulse {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Product actions container - spans price and button columns in grid */
.esp-chat-product-actions {
    display: contents;
}

/* Revealed price display - centered in price column */
.esp-chat-product-price-revealed {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #059669;
    font-weight: 600;
    font-size: 12px;
}

@media (min-width: 481px) {
    .esp-chat-product-price-revealed {
        font-size: 13px;
    }
}

.esp-chat-check-icon {
    color: #059669;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.esp-chat-product-price-value {
    color: var(--esp-text);
    font-weight: 700;
    font-size: 12px;
}

@media (min-width: 481px) {
    .esp-chat-product-price-value {
        font-size: 13px;
    }
}

/* Call for Price text styling */
.esp-chat-call-for-price {
    font-size: 10px;
    color: var(--esp-text-muted);
    text-align: center;
    line-height: 1.2;
}

@media (min-width: 481px) {
    .esp-chat-call-for-price {
        font-size: 11px;
    }
}

/* Cart button variant - Premium Add to Cart design */
.esp-chat-product-button--cart {
    position: relative;
    overflow: hidden;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--esp-accent) !important;
    color: #1f2937 !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.025em;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 36px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(230, 172, 44, 0.35);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (min-width: 481px) {
    .esp-chat-product-button--cart {
        padding: 10px 16px;
        font-size: 12px;
        min-height: 40px;
        border-radius: 12px;
    }
}

/* Shine effect for cart button */
.esp-chat-product-button--cart::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transform: translateX(-100%);
    transition: transform 0.7s ease;
}

.esp-chat-product-button--cart:hover:not(:disabled)::before {
    transform: translateX(100%);
}

.esp-chat-product-button--cart:hover:not(:disabled) {
    background: var(--esp-accent-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(230, 172, 44, 0.5);
}

.esp-chat-product-button--cart:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(230, 172, 44, 0.3);
}

.esp-chat-product-button--cart:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
    box-shadow: none;
}

.esp-chat-product-button--cart:disabled::before {
    display: none;
}

.esp-chat-product-button--cart:focus-visible {
    outline: 2px solid var(--esp-accent);
    outline-offset: 2px;
}

/* Quantity Counter Styles - compact for grid */
.esp-chat-quantity-control {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    height: 32px;
}

@media (min-width: 481px) {
    .esp-chat-quantity-control {
        height: 34px;
    }
}

.esp-chat-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (min-width: 481px) {
    .esp-chat-qty-btn {
        width: 30px;
    }
}

.esp-chat-qty-btn:hover:not(:disabled) {
    background: #e5e7eb;
}

.esp-chat-qty-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.esp-chat-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.esp-chat-qty-btn:focus-visible {
    outline: 2px solid var(--esp-accent);
    outline-offset: -2px;
}

.esp-chat-qty-btn--minus:hover:not(:disabled) {
    background: #fee2e2;
    color: #dc2626;
}

.esp-chat-qty-btn--plus:hover:not(:disabled) {
    background: #dcfce7;
    color: #16a34a;
}

.esp-chat-qty-value {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #1f2937;
    padding: 0 2px;
    user-select: none;
}

@media (min-width: 481px) {
    .esp-chat-qty-value {
        min-width: 28px;
        font-size: 13px;
    }
}

/* =========================================
   Image Upload Styles
   ========================================= */

/* Hidden file input */
.esp-chat-image-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Image upload button - Mobile first */
.esp-chat-image-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--esp-touch-target);
    height: var(--esp-touch-target);
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    color: var(--esp-text-light);
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.esp-chat-image-btn:focus-visible {
    outline: 2px solid var(--esp-accent);
    outline-offset: 2px;
}

/* Upload button tooltip - Hidden on mobile (touch only) */
.esp-chat-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    /* Hide on touch devices */
    display: none;
}

@media (min-width: 481px) {
    .esp-chat-tooltip {
        display: block;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Tooltip arrow */
.esp-chat-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1a1a1a;
}

/* Show tooltip on hover - only on non-touch devices */
@media (hover: hover) {
    .esp-chat-image-btn:hover .esp-chat-tooltip,
    .esp-chat-image-btn:focus .esp-chat-tooltip {
        opacity: 1;
        visibility: visible;
    }
}

/* First-visit pulse animation */
@keyframes esp-first-visit-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(230, 172, 44, 0.5);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(230, 172, 44, 0);
    }
}

.esp-chat-image-btn.esp-chat-first-visit {
    animation: esp-first-visit-pulse 2s ease-in-out infinite;
    border-color: var(--esp-accent);
}

.esp-chat-image-btn.esp-chat-first-visit:hover {
    animation: none;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .esp-chat-image-btn.esp-chat-first-visit {
        animation: none;
        border-color: var(--esp-accent);
        box-shadow: 0 0 0 3px rgba(230, 172, 44, 0.3);
    }
}

/* Drag & Drop Overlay */
.esp-chat-messages {
    position: relative;
}

.esp-chat-drag-active {
    background: #fef3c7 !important;
}

.esp-chat-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(230, 172, 44, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
    margin: 8px;
}

.esp-chat-drop-content {
    text-align: center;
    color: #1f2937;
}

.esp-chat-drop-content svg {
    margin-bottom: 12px;
    color: #1f2937;
}

.esp-chat-drop-content p {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.esp-chat-image-btn:hover:not(:disabled) {
    background: #f3f4f6;
    color: var(--esp-accent);
    border-color: var(--esp-accent);
}

.esp-chat-image-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.esp-chat-image-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   ATTACHMENT DROPDOWN MENU
   Plus button with dropdown for Add Photos / Take Photo
   ============================================ */

/* Dropdown container - positions the menu relative to button */
.esp-chat-attach-dropdown {
    position: relative;
    flex-shrink: 0;
}

/* Plus button styling */
.esp-chat-plus-btn {
    transition: all 0.2s ease, transform 0.2s ease;
}

.esp-chat-plus-btn:hover:not(:disabled) {
    color: var(--esp-accent);
    border-color: var(--esp-accent);
}

.esp-chat-plus-btn.is-open {
    color: var(--esp-accent);
    border-color: var(--esp-accent);
    background: #fef3c7;
}

.esp-chat-plus-btn.is-open svg {
    transform: rotate(45deg);
}

.esp-chat-plus-btn svg {
    transition: transform 0.2s ease;
}

/* Dropdown menu - uses fixed positioning with transform to escape overflow:hidden parent */
.esp-chat-attach-menu {
    position: fixed;
    left: 0;
    top: 0;
    min-width: max-content;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 6px;
    z-index: 10000;
}

/* Dropdown animation transitions */
.esp-dropdown-enter {
    transition: all 0.15s ease-out;
}
.esp-dropdown-enter-start {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
}
.esp-dropdown-enter-end {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.esp-dropdown-leave {
    transition: all 0.1s ease-in;
}
.esp-dropdown-leave-start {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.esp-dropdown-leave-end {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
}

/* Menu item styling */
.esp-chat-attach-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.esp-chat-attach-menu-item:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.esp-chat-attach-menu-item:active {
    background: #e5e7eb;
}

.esp-chat-attach-menu-item svg {
    color: #6b7280;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.esp-chat-attach-menu-item:hover svg {
    color: var(--esp-accent);
}

/* Arrow/caret pointing down from dropdown */
.esp-chat-attach-menu::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 18px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    transform: rotate(45deg);
}

/* On narrow screens */
@media (max-width: 360px) {
    .esp-chat-input-wrapper {
        gap: 4px;
    }

    .esp-chat-plus-btn {
        width: 40px;
        height: 40px;
    }

    .esp-chat-plus-btn svg {
        width: 18px;
        height: 18px;
    }

    .esp-chat-attach-menu {
        min-width: 150px;
    }

    .esp-chat-attach-menu-item {
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* Image preview area */
.esp-chat-image-preview {
    padding: 12px 16px;
    background: #fef3c7;
    border-top: 1px solid #fcd34d;
    display: flex;
    align-items: center;
    gap: 12px;
}

.esp-chat-image-preview-inner {
    position: relative;
    display: inline-block;
}

.esp-chat-preview-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--esp-accent);
}

.esp-chat-image-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.15s, background 0.15s;
}

.esp-chat-image-remove:hover {
    transform: scale(1.1);
    background: #dc2626;
}

.esp-chat-image-label {
    font-size: 13px;
    color: #92400e;
    font-weight: 500;
}

/* User uploaded image in message */
.esp-chat-message-image {
    margin-bottom: 8px;
}

.esp-chat-uploaded-image {
    max-width: 200px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--esp-border);
    cursor: pointer;
    transition: transform 0.2s;
}

.esp-chat-uploaded-image:hover {
    transform: scale(1.02);
}

/* Message row with image shows placeholder if image was in previous session */
.esp-chat-message-row-user .esp-chat-message-content-wrapper[data-had-image]::before {
    content: "📷 Image";
    display: block;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 12px;
    color: var(--esp-text-muted);
}

/* Send button content wrapper */
.esp-chat-send-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Spinner in send button */
.esp-chat-send .esp-chat-spinner {
    margin: 0;
}

/* Image preview responsive adjustments */
.esp-chat-image-preview {
    padding: 10px 12px;
}

@media (min-width: 481px) {
    .esp-chat-image-preview {
        padding: 12px 16px;
    }
}

.esp-chat-preview-img {
    width: 50px;
    height: 50px;
}

@media (min-width: 481px) {
    .esp-chat-preview-img {
        width: 60px;
        height: 60px;
    }
}

.esp-chat-uploaded-image {
    max-width: 150px;
    max-height: 150px;
}

@media (min-width: 481px) {
    .esp-chat-uploaded-image {
        max-width: 200px;
        max-height: 200px;
    }
}

/* =========================================
   Voice Mode Styles - Mobile-first Responsive
   ========================================= */

/* Voice mode button in header */
.esp-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

@media (min-width: 481px) {
    .esp-chat-header-actions {
        gap: 12px;
    }
}

/* TTS Toggle Button (header) - inherits from .esp-chat-header-btn */
.esp-chat-tts-btn {
    /* Inherits styles from .esp-chat-header-btn */
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    position: relative;
}

/* Inactive state - muted/off appearance */
.esp-chat-tts-btn:not(.is-active) {
    opacity: 0.6;
}

/* Active state - bright green "on" indicator */
.esp-chat-tts-btn.is-active {
    color: white;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 6px;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.esp-chat-tts-btn.is-active:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6), 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Microphone Push-to-Talk Button (inside input field, right-justified) */
.esp-chat-mic-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.esp-chat-mic-btn:hover:not(:disabled) {
    color: var(--esp-accent);
    background: rgba(230, 172, 44, 0.1);
}

.esp-chat-mic-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Recording state - red pulsing */
.esp-chat-mic-btn.is-recording {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: esp-mic-pulse 1s ease-in-out infinite;
}

.esp-chat-mic-btn.is-recording svg {
    animation: esp-mic-scale 0.5s ease-in-out infinite alternate;
}

@keyframes esp-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

@keyframes esp-mic-scale {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

/* Processing state - yellow with spinner */
.esp-chat-mic-btn.is-processing {
    color: #eab308;
    background: rgba(234, 179, 8, 0.1);
    cursor: wait;
}

.esp-chat-mic-btn svg {
    width: 18px;
    height: 18px;
}

/* Recording indicator icon (filled) */
.esp-chat-mic-btn .esp-mic-recording {
    color: #ef4444;
}

/* Voice Mode Modal - Full screen on mobile */
.esp-voice-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    /* Safe area support */
    padding-bottom: var(--esp-safe-bottom);
}

@media (min-width: 641px) {
    .esp-voice-modal {
        align-items: center;
        padding: 20px;
        padding-bottom: max(20px, var(--esp-safe-bottom));
    }
}

.esp-voice-modal-content {
    width: 100%;
    max-width: none;
    max-height: 100%;
    height: 100%;
    background: #1f2937;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media (min-width: 641px) {
    .esp-voice-modal-content {
        max-width: 600px;
        max-height: calc(100vh - 40px);
        height: auto;
        border-radius: 16px;
    }
}

/* Voice modal animations */
.esp-voice-enter {
    transition: all 0.3s ease-out;
}
.esp-voice-enter-start {
    opacity: 0;
    transform: scale(0.95);
}
.esp-voice-enter-end {
    opacity: 1;
    transform: scale(1);
}
.esp-voice-leave {
    transition: all 0.2s ease-in;
}
.esp-voice-leave-start {
    opacity: 1;
    transform: scale(1);
}
.esp-voice-leave-end {
    opacity: 0;
    transform: scale(0.95);
}

/* Voice Mode Header - Responsive */
.esp-voice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    background: var(--esp-accent);
    color: #1f2937;
    gap: 8px;
    flex-shrink: 0;
}

@media (min-width: 641px) {
    .esp-voice-header {
        padding: 16px 20px;
    }
}

.esp-voice-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

@media (min-width: 641px) {
    .esp-voice-header-info {
        gap: 12px;
    }
}

.esp-voice-header-info svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

@media (min-width: 641px) {
    .esp-voice-header-info svg {
        width: 24px;
        height: 24px;
    }
}

.esp-voice-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 641px) {
    .esp-voice-title {
        font-size: 18px;
    }
}

.esp-voice-header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

@media (min-width: 641px) {
    .esp-voice-header-status {
        gap: 12px;
    }
}

.esp-voice-timer {
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
}

@media (min-width: 641px) {
    .esp-voice-timer {
        font-size: 16px;
        padding: 6px 12px;
    }
}

.esp-voice-timer-warning {
    background: #ef4444 !important;
    color: white !important;
    animation: esp-pulse 1s ease-in-out infinite;
}

@keyframes esp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.esp-voice-status {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.85;
    display: none;
}

@media (min-width: 400px) {
    .esp-voice-status {
        display: block;
        font-size: 14px;
    }
}

/* Camera Container - Responsive */
.esp-voice-camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1; /* Square on mobile */
    background: #111827;
    overflow: hidden;
    flex-shrink: 0;
}

@media (min-width: 641px) {
    .esp-voice-camera-container {
        aspect-ratio: 4/3;
    }
}

/* Landscape mobile - reduce camera size */
@media (max-height: 500px) and (orientation: landscape) {
    .esp-voice-camera-container {
        aspect-ratio: 16/9;
        max-height: 40vh;
    }
}

.esp-voice-camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Recording Indicator */
.esp-voice-recording-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.esp-voice-recording-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: esp-blink 1s ease-in-out infinite;
}

@keyframes esp-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Camera Paused Overlay */
.esp-voice-camera-paused {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    gap: 12px;
}

.esp-voice-camera-paused svg {
    opacity: 0.7;
}

.esp-voice-camera-paused span {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.8;
}

/* Audio Visualizer */
.esp-voice-visualizer {
    padding: 16px 20px;
    background: #111827;
}

.esp-voice-visualizer-bars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
}

.esp-voice-visualizer-bars span {
    width: 4px;
    height: 8px;
    background: #4b5563;
    border-radius: 2px;
    transition: height 0.1s ease-out, background 0.2s;
}

/* Active visualizer animation */
.esp-voice-visualizer[data-state="active"] .esp-voice-visualizer-bars span,
.esp-voice-visualizer[data-state="user-speaking"] .esp-voice-visualizer-bars span,
.esp-voice-visualizer[data-state="ai-speaking"] .esp-voice-visualizer-bars span {
    animation: esp-visualizer 0.5s ease-in-out infinite;
    background: var(--esp-accent);
}

.esp-voice-visualizer[data-state="user-speaking"] .esp-voice-visualizer-bars span {
    background: #4ade80;
}

.esp-voice-visualizer[data-state="ai-speaking"] .esp-voice-visualizer-bars span {
    background: #60a5fa;
}

.esp-voice-visualizer-bars span:nth-child(1) { animation-delay: 0ms; }
.esp-voice-visualizer-bars span:nth-child(2) { animation-delay: 50ms; }
.esp-voice-visualizer-bars span:nth-child(3) { animation-delay: 100ms; }
.esp-voice-visualizer-bars span:nth-child(4) { animation-delay: 150ms; }
.esp-voice-visualizer-bars span:nth-child(5) { animation-delay: 200ms; }
.esp-voice-visualizer-bars span:nth-child(6) { animation-delay: 150ms; }
.esp-voice-visualizer-bars span:nth-child(7) { animation-delay: 100ms; }
.esp-voice-visualizer-bars span:nth-child(8) { animation-delay: 50ms; }
.esp-voice-visualizer-bars span:nth-child(9) { animation-delay: 0ms; }
.esp-voice-visualizer-bars span:nth-child(10) { animation-delay: 50ms; }

@keyframes esp-visualizer {
    0%, 100% { height: 8px; }
    50% { height: 24px; }
}

/* Live Transcript - Responsive */
.esp-voice-transcript {
    flex: 1;
    min-height: 60px;
    max-height: 100px;
    overflow-y: auto;
    padding: 12px 16px;
    background: #111827;
    font-size: 13px;
    line-height: 1.5;
    color: #e5e7eb;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 641px) {
    .esp-voice-transcript {
        min-height: 100px;
        max-height: 200px;
        padding: 16px 20px;
        font-size: 14px;
        line-height: 1.6;
    }
}

.esp-voice-transcript-intro {
    color: #9ca3af;
    font-style: italic;
    margin: 0;
}

.esp-voice-msg {
    margin-bottom: 12px;
}

.esp-voice-msg-user {
    color: #4ade80;
}

.esp-voice-msg-assistant {
    color: #60a5fa;
}

.esp-voice-msg-role {
    font-weight: 600;
    margin-right: 4px;
}

.esp-voice-msg-pending .esp-voice-msg-text::after {
    content: '▌';
    animation: esp-cursor 0.5s step-end infinite;
}

@keyframes esp-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Error Display */
.esp-voice-error {
    padding: 12px 20px;
    background: #450a0a;
    color: #fca5a5;
    font-size: 14px;
    text-align: center;
}

/* Control Buttons - Mobile first */
.esp-voice-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    padding-bottom: max(16px, var(--esp-safe-bottom));
    background: #1f2937;
    flex-shrink: 0;
}

@media (min-width: 641px) {
    .esp-voice-controls {
        gap: 16px;
        padding: 20px;
    }
}

.esp-voice-control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 60px;
    min-height: var(--esp-touch-target);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (min-width: 641px) {
    .esp-voice-control-btn {
        gap: 6px;
        padding: 16px 20px;
        min-width: 70px;
    }
}

@media (hover: hover) {
    .esp-voice-control-btn:hover {
        background: #4b5563;
        transform: translateY(-2px);
    }
}

.esp-voice-control-btn:active {
    transform: scale(0.95);
}

.esp-voice-control-btn:focus-visible {
    outline: 2px solid var(--esp-accent);
    outline-offset: 2px;
}

.esp-voice-control-btn svg {
    width: 20px;
    height: 20px;
}

@media (min-width: 641px) {
    .esp-voice-control-btn svg {
        width: 24px;
        height: 24px;
    }
}

.esp-voice-btn-label {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.9;
}

@media (min-width: 641px) {
    .esp-voice-btn-label {
        font-size: 12px;
    }
}

/* Active state (muted/paused) */
.esp-voice-btn-active {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
}

.esp-voice-btn-active:hover {
    background: #dc2626 !important;
}

/* Snap button special styling */
.esp-voice-snap-btn {
    background: var(--esp-accent);
    border-color: var(--esp-accent);
    color: #1f2937;
}

.esp-voice-snap-btn:hover {
    background: var(--esp-accent-hover);
}

/* End button special styling */
.esp-voice-end-btn {
    background: #374151;
    border-color: #ef4444;
    color: #fca5a5;
}

.esp-voice-end-btn:hover {
    background: #450a0a;
    border-color: #ef4444;
    color: white;
}

/* Voice Select Dropdown (STT Pipeline) */
.esp-voice-select {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    color: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231f2937' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 24px;
}

.esp-voice-select:focus {
    outline: 2px solid rgba(0, 0, 0, 0.3);
    outline-offset: 1px;
}

@media (min-width: 641px) {
    .esp-voice-select {
        font-size: 13px;
        padding: 6px 10px;
        padding-right: 28px;
    }
}

/* Record Button (STT Pipeline) */
.esp-voice-record-btn {
    background: #22c55e !important;
    border-color: #22c55e !important;
    color: white !important;
}

.esp-voice-record-btn:hover {
    background: #16a34a !important;
    border-color: #16a34a !important;
}

.esp-voice-record-btn:active,
.esp-voice-record-btn.esp-recording {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    transform: scale(1.05);
}

/* Stop Button (STT Pipeline) */
.esp-voice-stop-btn {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: white !important;
    animation: esp-pulse 1s ease-in-out infinite;
}

.esp-voice-stop-btn:hover {
    background: #dc2626 !important;
}

/* Response Display (STT Pipeline) */
.esp-voice-response {
    padding: 12px 16px;
    background: #0f172a;
    border-top: 1px solid #1e293b;
    font-size: 13px;
    line-height: 1.5;
    color: #60a5fa;
    max-height: 80px;
    overflow-y: auto;
}

.esp-voice-response p {
    margin: 0;
}

@media (min-width: 641px) {
    .esp-voice-response {
        padding: 16px 20px;
        font-size: 14px;
        max-height: 100px;
    }
}

/* Visualizer states for STT pipeline */
.esp-voice-visualizer[data-state="recording"] .esp-voice-visualizer-bars span {
    animation: esp-visualizer 0.5s ease-in-out infinite;
    background: #ef4444;
}

.esp-voice-visualizer[data-state="transcribing"] .esp-voice-visualizer-bars span,
.esp-voice-visualizer[data-state="thinking"] .esp-voice-visualizer-bars span {
    animation: esp-visualizer-slow 1s ease-in-out infinite;
    background: var(--esp-accent);
}

.esp-voice-visualizer[data-state="speaking"] .esp-voice-visualizer-bars span {
    animation: esp-visualizer 0.5s ease-in-out infinite;
    background: #60a5fa;
}

@keyframes esp-visualizer-slow {
    0%, 100% { height: 8px; }
    50% { height: 16px; }
}

/* Processing indicator for transcription */
.esp-voice-transcript.esp-processing::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #4b5563;
    border-top-color: var(--esp-accent);
    border-radius: 50%;
    animation: esp-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

@keyframes esp-spin {
    to { transform: rotate(360deg); }
}

/* =========================================
   Accessibility: Reduced Motion Support
   ========================================= */

@media (prefers-reduced-motion: reduce) {
    /* Disable all animations */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Keep essential UI feedback but remove motion */
    .esp-chat-enter,
    .esp-chat-leave,
    .esp-voice-enter,
    .esp-voice-leave {
        transition: opacity 0.01ms !important;
    }

    /* Disable typing indicator bounce */
    .esp-chat-typing-dot {
        animation: none !important;
    }

    /* Disable voice visualizer animation */
    .esp-voice-recording-dot,
    .esp-voice-visualizer-bars span {
        animation: none !important;
    }

    .esp-voice-timer-warning {
        animation: none;
    }

    /* Keep ping indicator visible but static */
    .esp-chat-status-ping {
        animation: none !important;
        opacity: 0.5;
    }

    /* Remove hover transforms */
    .esp-chat-button:hover,
    .esp-chat-voice-btn:hover,
    .esp-voice-control-btn:hover {
        transform: none !important;
    }

    /* Chat button - skip pop-in but keep functional appearance */
    .esp-chat-button {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .esp-chat-button.is-open {
        transform: none !important;
    }

    /* Badge should appear instantly without bounce */
    .esp-chat-badge {
        animation: none !important;
    }

    /* Keep icon transitions instant but functional */
    .esp-chat-icon {
        transition: opacity 0.01ms !important;
    }

    /* Keep first-visit highlight visible without pulse */
    .esp-chat-image-btn.esp-chat-first-visit {
        animation: none;
        box-shadow: 0 0 0 3px rgba(230, 172, 44, 0.4);
    }
}

/* ============================================
   INLINE PRODUCT TILES
   Products embedded within chat message text
   Uses same grid layout as regular product cards
   ============================================ */

/* Wrapper for inline products - provides spacing within text flow */
.esp-chat-inline-product {
    display: block;
    margin: 10px 0;
    max-width: 100%;
    overflow: hidden;
}

/* Compact inline product card - uses same 25/75 split */
.esp-chat-inline-product .esp-chat-product-card {
    padding: 8px !important;
    margin-bottom: 0;
    gap: 8px !important;
}

/* Smaller image for inline products */
.esp-chat-inline-product .esp-chat-product-image-wrapper {
    flex: 0 0 20% !important;
    max-width: 20% !important;
}

.esp-chat-inline-product .esp-chat-product-image {
    max-width: 50px !important;
}

.esp-chat-inline-product .esp-chat-product-info {
    flex: 0 0 80% !important;
    max-width: 80% !important;
}

/* Compact text for inline products */
.esp-chat-inline-product .esp-chat-product-name {
    font-size: 12px !important;
    -webkit-line-clamp: 1 !important;
}

/* Compact footer grid for inline */
.esp-chat-inline-product .esp-chat-product-footer {
    grid-template-columns: 3fr 3fr 4fr !important;
    margin-top: 2px !important;
    gap: 4px !important;
}

.esp-chat-inline-product .esp-chat-product-sku {
    font-size: 9px !important;
}

.esp-chat-inline-product .esp-chat-product-price-value {
    font-size: 11px !important;
}

/* Smaller button for inline products */
.esp-chat-inline-product .esp-chat-product-button {
    padding: 0 !important;
    font-size: 10px !important;
    min-height: 32px !important;
}

.esp-chat-inline-product .esp-chat-btn-action,
.esp-chat-inline-product .esp-chat-btn-drawer {
    align-self: stretch !important;
}

/* Inline product button - unified height for both sections */
.esp-chat-inline-product .esp-chat-product-button {
    align-items: stretch !important;
}

/* Inline drawer - force height to match button */
.esp-chat-inline-product .esp-chat-btn-drawer {
    display: flex !important;
    align-items: center !important;
    height: 34px !important;
    min-height: 34px !important;
}

/* Inline drawer inner - fill drawer height and center content */
.esp-chat-inline-product .esp-chat-btn-drawer-inner {
    width: 54px !important;
    min-width: 54px !important;
    padding: 8px 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    height: 34px !important;
    min-height: 34px !important;
}

/* Inline price - match action text styling exactly */
.esp-chat-inline-product .esp-chat-btn-price {
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Inline action panel - consistent styling */
.esp-chat-inline-product .esp-chat-btn-action {
    padding: 8px 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    font-size: 11px !important;
    min-height: 30px !important;
}

/* Inline drawer open state - accommodate price width */
.esp-chat-inline-product .esp-chat-btn--has-price .esp-chat-btn-drawer,
.esp-chat-inline-product .esp-chat-btn--loading .esp-chat-btn-drawer {
    max-width: 60px !important;
}

.esp-chat-inline-product .esp-chat-btn-icon {
    width: 10px !important;
    height: 10px !important;
    margin-right: 3px;
}

/* Inline spinner for price loading */
.esp-inline-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: esp-inline-spin 0.6s linear infinite;
}

@keyframes esp-inline-spin {
    to { transform: rotate(360deg); }
}

/* Product reference text when SKU not found */
.esp-chat-product-ref {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--esp-text-light);
}
