/* AI Expertise demo widget v1.3.0.0 — bottom sheet / docked panel */

.ai-expertise {
    position: fixed;
    z-index: 99980;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(96px, calc(env(safe-area-inset-bottom, 0px) + 80px));
    pointer-events: none;
}

.ai-expertise__launcher {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 48px;
    min-height: 48px;
    padding: 12px 18px;
    border: 1px solid rgba(59, 130, 246, 0.45);
    border-radius: 999px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 12px 32px -8px rgba(59, 130, 246, 0.55);
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    touch-action: manipulation;
}

.ai-expertise__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px -10px rgba(59, 130, 246, 0.65);
}

.ai-expertise.is-open .ai-expertise__launcher {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.92);
}

body.ai-expertise-open .wa-float-cta,
body.ai-expertise-open .floating-cta-hire {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ai-expertise__overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99981;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.ai-expertise.is-open .ai-expertise__overlay {
    opacity: 1;
    visibility: visible;
}

.ai-expertise__panel {
    position: fixed;
    z-index: 99982;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 24px 64px -16px rgba(15, 23, 42, 0.35);
    pointer-events: auto;
    overflow: hidden;
    min-height: 0;
    visibility: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
}

.ai-expertise.is-open .ai-expertise__panel {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-expertise__handle {
    display: none;
    width: 40px;
    height: 4px;
    margin: 10px auto 4px;
    border-radius: 999px;
    background: #cbd5e1;
    flex-shrink: 0;
}

.ai-expertise__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.ai-expertise__eyebrow {
    margin: 0 0 4px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3b82f6;
}

.ai-expertise__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
}

.ai-expertise__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
}

.ai-expertise__close:hover {
    background: #f8fafc;
    color: #0f172a;
}

.ai-expertise__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ai-expertise__lead {
    margin: 0;
    padding: 12px 20px 8px;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: #64748b;
}

.ai-expertise__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 12px;
}

.ai-expertise__chip {
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.75rem;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    touch-action: manipulation;
}

.ai-expertise__chip:hover,
.ai-expertise__chip:focus-visible {
    border-color: #93c5fd;
    color: #1d4ed8;
    outline: none;
}

.ai-expertise__log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 20px 16px;
    min-height: 0;
}

.ai-expertise__msg {
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ai-expertise__msg--user {
    align-self: flex-end;
    max-width: 88%;
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
}

.ai-expertise__msg--bot {
    align-self: flex-start;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

.ai-expertise__msg-text {
    margin: 0;
}

.ai-expertise__msg-foot {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.ai-expertise__source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #1d4ed8;
    text-decoration: none;
}

.ai-expertise__source:hover,
.ai-expertise__source:focus-visible {
    text-decoration: underline;
    outline: none;
}

.ai-expertise__msg--boundary {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #78350f;
}

.ai-expertise__msg--guardrail {
    background: #fef2f2;
    border-color: #fecaca;
    color: #7f1d1d;
}

.ai-expertise__typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 44px;
    width: auto;
    padding: 14px 18px;
}

.ai-expertise__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ai-expertise-dot 1.2s ease-in-out infinite;
}

.ai-expertise__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-expertise__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ai-expertise-dot {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.ai-expertise__composer {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 8px;
    align-items: center;
    padding: 12px 16px max(16px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.ai-expertise__input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.35;
    background: #f8fafc;
}

.ai-expertise__input:focus {
    outline: 2px solid rgba(59, 130, 246, 0.35);
    outline-offset: 0;
    border-color: #93c5fd;
    background: #fff;
}

.ai-expertise__send {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    background: #3b82f6;
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.ai-expertise__send:hover {
    background: #2563eb;
}

/* Desktop: docked panel, no dim overlay */
@media (min-width: 1024px) {
    .ai-expertise__overlay {
        display: none;
    }

    .ai-expertise__panel {
        top: 88px;
        right: 20px;
        bottom: auto;
        left: auto;
        width: min(400px, calc(100vw - 40px));
        height: min(560px, calc(100vh - 120px));
        max-height: min(560px, calc(100vh - 120px));
        border-radius: 20px;
    }

    .ai-expertise.is-open .ai-expertise__launcher {
        opacity: 0;
        visibility: hidden;
    }
}

/* Mobile / tablet: true bottom sheet */
@media (max-width: 1023px) {
    .ai-expertise__launcher-text {
        display: none;
    }

    .ai-expertise__handle {
        display: block;
    }

    .ai-expertise__panel {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: min(78dvh, 640px);
        max-height: min(78dvh, 640px);
        border-radius: 20px 20px 0 0;
        border-bottom: none;
        transform: translateY(100%);
    }

    .ai-expertise.is-open .ai-expertise__panel {
        transform: translateY(0);
    }

    .ai-expertise__head {
        padding-top: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-expertise__panel,
    .ai-expertise__overlay,
    .ai-expertise__launcher {
        transition: none;
    }
}
