/* Finrise AI chat widget — uses the site's design tokens (styles.css :root).
   Loaded after styles.css so overrides win. z-index 1002 = above navbar (1000)
   and notification toasts (1001). */

/* Launcher button */
.chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}
.chat-launcher:hover {
    transform: scale(1.08);
}

/* Chat panel */
.chat-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 360px;
    max-height: min(70vh, 560px);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: var(--background-white);
    z-index: 1002;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: all 0.25s ease;
}
.chat-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Header */
.chat-header {
    padding: 16px 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.chat-header-title {
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-header-title i {
    font-size: 1.1rem;
}
.chat-header-subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 2px;
}
.chat-new-chat {
    background: none;
    border: none;
    color: #fff;
    font-size: 0.8rem;
    opacity: 0.85;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}
.chat-new-chat:hover {
    opacity: 1;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--background-light);
}

/* Bubbles */
.chat-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 10px;
    font-size: 0.925rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-bubble.user {
    margin-left: auto;
    background: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
    background: var(--background-white);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}
.chat-bubble.assistant a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
    word-break: break-all;
}
.chat-bubble.error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

/* Typing indicator */
.chat-typing {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 12px 14px;
}
.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.5;
    animation: chatBlink 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}
.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes chatBlink {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

/* Suggestion chips */
.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--background-white);
}
.chat-chip {
    background: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--primary-color);
    transition: border-color 0.2s ease;
    font-family: inherit;
}
.chat-chip:hover {
    border-color: var(--primary-color);
}

/* Input row */
.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--background-white);
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    max-height: 96px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(27, 67, 50, 0.1);
}
.chat-send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.chat-send:hover {
    transform: scale(1.05);
}
.chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Mobile */
@media (max-width: 480px) {
    .chat-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 84px;
    }
    .chat-launcher {
        right: 16px;
        bottom: 16px;
    }
}
