/* Unified Assistant Panel — Retirement Planner */

/* ── FAB (single button) ── */
.assistant-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--accent, #c45d3e);
    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;
}

.assistant-fab:hover {
    transform: scale(1.08);
}

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

/* ── Panel ── */
.assistant-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    font-family: var(--sans, 'Outfit', sans-serif);
}

.assistant-panel.open {
    transform: translateX(0);
}

/* ── Page push (desktop only ≥1024px) ── */
body {
    transition: padding-right 0.3s ease;
}

body.assistant-panel-open {
    padding-right: 380px;
}

@media (max-width: 1023px) {
    body.assistant-panel-open {
        padding-right: 0;
    }
}

/* ── Header ── */
.assistant-panel-header {
    display: flex;
    align-items: stretch;
    padding: 0 8px 0 0;
    background: #1a1a1a;
    color: #f8f6f1;
    flex-shrink: 0;
}

.assistant-tabs {
    display: flex;
    flex: 1;
}

.assistant-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(248, 246, 241, 0.55);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    font-weight: 500;
    padding: 14px 20px;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.assistant-tab-btn:hover {
    color: rgba(248, 246, 241, 0.9);
}

.assistant-tab-btn.active {
    color: #f8f6f1;
    border-bottom-color: var(--accent, #c45d3e);
}

.assistant-close-btn {
    background: none;
    border: none;
    color: rgba(248, 246, 241, 0.6);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    padding: 4px 8px;
    border-radius: 4px;
    align-self: center;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.assistant-close-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f8f6f1;
}

/* ── Panel Body ── */
.assistant-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Pane visibility ── */
.chat-pane,
.voice-pane {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.chat-pane.active,
.voice-pane.active {
    display: flex;
}

/* ── Chat pane subheader (Start Over) ── */
.chat-pane-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 12px;
    border-bottom: 1px solid var(--divider, rgba(26, 26, 26, 0.08));
    flex-shrink: 0;
}

.chat-restart-btn {
    background: none;
    border: none;
    color: var(--muted, #8a8478);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    padding: 3px 8px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-restart-btn:hover {
    background: rgba(26, 26, 26, 0.06);
    color: var(--ink, #1a1a1a);
}

/* ── Chat Messages ── */
.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;
}

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

/* ── Chat 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); }
}

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

.chat-input {
    flex: 1 1 0%;
    min-width: 0;
    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-input:focus {
    border-color: var(--retire-color, #2d6a4f);
}

.chat-send-btn {
    flex: 0 0 auto;
    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-send-btn:hover {
    background: var(--retire-light, #40916c);
}

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

/* ── Chat Link Styles ── */
.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);
}

/* ── 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); }
}

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

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

.voice-message.user {
    align-self: flex-end;
    background: var(--accent, #c45d3e);
    color: #fff;
    border-bottom-right-radius: 4px;
}

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

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

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

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

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

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

/* ── Voice Controls ── */
.voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid var(--divider, rgba(26, 26, 26, 0.08));
    gap: 8px;
    flex-shrink: 0;
}

.voice-mic-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent, #c45d3e);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(196, 93, 62, 0.3);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='2' width='6' height='12' rx='3'/%3E%3Cpath d='M5 10a7 7 0 0 0 14 0'/%3E%3Cline x1='12' y1='19' x2='12' y2='22'/%3E%3Cline x1='8' y1='22' x2='16' y2='22'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px 24px;
}

.voice-mic-btn:hover:not(:disabled) {
    transform: scale(1.06);
}

.voice-mic-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voice-mic-btn.listening {
    animation: voicePulse 1.2s ease-in-out infinite;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Crect x='5' y='5' width='14' height='14' rx='2'/%3E%3C/svg%3E");
}

.voice-mic-btn.speaking {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3Cpath d='M15.54 8.46a5 5 0 0 1 0 7.07'/%3E%3Cpath d='M19.07 4.93a10 10 0 0 1 0 14.14'/%3E%3C/svg%3E");
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(196, 93, 62, 0.4); }
    50% { box-shadow: 0 4px 24px rgba(196, 93, 62, 0.8), 0 0 0 8px rgba(196, 93, 62, 0.2); }
}

.voice-status-text {
    font-size: 0.82rem;
    color: var(--muted, #8a8478);
    text-align: center;
    font-family: var(--sans, 'Outfit', sans-serif);
}

/* ── Voice Text Fallback ── */
.voice-text-fallback {
    display: none;
    flex-direction: row;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--divider, rgba(26, 26, 26, 0.08));
    align-items: flex-end;
    flex-shrink: 0;
}

.voice-text-fallback.visible {
    display: flex;
}

.voice-text-input {
    flex: 1 1 0%;
    min-width: 0;
    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;
}

.voice-text-input:focus {
    border-color: var(--accent, #c45d3e);
}

.voice-text-send {
    flex: 0 0 auto;
    background: var(--accent, #c45d3e);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--sans, 'Outfit', sans-serif);
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

.voice-text-send:hover {
    opacity: 0.88;
}

.voice-text-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .assistant-panel {
        width: 100%;
    }

    body.assistant-panel-open {
        padding-right: 0;
    }

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

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

    .voice-text-input {
        font-size: 16px;
    }
}
