/* --- Chatroom Specific Styles --- */

/* --- Custom Scrollbar for Chat Window --- */
#chatWindow::-webkit-scrollbar {
    width: 6px;
}
#chatWindow::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}
html.dark #chatWindow::-webkit-scrollbar-thumb {
    background-color: #475569;
}

/* --- Status Dot Animation --- */
.status-dot {
    width: 10px;
    height: 10px;
    background-color: #10b981; /* Green */
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --- Message Bubbles Base --- */
.chat-message {
    max-width: 80%;
    padding: 0.85rem 1.25rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease forwards;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

@media (min-width: 768px) {
    .chat-message {
        max-width: 70%;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Metadata (Name/Time) */
.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.2rem;
    gap: 1rem;
    font-size: 0.75rem;
    opacity: 0.9;
}

.message-sender {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* --- Specific Bubble Types --- */

/* 1. Other Users (Left aligned) */
.chat-message.other {
    background-color: #fff;
    color: #334155; /* Slate 700 */
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
}
html.dark .chat-message.other {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}
.chat-message.other .message-sender {
    color: #4f46e5; /* Primary Indigo */
}

/* 2. Current User (Right aligned) */
.chat-message.user {
    background: linear-gradient(135deg, #4f46e5, #0d9488); /* Primary to Teal */
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}
.chat-message.user .message-sender {
    display: none; /* Hide own name */
}
.chat-message.user .message-time {
    color: rgba(255,255,255,0.8);
}

/* 3. AI Bot (Left aligned, Distinct style) */
.chat-message.ai-message {
    background: linear-gradient(135deg, #6366f1, #c026d3); /* Indigo to Pink/Fuchsia */
    color: white;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.chat-message.ai-message .message-sender {
    color: #fff;
}

/* 4. System Message (Centered) */
.chat-message.system {
    align-self: center;
    text-align: center;
    background: rgba(203, 213, 225, 0.4);
    color: #64748b;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    max-width: 90%;
    margin: 1rem 0;
    box-shadow: none;
    border: 1px solid rgba(255,255,255,0.5);
}
html.dark .chat-message.system {
    background: rgba(51, 65, 85, 0.5);
    color: #94a3b8;
    border-color: rgba(255,255,255,0.1);
}

/* --- Moderation & Warnings --- */
.warning-box {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: #f59e0b; /* Amber warning */
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 1000;
    font-weight: 600;
    text-align: center;
    font-size: 0.9rem;
}

.warning-box.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Glassmorphism Enhancements for Dark Mode --- */
html.dark .glass-nav {
    background: rgba(15, 23, 42, 0.85); /* Slate 900 */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

html.dark #chatContainer {
    background-color: rgba(30, 41, 59, 0.7);
    border-color: rgba(255,255,255,0.05);
}

html.dark #messageForm {
    background-color: rgba(15, 23, 42, 0.5);
    border-top-color: rgba(255,255,255,0.05);
}

html.dark #messageInput {
    background-color: #0f172a;
    border-color: #334155;
    color: white;
}
html.dark #chatHeader {
    background-color: rgba(30, 41, 59, 0.5);
    border-bottom-color: rgba(255,255,255,0.05);
}
html.dark #chatHeader span.text-gray-800 {
    color: #f1f5f9;
}

/* --- Common Animations from Homepage (styles.css override/ensure) --- */
.glass-nav {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Liquid Blob Animation (ensure it's here if not loading styles.css) */
.liquid-blob {
    position: absolute;
    background: linear-gradient(45deg, #4f46e5, #0d9488);
    opacity: 0.4;
    filter: blur(60px);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: morphing 10s infinite ease-in-out;
    z-index: 0;
}

@keyframes morphing {
    0% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    25% { border-radius: 58% 42% 75% 25% / 76% 46% 54% 24%; }
    50% { border-radius: 50% 50% 33% 67% / 55% 27% 73% 45%; }
    75% { border-radius: 33% 67% 58% 42% / 63% 68% 32% 37%; }
    100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
}

/* Shimmer Button */
.btn-shimmer {
    position: relative;
    overflow: hidden;
}

.btn-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(to right, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
    transform: skewX(-20deg) translateX(-150%);
    transition: transform 0.5s;
}

.btn-shimmer:hover::after {
    transform: skewX(-20deg) translateX(150%);
    transition: transform 1s ease-in-out;
}

/* Loading Spinner */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #eef2ff;
    border-top: 5px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}