/* ==============================================
   CHAT WIDGET --- Floating intake agent
   ============================================== */

/* --- Bubble --- */

.cw-bubble {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 400;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    background-color: #5DADE2;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.cw-bubble:hover {
    background-color: #0E79AA;
    transform: scale(1.05);
}

.cw-bubble-icon {
    width: 1.5rem;
    height: 1.5rem;
    fill: #ffffff;
    pointer-events: none;
}

.cw-bubble-icon--close {
    display: none;
}

.cw-bubble.is-open .cw-bubble-icon--open {
    display: none;
}

.cw-bubble.is-open .cw-bubble-icon--close {
    display: block;
}

/* --- Panel --- */

.cw-panel {
    position: fixed;
    bottom: 5.75rem;
    right: 1.5rem;
    z-index: 400;
    width: 26rem;
    max-width: calc(100vw - 3rem);
    min-height: min(28rem, 70vh);
    max-height: 80vh;
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(0.5rem) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.cw-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* --- Panel header --- */

.cw-panel-header {
    background-color: #0F3350;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex-shrink: 0;
}

.cw-panel-title {
    font-family: 'Barlow', 'Arial Narrow', Arial, sans-serif;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #E5E4E2;
    margin: 0;
    line-height: 1.2;
}

.cw-panel-subtitle {
    font-family: 'Source Sans 3', 'Segoe UI', Arial, sans-serif;
    font-size: 0.75rem;
    color: #ACB6BD;
    margin: 0;
    line-height: 1.3;
}

/* --- Messages --- */

.cw-messages {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: #f4f6f8;
    min-height: 0;
}

.cw-message {
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-family: 'Source Sans 3', 'Segoe UI', Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.cw-message--bot {
    background-color: #ffffff;
    color: #1A2530;
    align-self: flex-start;
    border-bottom-left-radius: 0.125rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    white-space: normal;
}

.cw-list {
    margin-top: 0.25rem;
    margin-right: 0;
    margin-bottom: 0.25rem;
    margin-left: 1rem;
    padding: 0;
    list-style: disc;
}

.cw-list li {
    margin-bottom: 0.2rem;
    overflow-wrap: break-word;
}

.cw-message--bot strong {
    font-weight: 700;
}

.cw-message--user {
    background-color: #2D6FA3;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 0.125rem;
}

/* --- Typing indicator --- */

@keyframes cw-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%           { transform: translateY(-0.375rem); opacity: 1; }
}

.cw-message--typing {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.875rem 1rem;
    background-color: #ffffff;
    align-self: flex-start;
    border-radius: 0.5rem;
    border-bottom-left-radius: 0.125rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cw-message--typing .dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: #7393B3;
    animation: cw-dot-bounce 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

.cw-message--typing .dot:nth-child(2) { animation-delay: 0.2s; }
.cw-message--typing .dot:nth-child(3) { animation-delay: 0.4s; }

/* --- Complete state --- */

.cw-complete {
    flex: 1 1 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    background-color: #f4f6f8;
    gap: 0.75rem;
}

.cw-panel.is-complete .cw-complete  { display: flex; }
.cw-panel.is-complete .cw-messages  { display: none; }
.cw-panel.is-complete .cw-input-row { display: none; }

.cw-complete p {
    font-family: 'Source Sans 3', 'Segoe UI', Arial, sans-serif;
    font-size: 0.9rem;
    color: #496580;
    margin: 0;
    line-height: 1.5;
}

.cw-complete-check {
    width: 2.5rem;
    height: 2.5rem;
    fill: #2D6FA3;
}

/* --- Input row --- */

.cw-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 0.0625rem solid #D3D3D3;
    background-color: #ffffff;
    flex-shrink: 0;
}

.cw-input {
    flex: 1 1 0;
    min-width: 0;
    border: 0.0625rem solid #ACB6BD;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-family: 'Source Sans 3', 'Segoe UI', Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #1A2530;
    background-color: #ffffff;
    resize: none;
    overflow-y: hidden;
    max-height: 6rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.cw-input:focus {
    border-color: #2D6FA3;
}

.cw-input:disabled {
    background-color: #f4f6f8;
    cursor: not-allowed;
}

.cw-send-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background-color: #2D6FA3;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.cw-send-btn:hover {
    background-color: #1E5280;
}

.cw-send-btn:disabled {
    background-color: #ACB6BD;
    cursor: not-allowed;
}

.cw-send-icon {
    width: 1rem;
    height: 1rem;
    fill: #ffffff;
    pointer-events: none;
}

/* --- Mobile --- */

@media (max-width: 30rem) {
    .cw-bubble {
        bottom: 1rem;
        right: 1rem;
    }

    .cw-panel {
        bottom: 5.25rem;
        right: 1rem;
        width: calc(100vw - 2rem);
    }

    .cw-input {
        font-size: 1rem;
    }
}
