/* ===== VRServers Global Styles ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a26;
    --bg-surface: #22222e;
    --text-primary: #e8e8f0;
    --text-secondary: #9898a8;
    --text-muted: #6868788;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-dim: rgba(99, 102, 241, 0.15);
    --border: #2a2a3a;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== Layout ===== */
.vr-app {
    min-height: 100vh;
}

/* ===== Landing Page ===== */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-links { display: flex; gap: 0.75rem; align-items: center; }

.btn-primary-landing, .btn-secondary-landing {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.btn-primary-landing {
    background: var(--accent);
    color: white;
}
.btn-primary-landing:hover { background: var(--accent-hover); color: white; }

.btn-secondary-landing {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary-landing:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    max-width: 720px;
    margin: 0 auto;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -2px;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.btn-hero {
    display: inline-block;
    padding: 0.875rem 2.5rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-hero:hover { background: var(--accent-hover); color: white; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99,102,241,0.4); }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 3rem 2rem;
    max-width: 960px;
    margin: 0 auto;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--accent); }

.feature-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.landing-footer {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ===== Auth Pages ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.auth-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-auth {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 0.5rem;
}
.btn-auth:hover { background: var(--accent-hover); }
.btn-auth:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-link {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== Chat Layout ===== */
.chat-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.chat-sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s;
}

.chat-sidebar.collapsed {
    margin-left: -260px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
}

.btn-new-chat {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-new-chat:hover { background: var(--accent); color: white; }

.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sidebar-conv-item {
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s;
}
.sidebar-conv-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-conv-item.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-footer {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Chat Container ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.btn-sidebar-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
}
.btn-sidebar-toggle:hover { background: var(--bg-tertiary); }

.hamburger {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    position: relative;
}
.hamburger::before, .hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: currentColor;
    left: 0;
}
.hamburger::before { top: -5px; }
.hamburger::after { top: 5px; }

/* Model Selector Dropdown */
.model-selector-container {
    position: relative;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 180px;
}
.model-selector-btn:hover { border-color: var(--accent); background: var(--bg-surface); }

.model-selector-name {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-logo-sm {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.dropdown-chevron {
    transition: transform 0.2s;
    flex-shrink: 0;
    opacity: 0.5;
}
.dropdown-chevron.open { transform: rotate(180deg); }

.model-dropdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 280px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 100;
    padding: 0.375rem;
}

.model-group {
    margin-bottom: 0.25rem;
}

.model-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-tag {
    padding: 0.0625rem 0.375rem;
    border-radius: 999px;
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.tag-local { background: rgba(52,211,153,0.15); color: var(--success); }
.tag-free { background: rgba(52,211,153,0.1); color: var(--success); font-size: 0.625rem; }

.model-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.625rem 0.5rem 2.25rem;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
}
.model-option:hover { background: var(--bg-tertiary); }
.model-option.active { background: var(--accent-dim); color: var(--accent); }

.model-option-name { flex: 1; }

.topbar-spacer { flex: 1; }

/* ===== Messages ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    gap: 1.25rem;
}
.chat-welcome h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
    letter-spacing: -0.5px;
}
.chat-welcome p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.welcome-icon-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    max-width: 320px;
}

.welcome-icon-item {
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: all 0.2s;
}
.welcome-icon-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.2);
}
.welcome-icon-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar-user {
    background: var(--accent-dim);
    color: var(--accent);
}

.avatar-ai {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 4px;
}

.avatar-ai img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

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

.message-content p {
    line-height: 1.6;
    white-space: pre-wrap;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.meta-logo {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    object-fit: contain;
}

/* Markdown content */
.markdown-body {
    line-height: 1.7;
    font-size: 0.9375rem;
}

.markdown-body p { margin-bottom: 0.75rem; }
.markdown-body p:last-child { margin-bottom: 0; }

.markdown-body pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.markdown-body code {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.8125rem;
}

.markdown-body :not(pre) > code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8125rem;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.markdown-body li { margin-bottom: 0.25rem; }

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 0.75rem 0;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75rem 0;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.markdown-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

/* Streaming indicator */
.streaming-indicator {
    display: flex;
    gap: 4px;
    padding: 0.25rem 0;
}

.streaming-indicator .dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: blink 1.4s infinite;
}
.streaming-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.streaming-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* ===== Chat Input ===== */
.chat-input-area {
    padding: 1rem 1.5rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s;
}
.chat-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    padding: 0.375rem 0;
    max-height: 200px;
    font-family: inherit;
}
.chat-input:focus { outline: none; }
.chat-input::placeholder { color: var(--text-muted); }

.btn-send {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.send-icon {
    display: block;
    width: 0;
    height: 0;
    border-left: 8px solid white;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    margin-left: 2px;
}

.stop-icon {
    display: block;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 2px;
}

.chat-disclaimer {
    max-width: 800px;
    margin: 0.5rem auto 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Ethics Score Card ===== */
.ethics-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.ethics-badge:hover { opacity: 0.8; }

.ethics-green { background: rgba(52,211,153,0.15); color: var(--success); }
.ethics-yellow { background: rgba(251,191,36,0.15); color: var(--warning); }
.ethics-red { background: rgba(248,113,113,0.15); color: var(--danger); }

.ethics-detail {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.ethics-dimension {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0;
}

.ethics-bar {
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    flex: 1;
    margin: 0 0.5rem;
    overflow: hidden;
}

.ethics-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

/* ===== Admin Page ===== */
.admin-page {
    min-height: 100vh;
}

.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
}

.admin-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

.admin-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.admin-section {
    margin-bottom: 2rem;
}

.admin-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.provider-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.provider-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.provider-meta {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
}
.badge-active { background: rgba(52,211,153,0.15); color: var(--success); }
.badge-inactive { background: rgba(248,113,113,0.15); color: var(--danger); }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.admin-table th {
    text-align: left;
    padding: 0.625rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.admin-table td {
    padding: 0.625rem;
    border-bottom: 1px solid var(--border);
}

.admin-table small {
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .chat-sidebar { position: fixed; z-index: 100; left: 0; top: 0; height: 100%; }
    .chat-sidebar.collapsed { margin-left: -260px; }

    .hero-title { font-size: 2.25rem; }
    .features { grid-template-columns: 1fr; }

    .model-selector-btn { min-width: 140px; }
    .model-dropdown { min-width: 240px; right: auto; left: 0; }
}

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