/* Chat Widget — Retirement Planner Conversational Intake */

.chat-fab {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 56px;
    height: 56px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--retire-color, #2d6a4f);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px 24px;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.chat-fab:hover {
    transform: scale(1.08);
    background-color: var(--retire-light, #40916c);
}

.chat-fab[aria-expanded="true"] {
    display: none;
}

/* Chat Panel */
.chat-panel {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 400px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel.open {
    display: flex;
}

/* Panel Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--retire-color, #2d6a4f);
    color: #fff;
    font-family: var(--sans, 'Outfit', sans-serif);
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: var(--sans, 'Outfit', sans-serif);
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--retire-color, #2d6a4f);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    align-self: flex-start;
    background: #f0f0ec;
    color: var(--ink, #1a1a1a);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.chat-typing {
    align-self: flex-start;
    padding: 10px 18px;
    background: #f0f0ec;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: none;
}

.chat-typing.visible {
    display: flex;
    gap: 5px;
    align-items: center;
}

.chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted, #8a8478);
    animation: chatBounce 1.2s infinite ease-in-out;
}

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

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

@keyframes chatBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Input Area */
.chat-panel .chat-input-area {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    padding: 12px;
    border-top: 1px solid var(--divider, rgba(26, 26, 26, 0.08));
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
}

.chat-panel .chat-input {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: auto !important;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    box-sizing: border-box;
}

.chat-panel .chat-input:focus {
    border-color: var(--retire-color, #2d6a4f);
}

.chat-panel .chat-send-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    background: var(--retire-color, #2d6a4f);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    transition: background 0.15s ease;
    white-space: nowrap;
}

.chat-panel .chat-send-btn:hover {
    background: var(--retire-light, #40916c);
}

.chat-panel .chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Error message */
.chat-message.error {
    align-self: center;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.85rem;
    text-align: center;
    max-width: 90%;
}

/* Field highlight glow */
.chat-field-highlight {
    animation: chatFieldGlow 1.5s ease-in-out 2;
}

@keyframes chatFieldGlow {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.35); }
}

/* Link styles in assistant messages */
.chat-message.assistant a.chat-link {
    color: var(--retire-color, #2d6a4f);
    text-decoration: underline;
}

.chat-message.assistant a.chat-link:hover {
    color: var(--retire-light, #40916c);
}

.chat-results-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: var(--retire-color, #2d6a4f);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s ease;
}

.chat-results-link:hover {
    background: var(--retire-light, #40916c);
}

/* Mobile */
@media (max-width: 768px) {
    .chat-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: -webkit-fill-available;
        border-radius: 0;
        box-shadow: none;
    }

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

    .chat-panel .chat-input {
        font-size: 16px;
    }
}
