/**
 * AI Features Styles
 */

/* Result Explainer */
.ai-explain-wrapper { margin-top: 1rem; }
.ai-explain-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--white);
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}
.ai-explain-btn:hover { background: var(--primary-light); }
.ai-explain-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-explain-result {
    background: var(--accent-light);
    border: 1px solid #BAE6FD;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--dark-text);
}

/* Should-I Analyzer */
.ai-shouldi-wrapper { margin-top: 1.5rem; }
.ai-shouldi-panel {
    background: var(--off-white);
    border: 1px solid var(--light-border);
    border-radius: var(--card-radius);
    padding: 1.5rem;
}
.ai-shouldi-panel h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.ai-shouldi-content { font-size: 0.95rem; line-height: 1.7; }
.ai-disclaimer { font-size: 0.8rem; color: var(--body-text); margin-top: 1rem; margin-bottom: 0; font-style: italic; }

/* Comparison Narrator */
.ai-compare-wrapper { margin-top: 1.5rem; }
.ai-compare-panel {
    background: #FFF7ED;
    border: 1px solid #FED7AA;
    border-radius: var(--card-radius);
    padding: 1.5rem;
}
.ai-compare-panel h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.ai-compare-content { font-size: 0.95rem; line-height: 1.7; }

/* Loading Animation */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--body-text);
    font-size: 0.9rem;
}
.ai-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--light-border);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* Typing Dots */
.ai-typing { display: inline-flex; gap: 4px; padding: 0.5rem 0; }
.ai-typing span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: ai-bounce 1.4s infinite ease-in-out both;
}
.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ========== CHAT WIDGET ========== */
.ai-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 60px;
    padding: 0.875rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    font-family: var(--font-body);
}
.ai-chat-fab:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.ai-chat-fab-icon { font-size: 1.2rem; }

/* Chat Panel */
.ai-chat-panel {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 400px;
    height: 500px;
    background: var(--white);
    border: 1px solid var(--light-border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-lg);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.ai-chat-panel.active { display: flex; }

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--light-border);
    background: var(--off-white);
}
.ai-chat-header-info h4 { margin: 0; font-size: 1rem; color: var(--dark-text); }
.ai-chat-header-info p { margin: 0; font-size: 0.75rem; color: var(--body-text); }
.ai-chat-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--body-text);
    padding: 0.25rem;
    transition: var(--transition);
}
.ai-chat-close:hover { color: var(--dark-text); }

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-chat-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--card-radius);
    font-size: 0.9rem;
    line-height: 1.6;
}
.ai-chat-msg-ai {
    background: var(--off-white);
    border: 1px solid var(--light-border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.ai-chat-msg-user {
    background: var(--primary);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-input-area {
    display: flex;
    padding: 0.75rem;
    border-top: 1px solid var(--light-border);
    gap: 0.5rem;
}
.ai-chat-input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 2px solid var(--light-border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: var(--font-body);
    outline: none;
    transition: var(--transition);
}
.ai-chat-input:focus { border-color: var(--primary); }
.ai-chat-send {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 0.625rem 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}
.ai-chat-send:hover { background: var(--primary-dark); }
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Rate limit message */
.ai-rate-limit {
    text-align: center;
    padding: 1rem;
    color: var(--body-text);
    font-size: 0.85rem;
    font-style: italic;
}
