/* Ruwe AI Premium Styles */
:root {
    --ruwe-ai-red: #A30000;
    --ruwe-ai-red-light: #d32f2f;
    --ruwe-ai-dark: #121212;
    --ruwe-ai-darker: #0a0a0a;
    --ruwe-ai-light: #f9f9f9;
    --ruwe-ai-white: #ffffff;
    --ruwe-ai-gray: #e0e0e0;
    --ruwe-ai-text-dark: #333333;
    --ruwe-ai-text-light: #ffffff;
    --ruwe-ai-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --ruwe-ai-border: rgba(255, 255, 255, 0.1);
}

/* FAB Styling */
.ruwe-ai-fab {
    position: fixed;
    bottom: 110px; /* Above WhatsApp */
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ruwe-ai-red), var(--ruwe-ai-dark));
    color: var(--ruwe-ai-white);
    border: none;
    box-shadow: 0 4px 15px rgba(163, 0, 0, 0.4);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    padding: 0;
    line-height: 1;
}

.ruwe-ai-fab .fab-emoji {
    font-size: 26px;
    margin-bottom: 2px;
}

.ruwe-ai-fab .fab-label {
    font-size: 9px !important;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.ruwe-ai-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(163, 0, 0, 0.6);
}

/* Chat Panel Styling */
.ruwe-ai-panel {
    position: fixed;
    bottom: 180px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 200px);
    background: var(--ruwe-ai-white);
    border-radius: 16px;
    box-shadow: var(--ruwe-ai-shadow);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    transform-origin: bottom right;
    border: 1px solid rgba(0,0,0,0.08);
}

.ruwe-ai-panel.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* Header */
.ruwe-ai-header {
    background: linear-gradient(90deg, var(--ruwe-ai-darker), var(--ruwe-ai-dark));
    color: var(--ruwe-ai-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--ruwe-ai-red);
}

.ai-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-header-title i {
    color: var(--ruwe-ai-red-light);
}

.ai-header-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

#ruwe-ai-close {
    background: none;
    border: none;
    color: var(--ruwe-ai-gray);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

#ruwe-ai-close:hover {
    color: var(--ruwe-ai-white);
}

/* Messages Area */
.ruwe-ai-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--ruwe-ai-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Align messages to the bottom of the container to eliminate empty whitespace */
.ruwe-ai-messages > :first-child {
    margin-top: auto;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease forwards;
}

.ai-message.system-msg {
    background: var(--ruwe-ai-white);
    color: var(--ruwe-ai-text-dark);
    border: 1px solid rgba(0,0,0,0.05);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-message.user-msg {
    background: linear-gradient(135deg, var(--ruwe-ai-darker), var(--ruwe-ai-dark));
    color: var(--ruwe-ai-white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-message p {
    margin: 0 0 8px 0;
}

.ai-message p:last-child {
    margin-bottom: 0;
}

.ai-message a {
    color: var(--ruwe-ai-red);
    text-decoration: none;
    font-weight: 500;
}

.ai-message a:hover {
    text-decoration: underline;
}

.bible-text {
    color: var(--ruwe-ai-red);
    font-weight: 600;
}

/* Sources styling */
.ai-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.05);
    font-size: 12px;
}
.ai-sources h4 {
    margin: 0 0 5px 0;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}
.ai-sources ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.ai-sources li a {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(163, 0, 0, 0.05);
    border: 1px solid rgba(163, 0, 0, 0.1);
    border-radius: 4px;
    color: var(--ruwe-ai-red);
    font-size: 11px;
    transition: background 0.2s;
}
.ai-sources li a:hover {
    background: rgba(163, 0, 0, 0.1);
    text-decoration: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--ruwe-ai-white);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--ruwe-ai-gray);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Input Area */
.ruwe-ai-input-area {
    padding: 16px 20px;
    background: var(--ruwe-ai-white);
    border-top: 1px solid rgba(0,0,0,0.08);
}

#ruwe-ai-form {
    display: flex;
    gap: 10px;
    background: var(--ruwe-ai-light);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 24px;
    padding: 4px;
    transition: border-color 0.3s;
}

#ruwe-ai-form:focus-within {
    border-color: var(--ruwe-ai-red);
    background: var(--ruwe-ai-white);
    box-shadow: 0 0 0 2px rgba(163, 0, 0, 0.1);
}

#ruwe-ai-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--ruwe-ai-text-dark);
    outline: none;
}

#ruwe-ai-input::placeholder {
    color: #999;
}

#ruwe-ai-submit {
    background: var(--ruwe-ai-dark);
    color: var(--ruwe-ai-white);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#ruwe-ai-submit:hover {
    background: var(--ruwe-ai-red);
}

#ruwe-ai-submit:active {
    transform: scale(0.95);
}

.ruwe-ai-footer-text {
    text-align: center;
    font-size: 11px;
    color: #999;
    margin-top: 8px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); background: var(--ruwe-ai-red); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ruwe-ai-panel {
        position: fixed;
        top: 70px;
        left: 0;
        bottom: 0;
        right: 0;
        width: 100vw;
        height: auto;
        max-height: none;
        max-width: 100vw;
        border-radius: 16px 16px 0 0;
        transform-origin: bottom center;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        border-top: 1px solid rgba(0,0,0,0.1);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }
    
    .ruwe-ai-header {
        flex-shrink: 0;
    }

    .ruwe-ai-messages {
        flex: 1;
        overflow-y: auto;
    }

    .ruwe-ai-input-area {
        flex-shrink: 0;
    }
    
    .ruwe-ai-fab {
        bottom: 90px; /* Above WhatsApp on mobile if it changed */
        right: 20px;
        width: 60px;
        height: 60px;
    }
}
