/* ============================================================
   GenAI Floating AI Assistant Widget - Reference Aesthetic
   Clean, pristine modern white card, hero greeting,
   floating pill input, and ambient sparkle launcher.
   ============================================================ */

:host {
    all: initial;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#genai-widget-container {
    --gw-bg: #ffffff;
    --gw-bg-subtle: #f8fafc;
    --gw-text: #0f172a;
    --gw-text-muted: #64748b;
    --gw-pill-bg: #f1f5f9;
    --gw-pill-border: #e2e8f0;
    --gw-btn-dark: #0f172a;
    --gw-btn-dark-hover: #1e293b;
    --gw-primary: #1e40af;
    --gw-accent: #10b981;
    --gw-danger: #ef4444;
    --gw-card-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.06);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--gw-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    z-index: 2147483647;
}

/* Global Hidden Utility */
#genai-widget-container .genai-widget-hidden,
.genai-widget-hidden {
    display: none !important;
}

/* ---------- Sparkle Launcher Button ---------- */
#genai-widget-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #38bdf8 0%, #1e40af 60%, #0f172a 100%);
    box-shadow: 0 10px 28px rgba(30, 64, 175, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    animation: genai-widget-pulse 2.5s infinite;
}

#genai-widget-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 36px rgba(30, 64, 175, 0.65), 0 0 0 2px rgba(255, 255, 255, 0.3);
}

#genai-widget-launcher svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes genai-widget-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5), 0 10px 28px rgba(30, 64, 175, 0.45);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(56, 189, 248, 0), 0 10px 28px rgba(30, 64, 175, 0.45);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0), 0 10px 28px rgba(30, 64, 175, 0.45);
    }
}

/* ---------- Main Panel (Pristine White Card) ---------- */
#genai-widget-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 420px;
    height: 620px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    border-radius: 28px;
    background: #ffffff;
    box-shadow: var(--gw-card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2147483647;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#genai-widget-panel.genai-widget-hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    transform: translateY(24px) scale(0.96);
}

/* ---------- Header ---------- */
.genai-widget-header {
    padding: 16px 20px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.genai-widget-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.genai-widget-brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gw-accent);
    box-shadow: 0 0 8px var(--gw-accent);
}

.genai-widget-brand-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gw-text);
    letter-spacing: -0.2px;
}

.genai-widget-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.genai-widget-header-actions button {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.genai-widget-header-actions button:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: scale(1.05);
}

.genai-widget-header-actions svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

/* ---------- Body Area ---------- */
.genai-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.genai-widget-body::-webkit-scrollbar {
    width: 5px;
}

.genai-widget-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}

/* ---------- Hero Welcome ---------- */
.genai-widget-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px 8px;
    min-height: 240px;
}

.genai-widget-hero-title {
    font-size: 26px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
    margin: 0 0 20px;
    letter-spacing: -0.5px;
}

.genai-widget-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 340px;
}

.genai-widget-chip {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
}

.genai-widget-chip:hover {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

/* ---------- Messages Stream ---------- */
.genai-widget-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.genai-widget-msg {
    max-width: 82%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.genai-widget-msg-user {
    align-self: flex-end;
    background: #0f172a;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.genai-widget-msg-bot {
    align-self: flex-start;
    background: #f8fafc;
    color: #0f172a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
}

.genai-widget-msg-bot p {
    margin: 0 0 8px;
}

.genai-widget-msg-bot p:last-child {
    margin-bottom: 0;
}

.genai-widget-msg-bot ul,
.genai-widget-msg-bot ol {
    margin: 6px 0;
    padding-left: 20px;
}

.genai-widget-msg-bot a {
    color: #0284c7;
    text-decoration: underline;
}

.genai-widget-msg-bot code {
    background: #e2e8f0;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* Typing indicator */
.genai-widget-typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
}

.genai-widget-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
    opacity: 0.4;
    animation: genai-widget-blink 1.4s infinite both;
}

.genai-widget-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.genai-widget-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes genai-widget-blink {
    0%, 80%, 100% {
        opacity: 0.3;
    }
    40% {
        opacity: 0.9;
    }
}

/* ---------- Footer (Pill Input Box) ---------- */
.genai-widget-footer {
    padding: 12px 20px 16px;
}

.genai-widget-pill-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 32px;
    padding: 6px 6px 6px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.genai-widget-pill-box:focus-within {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.genai-widget-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: #0f172a;
    padding: 6px 0;
}

.genai-widget-input::placeholder {
    color: #94a3b8;
}

.genai-widget-pill-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.genai-widget-mic-btn,
.genai-widget-tts-btn {
    background: transparent;
    border: none;
    color: #475569;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.genai-widget-mic-btn:hover,
.genai-widget-tts-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.genai-widget-mic-btn.genai-widget-recording {
    background: var(--gw-danger) !important;
    color: #ffffff !important;
    animation: genai-widget-mic-pulse 1s infinite;
}

@keyframes genai-widget-mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.genai-widget-tts-btn.genai-widget-tts-active {
    color: #0284c7;
}

.genai-widget-send-btn {
    background: #0f172a;
    color: #ffffff;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.genai-widget-send-btn:hover {
    background: #1e293b;
    transform: scale(1.05);
}

.genai-widget-send-btn svg,
.genai-widget-mic-btn svg,
.genai-widget-tts-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.genai-widget-brand-footer {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
    letter-spacing: 0.2px;
}

/* ---------- Slide-in Lead Modal ---------- */
.genai-widget-lead-modal {
    position: absolute;
    inset: 0;
    background: #ffffff;
    z-index: 100;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-radius: 28px;
}

.genai-widget-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.genai-widget-modal-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.genai-widget-lead-close {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.genai-widget-lead-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.genai-widget-lead-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.genai-widget-lead-form label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: -4px;
}

.genai-widget-lead-form input,
.genai-widget-lead-form textarea {
    width: 100%;
    box-sizing: border-box;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.genai-widget-lead-form input:focus,
.genai-widget-lead-form textarea:focus {
    background: #ffffff;
    border-color: #0f172a;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.genai-widget-lead-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.genai-widget-lead-actions button {
    flex: 1;
    padding: 11px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.genai-widget-lead-submit {
    background: #0f172a;
    color: #ffffff;
    border: none;
}

.genai-widget-lead-submit:hover {
    background: #1e293b;
}

.genai-widget-lead-cancel {
    background: #f8fafc;
    border: 1px solid #e2e8f0 !important;
    color: #475569;
}

.genai-widget-lead-cancel:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.genai-widget-lead-success {
    background: rgba(16, 185, 129, 0.12);
    color: #065f46;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
    margin-top: 12px;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    #genai-widget-panel {
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }

    #genai-widget-launcher {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
}

/* ---------- Reactive CTA & Conversion Card ---------- */
.genai-cta-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 14px;
    margin: 8px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.genai-cta-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.genai-cta-title {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
}

.genai-cta-prompt {
    font-size: 12.5px;
    color: #334155;
    line-height: 1.4;
    margin: 0 0 10px 0;
}

.genai-cta-actions {
    display: flex;
    gap: 8px;
}

.genai-cta-btn-primary {
    background: var(--gw-primary, #1e40af);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.genai-cta-btn-primary:hover {
    opacity: 0.9;
}

.genai-cta-btn-dismiss {
    background: transparent;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.genai-cta-btn-dismiss:hover {
    background: #f1f5f9;
}

.genai-lead-badge {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    color: #065f46;
    font-weight: 500;
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---------- Positioning Overrides ---------- */
.genai-pos-bottom-left #genai-widget-launcher {
    left: 24px;
    right: auto;
}

.genai-pos-bottom-left #genai-widget-panel {
    left: 24px;
    right: auto;
}

/* ============================================================
   Voice Interaction Feedback & State Machine Styles
   ============================================================ */

/* Pending speech transcription bubble */
.genai-widget-msg-pending {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    color: #cbd5e1 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    font-style: italic;
}

.genai-widget-msg-pending::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    animation: genai-shimmer 1.8s infinite;
}

@keyframes genai-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* STT or voice error message bubble */
.genai-widget-msg-error {
    background: #fef2f2 !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca !important;
    font-style: normal !important;
}

/* Floating Voice Status Badge */
.genai-widget-status-badge {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin: 6px 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    animation: genai-fade-in 0.25s ease-out;
    transition: all 0.2s ease;
}

@keyframes genai-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.genai-status-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0284c7;
    animation: genai-status-pulse 1.2s infinite;
}

@keyframes genai-status-pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 6px rgba(2, 132, 199, 0.6); }
    100% { transform: scale(0.9); opacity: 0.6; }
}

/* Audio Playing Waveform (Vertical Bars) */
.genai-audio-wave {
    display: inline-flex;
    align-items: center;
    gap: 2.5px;
    height: 14px;
    vertical-align: middle;
    margin-right: 4px;
}

.genai-audio-wave span {
    display: inline-block;
    width: 3px;
    background: #0284c7;
    border-radius: 2px;
    animation: genai-audio-dance 1s ease-in-out infinite;
}

.genai-audio-wave span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.genai-audio-wave span:nth-child(2) { height: 13px; animation-delay: 0.25s; }
.genai-audio-wave span:nth-child(3) { height: 9px; animation-delay: 0.4s; }
.genai-audio-wave span:nth-child(4) { height: 14px; animation-delay: 0.15s; }

@keyframes genai-audio-dance {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1.0); }
}

/* Mic Button States */
.genai-widget-mic-btn.genai-widget-busy {
    opacity: 0.5;
    cursor: wait !important;
    pointer-events: none;
}

.genai-widget-mic-btn.genai-widget-speaking {
    color: #0284c7;
    background: #e0f2fe;
    animation: genai-widget-speaking-pulse 1.6s infinite;
}

@keyframes genai-widget-speaking-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(2, 132, 199, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0);
    }
}

/* ---------- ZCare In-Chat Booking Review Card ---------- */
.genai-booking-card {
    background: #ffffff;
    border: 1.5px solid #0284c7;
    border-radius: 16px;
    padding: 16px;
    margin: 12px 0;
    box-shadow: 0 8px 24px -4px rgba(2, 132, 199, 0.14);
    animation: genai-fade-in 0.3s ease;
}

.genai-booking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #e0f2fe;
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.genai-booking-icon {
    font-size: 24px;
    line-height: 1;
}

.genai-booking-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.genai-booking-subtitle {
    font-size: 12px;
    color: #0284c7;
    font-weight: 600;
}

.genai-booking-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.genai-booking-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    line-height: 1.4;
}

.genai-booking-label {
    color: #64748b;
    font-weight: 500;
}

.genai-booking-val {
    color: #0f172a;
    text-align: right;
    max-width: 65%;
}

.genai-booking-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.genai-booking-btn-confirm {
    width: 100%;
    padding: 11px 16px;
    border: none;
    border-radius: 10px;
    background: #10b981;
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.genai-booking-btn-confirm:hover {
    background: #059669;
}

.genai-booking-btn-confirm:active {
    transform: scale(0.98);
}

.genai-booking-btn-link {
    display: block;
    text-align: center;
    padding: 8px 12px;
    font-size: 12px;
    color: #0284c7;
    text-decoration: none;
    background: #f0f9ff;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s ease;
}

.genai-booking-btn-link:hover {
    background: #e0f2fe;
}

.genai-booking-btn-cancel {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}

.genai-booking-btn-cancel:hover {
    color: #64748b;
}

.genai-booking-success-banner {
    background: #ecfdf5;
    border: 1px solid #10b981;
    border-radius: 12px;
    padding: 14px;
    margin: 10px 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.genai-booking-success-icon {
    font-size: 22px;
    line-height: 1;
}

.genai-booking-list-link {
    display: inline-block;
    color: #059669;
    font-weight: 700;
    font-size: 12px;
    text-decoration: underline;
}

.genai-booking-fail-banner {
    background: #fef2f2;
    border: 1px solid #ef4444;
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0;
    font-size: 13px;
}
