/**
 * MyOmniverse Live Chat Styles
 * Version 1.1.0 - With Emoji Picker
 */

:root {
    --molc-primary: #6366f1;
    --molc-primary-dark: #4f46e5;
    --molc-bg: #ffffff;
    --molc-bg-secondary: #f8fafc;
    --molc-bg-tertiary: #f1f5f9;
    --molc-border: #e2e8f0;
    --molc-text: #1e293b;
    --molc-text-secondary: #64748b;
    --molc-text-light: #94a3b8;
    --molc-success: #22c55e;
    --molc-error: #ef4444;
    --molc-message-own: #6366f1;
    --molc-message-other: #f1f5f9;
    --molc-radius: 12px;
    --molc-radius-sm: 8px;
}

/* Stream Layout */
.molc-stream-container {
    display: flex;
    width: 100%;
    min-height: 500px;
    height: calc(100vh - 200px);
    max-height: 800px;
    background: var(--molc-bg);
    border-radius: var(--molc-radius);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.molc-video-section {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.molc-video-wrapper { width: 100%; height: 100%; }
.molc-video-wrapper iframe, .molc-video-wrapper video { width: 100%; height: 100%; border: none; }
.molc-video-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #fff; text-align: center; padding: 20px; }

.molc-chat-section {
    display: flex;
    flex-direction: column;
    background: var(--molc-bg);
    border-left: 1px solid var(--molc-border);
}

/* Chat Container */
.molc-chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
    max-height: 600px;
    overflow: hidden;
    background: var(--molc-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.molc-chat-section .molc-chat-container { height: 100%; max-height: none; }

.molc-chat-container:not(.molc-chat-section .molc-chat-container) {
    border: 1px solid var(--molc-border);
    border-radius: var(--molc-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Header */
.molc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--molc-bg);
    border-bottom: 1px solid var(--molc-border);
    flex-shrink: 0;
}

.molc-header-left { display: flex; align-items: center; gap: 10px; }
.molc-status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--molc-text-light); transition: all 0.3s; }
.molc-status-indicator.molc-status-online { background: var(--molc-success); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.molc-status-indicator.molc-status-offline { background: var(--molc-error); }
.molc-title { font-weight: 600; color: var(--molc-text); font-size: 15px; }
.molc-header-right { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--molc-text-secondary); }
.molc-online-count { font-weight: 600; color: var(--molc-success); }

/* Messages */
.molc-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: var(--molc-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.molc-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; color: var(--molc-text-secondary); }
.molc-spinner { width: 28px; height: 28px; border: 3px solid var(--molc-border); border-top-color: var(--molc-primary); border-radius: 50%; animation: molc-spin 0.8s linear infinite; }
@keyframes molc-spin { to { transform: rotate(360deg); } }

.molc-message { display: flex; gap: 10px; max-width: 90%; animation: molc-slide-up 0.2s ease-out; }
@keyframes molc-slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.molc-message-own { flex-direction: row-reverse; align-self: flex-end; }
.molc-message-other { align-self: flex-start; }
.molc-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--molc-border); flex-shrink: 0; }
.molc-message-body { display: flex; flex-direction: column; gap: 4px; }
.molc-message-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.molc-message-own .molc-message-meta { flex-direction: row-reverse; }
.molc-message-author { font-weight: 600; color: var(--molc-text); }
.molc-message-time { color: var(--molc-text-light); }
.molc-message-text { padding: 10px 14px; border-radius: 16px; word-wrap: break-word; }
.molc-message-own .molc-message-text { background: var(--molc-message-own); color: #fff; border-bottom-right-radius: 4px; }
.molc-message-other .molc-message-text { background: var(--molc-message-other); color: var(--molc-text); border-bottom-left-radius: 4px; }
.molc-message-text a { color: inherit; text-decoration: underline; }

/* Typing */
.molc-typing { padding: 8px 16px; background: var(--molc-bg-secondary); font-size: 13px; color: var(--molc-text-secondary); border-top: 1px solid var(--molc-border); flex-shrink: 0; }
.molc-typing:empty { display: none; }
.molc-typing-text::after { content: '...'; animation: molc-dots 1.4s infinite; }
@keyframes molc-dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }

/* Emoji Picker */
.molc-emoji-picker {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 16px;
    right: 16px;
    background: var(--molc-bg);
    border: 1px solid var(--molc-border);
    border-radius: var(--molc-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    z-index: 100;
}

.molc-emoji-picker-open { display: block; animation: molc-fade-in 0.15s ease-out; }
@keyframes molc-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.molc-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.molc-emoji { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; font-size: 20px; cursor: pointer; border-radius: 6px; transition: background 0.15s, transform 0.1s; }
.molc-emoji:hover { background: var(--molc-bg-tertiary); transform: scale(1.15); }

/* Input Area */
.molc-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--molc-bg);
    border-top: 1px solid var(--molc-border);
    flex-shrink: 0;
}

.molc-emoji-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 20px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.molc-emoji-btn:hover, .molc-emoji-btn-active { background: var(--molc-bg-tertiary); }

.molc-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--molc-border);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--molc-bg-tertiary);
    color: var(--molc-text);
    min-width: 0;
}

.molc-input:focus { border-color: var(--molc-primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); background: var(--molc-bg); }
.molc-input::placeholder { color: var(--molc-text-light); }

.molc-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--molc-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
    font-size: 18px;
}

.molc-send-btn:hover { background: var(--molc-primary-dark); }
.molc-send-btn:active { transform: scale(0.95); }

/* Login Prompt */
.molc-login-prompt { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; text-align: center; background: var(--molc-bg); border: 1px solid var(--molc-border); border-radius: var(--molc-radius); height: 100%; }
.molc-login-icon { font-size: 48px; margin-bottom: 16px; }
.molc-login-prompt h3 { margin: 0 0 8px; font-size: 18px; color: var(--molc-text); }
.molc-login-prompt p { margin: 0 0 20px; color: var(--molc-text-secondary); }
.molc-login-btn { display: inline-flex; padding: 10px 24px; background: var(--molc-primary); color: #fff; text-decoration: none; border-radius: var(--molc-radius-sm); font-weight: 500; }
.molc-login-btn:hover { background: var(--molc-primary-dark); color: #fff; }

/* Error */
.molc-error { padding: 20px; text-align: center; color: var(--molc-error); background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--molc-radius); }
.molc-error-message { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--molc-text-secondary); }

/* Scrollbar */
.molc-messages::-webkit-scrollbar { width: 6px; }
.molc-messages::-webkit-scrollbar-track { background: transparent; }
.molc-messages::-webkit-scrollbar-thumb { background: var(--molc-border); border-radius: 3px; }
.molc-messages::-webkit-scrollbar-thumb:hover { background: var(--molc-text-light); }

/* Responsive */
@media (max-width: 900px) {
    .molc-stream-container { flex-direction: column; height: auto; max-height: none; }
    .molc-video-section, .molc-chat-section { flex: none !important; width: 100% !important; }
    .molc-video-section { aspect-ratio: 16/9; }
    .molc-chat-section { height: 400px; border-left: none; border-top: 1px solid var(--molc-border); }
}

@media (max-width: 480px) {
    .molc-header, .molc-messages, .molc-input-wrapper { padding: 12px; }
    .molc-message { max-width: 95%; }
    .molc-avatar { width: 28px; height: 28px; }
    .molc-emoji-grid { grid-template-columns: repeat(6, 1fr); }
    .molc-emoji { width: 36px; height: 36px; }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --molc-bg: #1e293b;
        --molc-bg-secondary: #0f172a;
        --molc-bg-tertiary: #334155;
        --molc-border: #334155;
        --molc-text: #f1f5f9;
        --molc-text-secondary: #94a3b8;
        --molc-text-light: #64748b;
        --molc-message-other: #334155;
    }
}

/* YouTube Container */
.molc-youtube-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.molc-youtube-container iframe {
    width: 100%;
    height: 100%;
}

.molc-live-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    z-index: 10;
}

.molc-live-active .molc-live-badge {
    background: #dc2626;
    animation: molc-pulse 2s infinite;
}

@keyframes molc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* BuddyBoss */
.buddyboss-theme .molc-chat-container, .buddyboss-theme .molc-input { font-family: inherit; }
