/* Platform-assistant chat widget — floating launcher + panel.
   Markup: debt/templates/debt/includes/_chat_widget.html
   Behaviour: static/js/debt_campaign/chat-widget.js */

.cw-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 8500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.1rem;
    background: #F59E0B;
    color: #1A1A1A;
    border: 0;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    transition: transform 150ms ease, background 150ms ease;
}
.cw-launcher:hover { background: #FBBF24; transform: translateY(-2px); }
.cw-launcher:focus-visible {
    outline: 3px solid #34D399;
    outline-offset: 3px;
}
.cw-launcher svg { width: 18px; height: 18px; }
.cw-launcher[aria-expanded="true"] { display: none; }

.cw-panel {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 8500;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 2rem));
    height: min(560px, calc(100vh - 2rem));
    background: #0A0E27;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
    color: #E2E8F0;
    font-family: 'Inter', sans-serif;
    animation: cw-slide 220ms ease-out;
}
.cw-panel[hidden] { display: none; }

@keyframes cw-slide {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cw-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(52, 211, 153, 0.06), transparent);
}
.cw-title {
    margin: 0 0 0.15rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #F1F5F9;
}
.cw-subtitle {
    margin: 0;
    font-size: 0.78rem;
    color: #94A3B8;
}

.cw-close {
    background: transparent;
    border: 0;
    color: #94A3B8;
    font-size: 1.5rem;
    line-height: 1;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    cursor: pointer;
}
.cw-close:hover { color: #E2E8F0; background: rgba(255, 255, 255, 0.06); }
.cw-close:focus-visible { outline: 2px solid #34D399; outline-offset: 2px; }

.cw-log {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.cw-message {
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 92%;
}
.cw-message p { margin: 0; }
.cw-message p + p { margin-top: 0.5rem; }
.cw-message a { color: #34D399; text-decoration: underline; }

.cw-message-user {
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.24);
    color: #FDE8B4;
    align-self: flex-end;
}

.cw-message-assistant {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #E2E8F0;
    align-self: flex-start;
}

.cw-message-error {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #FCA5A5;
    align-self: flex-start;
}

.cw-typing {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.2rem 0;
}
.cw-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #94A3B8;
    animation: cw-pulse 1.1s infinite ease-in-out;
}
.cw-typing span:nth-child(2) { animation-delay: 0.15s; }
.cw-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes cw-pulse {
    0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
    30%            { opacity: 1;    transform: scale(1); }
}

.cw-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}
.cw-field { flex: 1; display: block; margin: 0; }
.cw-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #F1F5F9;
    font-size: 0.9rem;
    font-family: inherit;
}
.cw-input::placeholder { color: #64748B; }
.cw-input:focus {
    outline: none;
    border-color: #34D399;
    box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.18);
}
.cw-input:disabled { opacity: 0.6; }

.cw-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px; height: 42px;
    background: #F59E0B;
    color: #1A1A1A;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 150ms ease;
}
.cw-send:hover { background: #FBBF24; }
.cw-send:disabled { opacity: 0.6; cursor: not-allowed; }
.cw-send:focus-visible { outline: 2px solid #34D399; outline-offset: 2px; }
.cw-send svg { width: 18px; height: 18px; }

.cw-foot {
    margin: 0;
    padding: 0.4rem 1.1rem 0.85rem;
    font-size: 0.72rem;
    color: #64748B;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Visually hidden helper (duplicated from newsletter-popup.css so the
   widget can be served without that stylesheet; the declaration is
   identical so a second copy doesn't fight the first). */
.cw-field .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0);
    border: 0;
}

@media (max-width: 480px) {
    .cw-launcher { right: 0.85rem; bottom: 0.85rem; }
    .cw-panel {
        right: 0.5rem;
        bottom: 0.5rem;
        width: calc(100vw - 1rem);
        height: calc(100vh - 1rem);
        border-radius: 12px;
    }
}
