/* ═══════════════════════════════════════════════
   CHAT WIDGET UNA — UNITAS Design System
   ═══════════════════════════════════════════════ */

/* ─── Variables ─── */
:root {
    --chat-bg: #141925;
    --chat-header-bg: #0B0F1A;
    --chat-msg-bot: rgba(255, 255, 255, 0.04);
    --chat-msg-user: rgba(100, 181, 246, 0.12);
    --chat-ember: #E8613A;
    --chat-ember-hover: #F07A55;
    --chat-ember-glow: rgba(232, 97, 58, 0.15);
    --chat-ice: #64B5F6;
    --chat-ice-light: #90CAF9;
    --chat-snow: #F1F3F7;
    --chat-mist: #B0B8C9;
    --chat-fog: #6B7A91;
    --chat-ash: #2D3548;
    --chat-slate: #1E2433;
    --chat-obsidian: #0B0F1A;
    --chat-radius-lg: 16px;
    --chat-radius-md: 10px;
    --chat-radius-sm: 8px;
    --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --chat-transition: 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Floating Button ─── */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-ember);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--chat-ember-glow), 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 200ms ease, box-shadow 200ms ease;
    animation: chatFabPulse 3s ease-in-out infinite;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(232, 97, 58, 0.35), 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-fab svg {
    width: 24px;
    height: 24px;
    fill: white;
    transition: transform 200ms ease, opacity 150ms ease;
}

.chat-fab .chat-fab__close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.chat-fab--open .chat-fab__icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.chat-fab--open .chat-fab__close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.chat-fab--open {
    animation: none;
}

@keyframes chatFabPulse {

    0%,
    100% {
        box-shadow: 0 0 20px var(--chat-ember-glow), 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 28px rgba(232, 97, 58, 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

/* ─── Chat Container ─── */
.chat-widget {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    height: 520px;
    background: var(--chat-bg);
    border-radius: var(--chat-radius-lg);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity var(--chat-transition), transform var(--chat-transition);
}

.chat-widget--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ─── Header ─── */
.chat-widget__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-ash);
    flex-shrink: 0;
}

.chat-widget__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chat-ember-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-widget__avatar span {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--chat-ember);
}

.chat-widget__info {
    flex: 1;
    min-width: 0;
}

.chat-widget__name {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: var(--chat-snow);
    line-height: 1.2;
}

.chat-widget__status {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--chat-fog);
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ADE80;
    flex-shrink: 0;
}

/* ─── Messages Area ─── */
.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-ash) transparent;
}

.chat-widget__messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-widget__messages::-webkit-scrollbar-thumb {
    background: var(--chat-ash);
    border-radius: 4px;
}

/* ─── Message Bubbles ─── */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--chat-radius-md);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    animation: chatMsgIn 200ms ease-out both;
}

.chat-msg--bot {
    align-self: flex-start;
    background: var(--chat-msg-bot);
    color: var(--chat-mist);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
}

.chat-msg--user {
    align-self: flex-end;
    background: var(--chat-msg-user);
    color: var(--chat-snow);
    border-bottom-right-radius: 4px;
}

.chat-msg--bot strong {
    color: var(--chat-snow);
    font-weight: 600;
}

@keyframes chatMsgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Typing Indicator ─── */
.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-msg-bot);
    border-radius: var(--chat-radius-md);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-fog);
    animation: chatTypingDot 1.2s ease-in-out infinite;
}

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

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

@keyframes chatTypingDot {

    0%,
    60%,
    100% {
        opacity: 0.4;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* ─── Quick Replies ─── */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 8px;
    animation: chatMsgIn 200ms ease-out 100ms both;
}

.chat-quick-reply {
    padding: 8px 14px;
    border: 1px solid rgba(100, 181, 246, 0.25);
    border-radius: 20px;
    background: transparent;
    color: var(--chat-ice);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
}

.chat-quick-reply:hover {
    background: rgba(100, 181, 246, 0.1);
    border-color: var(--chat-ice-light);
    color: var(--chat-ice-light);
}

.chat-quick-reply:active {
    transform: scale(0.96);
}

/* ─── Product Cards ─── */
.chat-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 8px;
    animation: chatMsgIn 200ms ease-out 100ms both;
}

.chat-card {
    background: var(--chat-slate);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--chat-radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 200ms ease;
}

.chat-card:hover {
    border-color: rgba(232, 97, 58, 0.3);
    background: rgba(30, 36, 51, 0.9);
    transform: translateY(-1px);
}

.chat-card--featured {
    border-color: rgba(232, 97, 58, 0.2);
    position: relative;
}

.chat-card--featured::before {
    content: 'Mais contratado';
    position: absolute;
    top: -8px;
    left: 14px;
    background: var(--chat-ember);
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-card__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.chat-card__name {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--chat-snow);
}

.chat-card__price {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--chat-ember);
    font-weight: 600;
}

.chat-card__features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-card__features li {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--chat-fog);
    padding-left: 14px;
    position: relative;
}

.chat-card__features li::before {
    content: '·';
    position: absolute;
    left: 4px;
    color: var(--chat-fog);
}

/* ─── Input Area ─── */
.chat-widget__input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--chat-header-bg);
    border-top: 1px solid var(--chat-ash);
    flex-shrink: 0;
}

.chat-widget__input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--chat-ash);
    border-radius: var(--chat-radius-sm);
    padding: 10px 14px;
    color: var(--chat-snow);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 200ms ease;
}

.chat-widget__input input::placeholder {
    color: var(--chat-fog);
}

.chat-widget__input input:focus {
    border-color: rgba(100, 181, 246, 0.4);
}

.chat-widget__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--chat-ember);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, transform 150ms ease;
    flex-shrink: 0;
}

.chat-widget__send:hover {
    background: var(--chat-ember-hover);
}

.chat-widget__send:active {
    transform: scale(0.92);
}

.chat-widget__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-widget__send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 480px) {
    .chat-widget {
        width: 100%;
        height: 85vh;
        bottom: 0;
        right: 0;
        border-radius: var(--chat-radius-lg) var(--chat-radius-lg) 0 0;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
    }
}

/* ─── Accessibility ─── */
@media (prefers-reduced-motion: reduce) {

    .chat-fab,
    .chat-widget,
    .chat-msg,
    .chat-quick-replies,
    .chat-typing span {
        animation: none !important;
        transition: opacity 100ms ease !important;
    }
}

/* ─── Audio Player (for jingles) ─── */
.chat-audio {
    width: 100%;
    padding: 4px 0 8px;
    animation: chatMsgIn 200ms ease-out 100ms both;
}

.chat-audio audio {
    width: 100%;
    height: 36px;
    border-radius: var(--chat-radius-sm);
}

/* ─── WhatsApp Handoff Button ─── */
.chat-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #25D366;
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 150ms ease;
    text-decoration: none;
    margin-top: 4px;
}

.chat-wa-btn:hover {
    background: #20BD5A;
    transform: translateY(-1px);
}

.chat-wa-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}