/**
 * Celestial Commons - Native Chat Styles
 * Ethereal theme for the real-time chat sanctum
 */

/* Main Layout */
.sanctum-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 500px;
    max-height: 800px;
    background: linear-gradient(135deg, rgba(26, 13, 51, 0.95) 0%, rgba(10, 10, 18, 0.98) 100%);
    border: 1px solid rgba(255, 94, 120, 0.3);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Presence Sidebar */
.presence-sidebar {
    width: 220px;
    background: rgba(5, 5, 8, 0.6);
    border-right: 1px solid rgba(255, 94, 120, 0.2);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.presence-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 94, 120, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.presence-header i {
    color: var(--flame-coral, #ff5e78);
}

.presence-header h3 {
    font-family: var(--font-mystical, 'Cinzel', serif);
    font-size: 0.875rem;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.presence-count {
    background: rgba(255, 94, 120, 0.2);
    color: var(--flame-coral, #ff5e78);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: auto;
}

.presence-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.presence-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.presence-user:hover {
    background: rgba(255, 94, 120, 0.1);
}

.presence-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ether-purple, #1a0d33), var(--ether-secondary, #2d1b4e));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
    position: relative;
    overflow: hidden;
}

.presence-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.presence-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--void-primary, #0a0a12);
}

.presence-name {
    flex: 1;
    font-size: 0.875rem;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Soul Rank Colors */
.presence-name.rank-initiate { color: #9ca3af; }
.presence-name.rank-seeker { color: #22c55e; }
.presence-name.rank-adept { color: #3b82f6; }
.presence-name.rank-sage { color: #8b5cf6; }
.presence-name.rank-oracle { color: #f59e0b; }
.presence-name.rank-immortal { color: var(--flame-coral, #ff5e78); }
.presence-name.rank-admin { color: var(--gold-divine, #d4af37); }

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Chat Header */
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 94, 120, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(5, 5, 8, 0.4);
}

.chat-header i {
    color: var(--gold-divine, #d4af37);
    font-size: 1.25rem;
}

.chat-header h2 {
    font-family: var(--font-mystical, 'Cinzel', serif);
    font-size: 1.125rem;
    color: var(--starlight, rgba(255, 255, 255, 0.95));
    margin: 0;
    letter-spacing: 2px;
}

.chat-header-subtitle {
    font-size: 0.75rem;
    color: rgba(240, 230, 255, 0.5);
    margin-left: auto;
}

/* Message Stream */
.message-stream {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-stream::-webkit-scrollbar {
    width: 6px;
}

.message-stream::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.message-stream::-webkit-scrollbar-thumb {
    background: rgba(255, 94, 120, 0.3);
    border-radius: 3px;
}

/* Chat Messages */
.chat-message {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message:hover {
    background: rgba(255, 94, 120, 0.05);
}

.chat-message.own-message {
    background: rgba(157, 78, 221, 0.08);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ether-purple, #1a0d33), var(--ether-secondary, #2d1b4e));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
}

/* Author Soul Rank Colors */
.message-author.rank-initiate { color: #9ca3af; }
.message-author.rank-seeker { color: #22c55e; }
.message-author.rank-adept { color: #3b82f6; }
.message-author.rank-sage { color: #8b5cf6; }
.message-author.rank-oracle { color: #f59e0b; }
.message-author.rank-immortal { color: var(--flame-coral, #ff5e78); }
.message-author.rank-admin { color: var(--gold-divine, #d4af37); }

.message-time {
    font-size: 0.75rem;
    color: rgba(240, 230, 255, 0.4);
}

.message-content {
    font-size: 0.9375rem;
    color: rgba(240, 230, 255, 0.85);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Typing Indicator */
.typing-indicator {
    padding: 8px 20px;
    font-size: 0.8125rem;
    color: rgba(240, 230, 255, 0.5);
    font-style: italic;
    min-height: 32px;
}

.typing-indicator .typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 4px;
}

.typing-indicator .typing-dots span {
    width: 4px;
    height: 4px;
    background: rgba(255, 94, 120, 0.6);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator .typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-indicator .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
}

/* Chat Input Area */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 94, 120, 0.2);
    background: rgba(5, 5, 8, 0.4);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: rgba(10, 10, 18, 0.8);
    border: 1px solid rgba(255, 94, 120, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
    font-size: 0.9375rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus {
    outline: none;
    border-color: rgba(255, 94, 120, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 94, 120, 0.1);
}

.chat-input::placeholder {
    color: rgba(240, 230, 255, 0.3);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--flame-coral, #ff5e78) 0%, var(--flame-ember, #ff8f6b) 100%);
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 94, 120, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.chat-send-btn i {
    color: white;
    font-size: 1rem;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* System Messages */
.system-message {
    text-align: center;
    padding: 8px 16px;
    font-size: 0.8125rem;
    color: rgba(240, 230, 255, 0.5);
}

.system-message.join {
    color: rgba(34, 197, 94, 0.7);
}

.system-message.leave {
    color: rgba(239, 68, 68, 0.6);
}

/* Loading State */
.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    color: rgba(240, 230, 255, 0.6);
}

.chat-loading i {
    font-size: 2rem;
    color: var(--flame-coral, #ff5e78);
}

/* Login Required State */
.chat-login-required {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 60px 40px;
    text-align: center;
}

.chat-login-required i {
    font-size: 3rem;
    color: var(--gold-divine, #d4af37);
    opacity: 0.8;
}

.chat-login-required h3 {
    font-family: var(--font-mystical, 'Cinzel', serif);
    font-size: 1.25rem;
    color: var(--moonlight, rgba(240, 230, 255, 0.9));
    margin: 0;
}

.chat-login-required p {
    color: rgba(240, 230, 255, 0.6);
    margin: 0;
    max-width: 300px;
}

.chat-login-btn {
    background: linear-gradient(135deg, var(--flame-coral, #ff5e78) 0%, var(--flame-ember, #ff8f6b) 100%);
    border: none;
    border-radius: 8px;
    padding: 12px 32px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 94, 120, 0.4);
}

/* Load More History */
.load-more-container {
    text-align: center;
    padding: 12px;
}

.load-more-btn {
    background: transparent;
    border: 1px solid rgba(255, 94, 120, 0.3);
    border-radius: 6px;
    padding: 8px 20px;
    color: rgba(240, 230, 255, 0.7);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-more-btn:hover {
    background: rgba(255, 94, 120, 0.1);
    border-color: rgba(255, 94, 120, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .sanctum-container {
        flex-direction: column;
        height: calc(100vh - 150px);
        max-height: none;
    }

    .presence-sidebar {
        width: 100%;
        height: auto;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 94, 120, 0.2);
    }

    .presence-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }

    .presence-user {
        padding: 4px 8px;
    }

    .presence-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .presence-status {
        width: 8px;
        height: 8px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .message-stream {
        padding: 12px 16px;
    }

    .chat-input-area {
        padding: 12px 16px;
    }
}

/* Light Theme Overrides */
body.light-theme .sanctum-container {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 245, 255, 0.98) 100%);
    border-color: rgba(214, 45, 77, 0.2);
}

body.light-theme .presence-sidebar {
    background: rgba(248, 245, 255, 0.6);
    border-color: rgba(214, 45, 77, 0.15);
}

body.light-theme .presence-name,
body.light-theme .message-author {
    color: #1e1b4b;
}

body.light-theme .message-content {
    color: #374151;
}

body.light-theme .chat-input {
    background: rgba(255, 255, 255, 0.9);
    color: #1e1b4b;
    border-color: rgba(214, 45, 77, 0.2);
}

body.light-theme .chat-input::placeholder {
    color: rgba(30, 27, 75, 0.4);
}

body.light-theme .chat-header,
body.light-theme .chat-input-area {
    background: rgba(248, 245, 255, 0.6);
    border-color: rgba(214, 45, 77, 0.15);
}

body.light-theme .chat-header h2 {
    color: #1e1b4b;
}

body.light-theme .system-message {
    color: rgba(30, 27, 75, 0.5);
}
