/* DEBATE IA - App Styles */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #8b5cf6;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16162b;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --text-muted: #64748b;
    --border: #2d2d4a;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* AUTH */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image: radial-gradient(circle at 30% 50%, rgba(99,102,241,0.06) 0%, transparent 50%);
}
.auth-container { width: 100%; max-width: 420px; padding: 20px; }
.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-brand .logo { font-size: 1.6rem; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.auth-brand .logo i { color: var(--primary-light); }
.auth-brand .logo strong { color: var(--primary-light); }
.auth-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
}
.auth-form h2 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--text-muted); }
.auth-switch a { color: var(--primary-light); text-decoration: none; font-weight: 600; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 6px; color: var(--text-light); }
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
textarea.form-control { resize: vertical; }

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 8px; font-weight: 600;
    font-size: 0.9rem; text-decoration: none; cursor: pointer;
    transition: all 0.2s; border: none; font-family: inherit;
}
.btn-primary { background: var(--gradient); color: white; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { opacity: 0.9; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-light); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* TOPBAR */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar-left .logo-sm { font-size: 1.1rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 6px; }
.topbar-left .logo-sm i { color: var(--primary-light); }
.topbar-left .logo-sm strong { color: var(--primary-light); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.credits-badge {
    padding: 6px 14px; border-radius: 20px;
    background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2);
    color: var(--success); font-size: 0.85rem; font-weight: 600;
}
.user-name { font-size: 0.9rem; font-weight: 500; }

/* TABS */
.app-tabs {
    display: flex; gap: 4px; padding: 16px 24px 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.tab {
    padding: 10px 20px; border: none; background: transparent;
    color: var(--text-muted); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.2s; white-space: nowrap; font-family: inherit;
    display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text-light); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }

/* PANELS */
.main-content { padding: 0; }
.panel { padding: 24px; }

/* EMPTY STATE */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; opacity: 0.3; }
.empty-state a { color: var(--primary-light); text-decoration: none; }

/* DEBATES GRID */
.debates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.debate-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px; cursor: pointer;
    transition: all 0.2s;
}
.debate-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.debate-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; }
.debate-card-topic { font-weight: 600; font-size: 0.95rem; flex: 1; }
.debate-card-status {
    padding: 3px 10px; border-radius: 12px; font-size: 0.7rem;
    font-weight: 600; white-space: nowrap;
}
.status-active { background: rgba(34,197,94,0.15); color: var(--success); }
.status-waiting { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-closed { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.status-warning { background: rgba(239,68,68,0.15); color: var(--danger); }
.debate-card-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 16px; }

/* MODEL SELECTOR (multi-API) */
.personas-selector { display: flex; flex-direction: column; gap: 16px; }
.provider-group-header {
    font-size: 0.85rem; font-weight: 700; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}
.provider-group-models { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.model-option {
    padding: 12px 14px; border: 2px solid var(--border); border-radius: 10px;
    cursor: pointer; transition: all 0.2s; background: var(--bg-input);
}
.model-option:hover { border-color: var(--primary); }
.model-option.selected { border-color: var(--primary); background: rgba(99,102,241,0.1); box-shadow: 0 0 12px rgba(99,102,241,0.15); }
.mo-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mo-name { font-size: 0.85rem; font-weight: 600; flex: 1; }
.model-tier {
    padding: 2px 8px; border-radius: 8px; font-size: 0.6rem;
    font-weight: 700; text-transform: uppercase;
}
.model-tier.economy { background: rgba(34,197,94,0.12); color: var(--success); }
.model-tier.standard { background: rgba(59,130,246,0.12); color: #3b82f6; }
.model-tier.premium { background: rgba(139,92,246,0.12); color: var(--accent); }
.model-tier.elite { background: rgba(245,158,11,0.12); color: var(--warning); }
.mo-bottom { display: flex; align-items: center; gap: 8px; }

/* PERSONALITY SELECTOR */
.personality-row {
    padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-card); margin-bottom: 10px;
}
.personality-model {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
    font-size: 0.85rem;
}
.personality-slot {
    background: var(--primary); color: white; font-size: 0.65rem; font-weight: 700;
    padding: 2px 8px; border-radius: 6px;
}
.personality-label {
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.personality-options {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.personality-chip {
    padding: 5px 10px; border-radius: 8px; font-size: 0.72rem; font-weight: 500;
    border: 1px solid var(--border); background: var(--bg-input);
    cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.personality-chip:hover { border-color: var(--primary); background: rgba(99,102,241,0.06); }
.personality-chip.selected {
    border-color: var(--primary); background: rgba(99,102,241,0.12);
    box-shadow: 0 0 8px rgba(99,102,241,0.15); font-weight: 600;
}
.mo-price { font-size: 0.78rem; font-weight: 700; color: var(--primary-light); }
.mo-desc { font-size: 0.7rem; color: var(--text-muted); flex: 1; }
.msg-model-tag {
    font-size: 0.6rem; font-weight: 500; color: var(--text-muted);
    background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 4px; margin-left: 4px;
}

/* PLAN SELECTOR */
.plan-selector { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.plan-option {
    padding: 16px; border: 2px solid var(--border); border-radius: 12px;
    cursor: pointer; transition: all 0.2s; background: var(--bg-input);
}
.plan-option:hover { border-color: var(--primary); }
.plan-option.selected { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.plan-option .plan-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.plan-option .plan-price { color: var(--primary-light); font-size: 1.2rem; font-weight: 700; }
.plan-option .plan-detail { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.create-info {
    padding: 12px 16px; background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.2); border-radius: 10px;
    margin-bottom: 16px; font-size: 0.85rem; color: var(--primary-light);
}

/* SHOP */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.shop-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px; text-align: center;
    transition: all 0.2s;
}
.shop-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.shop-card h4 { margin-bottom: 8px; }
.shop-card .shop-price { font-size: 1.8rem; font-weight: 800; color: var(--primary-light); margin: 12px 0; }
.shop-card .shop-detail { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; }

/* DEBATE VIEW */
.debate-view { display: flex; flex-direction: column; height: calc(100vh - 130px); }
.debate-view-header {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.debate-view-info { flex: 1; }
.debate-view-info h3 { font-size: 1rem; }
.debate-view-participants { font-size: 0.8rem; color: var(--text-muted); }
.debate-view-timer {
    padding: 8px 16px; border-radius: 10px;
    font-size: 1.1rem; font-weight: 700;
    background: rgba(34,197,94,0.1); color: var(--success);
    display: flex; align-items: center; gap: 8px;
}
.debate-view-timer.warning { background: rgba(239,68,68,0.1); color: var(--danger); animation: pulse 1s infinite; }
.debate-view-timer.paused { background: rgba(245,158,11,0.12); color: var(--warning); animation: pulse 2s infinite; }
.status-paused { background: rgba(245,158,11,0.15); color: var(--warning); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.debate-messages {
    flex: 1; overflow-y: auto; padding: 16px 0;
    display: flex; flex-direction: column; gap: 12px;
}
.d-msg {
    display: flex; gap: 10px; padding: 12px 16px;
    border-radius: 12px; background: var(--bg-card);
    border: 1px solid var(--border); animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.d-msg-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.85rem; flex-shrink: 0;
}
.d-msg-body { flex: 1; }
.d-msg-name { font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; }
.d-msg-text { font-size: 0.9rem; color: var(--text-light); line-height: 1.6; }
.d-msg-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }
.d-msg.system {
    background: rgba(99,102,241,0.05); border-color: rgba(99,102,241,0.15);
    justify-content: center; text-align: center; font-size: 0.85rem; color: var(--text-muted);
}

.debate-input {
    display: flex; gap: 8px; padding: 12px 0;
    border-top: 1px solid var(--border); flex-shrink: 0;
}
.debate-input .form-control { flex: 1; }

/* DEBATE VIEW WRAPPER (split: debate left + chat right) */
.debate-view-wrapper {
    display: flex; gap: 0; height: calc(100vh - 130px);
}
.debate-view-wrapper .debate-view {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
}

/* AUDIENCE BADGE */
.audience-badge {
    background: var(--danger); color: white; font-size: 0.65rem; font-weight: 700;
    padding: 1px 6px; border-radius: 10px; margin-left: 4px;
}

/* AUDIENCE SIDEBAR (always visible right panel) */
.audience-sidebar {
    width: 340px; flex-shrink: 0;
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    background: var(--bg-card);
}
.audience-header {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    background: rgba(99,102,241,0.04);
}
.audience-header h4 {
    font-size: 0.9rem; flex: 1; margin: 0;
    display: flex; align-items: center; gap: 6px;
    color: var(--primary-light);
}
.audience-viewers {
    font-size: 0.7rem; color: var(--text-muted);
    background: rgba(255,255,255,0.05); padding: 3px 10px; border-radius: 10px;
}
.audience-viewers-list {
    padding: 8px 14px; border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; gap: 6px; max-height: 60px; overflow-y: auto; flex-shrink: 0;
}
.audience-viewers-list:empty { display: none; }
.viewer-chip {
    padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 500;
    background: rgba(99,102,241,0.1); color: var(--primary-light); border: 1px solid rgba(99,102,241,0.2);
}
.audience-messages {
    flex: 1; overflow-y: auto; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px;
}
.audience-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; color: var(--text-muted); text-align: center; padding: 20px;
}
.audience-empty i { font-size: 2rem; margin-bottom: 12px; opacity: 0.3; }
.audience-empty p { font-size: 0.82rem; line-height: 1.5; max-width: 220px; }
.aud-msg {
    padding: 10px 12px; border-radius: 10px;
    background: var(--bg); border: 1px solid var(--border);
    font-size: 0.82rem; animation: fadeIn 0.2s ease;
}
.aud-msg.mod-msg {
    background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.2);
}
.aud-msg-name { font-weight: 600; font-size: 0.75rem; color: var(--primary-light); margin-bottom: 3px; }
.aud-msg.mod-msg .aud-msg-name { color: var(--warning); }
.aud-msg-text { color: var(--text-light); line-height: 1.4; }
.aud-msg-time { font-size: 0.65rem; color: var(--text-muted); margin-top: 3px; }
.aud-msg.unread { border-color: rgba(99,102,241,0.3); background: rgba(99,102,241,0.04); }

/* Audience input (moderator writes to public) */
.audience-input {
    display: flex; gap: 6px; padding: 10px 14px;
    border-top: 1px solid var(--border); flex-shrink: 0;
    background: rgba(0,0,0,0.15);
}
.audience-input .form-control {
    flex: 1; font-size: 0.82rem; padding: 8px 12px;
}

/* Responsive: stack on small screens */
@media (max-width: 900px) {
    .debate-view-wrapper { flex-direction: column; }
    .audience-sidebar { width: 100%; height: 250px; border-left: none; border-top: 1px solid var(--border); }
}

/* MODAL */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
    padding: 28px; max-width: 480px; width: 100%; animation: fadeIn 0.2s ease;
}
.modal-box h3 { font-size: 1.1rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.invite-link-box { display: flex; gap: 8px; }
.invite-link-box .form-control { flex: 1; font-size: 0.8rem; }

/* TOAST */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: 10px; font-size: 0.85rem;
    font-weight: 500; animation: slideIn 0.3s ease; min-width: 280px;
    display: flex; align-items: center; gap: 8px;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
.toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }
.toast-info { background: #1e3a5f; color: #93c5fd; border: 1px solid #3b82f6; }

/* ============================================
   ADMIN PANEL
   ============================================ */

/* Admin Sub-Tabs */
.admin-tabs {
    display: flex; gap: 4px; margin-bottom: 20px;
    border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.admin-tab {
    padding: 10px 18px; border: none; background: transparent;
    color: var(--text-muted); font-size: 0.82rem; font-weight: 500;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.2s; font-family: inherit;
    display: flex; align-items: center; gap: 6px;
}
.admin-tab:hover { color: var(--text-light); }
.admin-tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }

.admin-loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* Admin Stats */
.admin-stats-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px; margin-bottom: 24px;
}
.admin-stat-card {
    padding: 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; text-align: center;
}
.admin-stat-value { font-size: 1.6rem; font-weight: 700; }
.admin-stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Admin Section Titles */
.admin-section-title {
    font-size: 1rem; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.admin-section-desc {
    font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5;
}

/* Admin Table */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.admin-table thead tr { border-bottom: 1px solid var(--border); }
.admin-table th {
    padding: 8px 12px; text-align: left; font-weight: 600;
    color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.3px;
}
.admin-table td { padding: 10px 12px; border-bottom: 1px solid rgba(45,45,74,0.5); }
.admin-table tr:hover { background: rgba(99,102,241,0.03); }
.text-muted { color: var(--text-muted); }

.admin-role-badge {
    padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 600;
}
.role-admin { background: rgba(239,68,68,0.15); color: var(--danger); }
.role-user { background: rgba(99,102,241,0.15); color: var(--primary-light); }

/* Admin Providers / API Keys */
.admin-providers-list { display: flex; flex-direction: column; gap: 12px; }
.admin-provider-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px; transition: all 0.2s;
}
.admin-provider-card.provider-active { border-left: 3px solid var(--success); }
.admin-provider-card.provider-inactive { border-left: 3px solid var(--warning); opacity: 0.7; }
.admin-provider-card.provider-nokey { border-left: 3px solid var(--danger); opacity: 0.8; }

.admin-provider-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.admin-provider-info { display: flex; align-items: center; gap: 12px; }
.admin-provider-icon { font-size: 1.4rem; width: 40px; text-align: center; }
.admin-provider-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.admin-provider-status { font-weight: 600; }

.admin-apikey-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap;
}
.admin-apikey-display { flex: 1; }
.admin-apikey-masked {
    font-family: monospace; font-size: 0.82rem; color: var(--text-light);
    background: var(--bg-input); padding: 6px 12px; border-radius: 6px;
    display: inline-flex; align-items: center; gap: 6px;
}
.admin-apikey-empty {
    font-size: 0.82rem; color: var(--danger);
    display: inline-flex; align-items: center; gap: 6px;
}
.admin-apikey-actions { display: flex; gap: 6px; }

.admin-apikey-edit {
    margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.admin-apikey-edit .form-control { flex: 1; min-width: 200px; font-family: monospace; font-size: 0.82rem; }
.admin-apikey-edit-actions { display: flex; gap: 6px; }

/* Toggle Switch */
.admin-toggle {
    position: relative; display: inline-block; width: 44px; height: 24px;
}
.admin-toggle input { opacity: 0; width: 0; height: 0; }
.admin-toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: rgba(100,116,139,0.3); border-radius: 12px;
    transition: 0.3s;
}
.admin-toggle-slider:before {
    content: ''; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: white; border-radius: 50%;
    transition: 0.3s;
}
.admin-toggle input:checked + .admin-toggle-slider { background: var(--success); }
.admin-toggle input:checked + .admin-toggle-slider:before { transform: translateX(20px); }
.admin-toggle-sm { width: 36px; height: 20px; }
.admin-toggle-sm .admin-toggle-slider:before { height: 14px; width: 14px; }
.admin-toggle-sm input:checked + .admin-toggle-slider:before { transform: translateX(16px); }

/* Admin Models */
.admin-models-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 4px;
}
.admin-model-group { margin-bottom: 20px; }
.admin-model-group-header {
    font-size: 0.85rem; font-weight: 700; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 0;
}
.model-inactive { opacity: 0.45; }
.admin-editable {
    cursor: pointer; padding: 2px 6px; border-radius: 4px;
    border: 1px dashed transparent; transition: all 0.2s;
}
.admin-editable:hover {
    border-color: var(--primary); background: rgba(99,102,241,0.06);
}

/* Add Model Form */
.admin-add-model-form {
    background: var(--bg-card); border: 1px solid var(--primary);
    border-radius: 12px; padding: 20px; margin-bottom: 20px;
    animation: fadeIn 0.2s ease;
}
.admin-add-model-form h4 {
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.admin-form-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px; margin-bottom: 16px;
}
.admin-form-actions { display: flex; gap: 8px; }

/* Admin Config / Settings */
.admin-test-banner {
    padding: 12px 16px; border-radius: 10px; margin-bottom: 20px;
    background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
    color: var(--warning); font-size: 0.85rem;
    display: flex; align-items: center; gap: 8px;
}
.admin-config-group {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px; margin-bottom: 12px;
}
.admin-config-group-title {
    font-size: 0.9rem; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
    color: var(--text);
}
.admin-config-items { display: flex; flex-direction: column; gap: 10px; }
.admin-config-item {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; padding: 8px 0; border-bottom: 1px solid rgba(45,45,74,0.3);
}
.admin-config-item:last-child { border-bottom: none; }
.admin-config-label { flex: 1; min-width: 0; }
.admin-config-label strong { font-size: 0.82rem; font-family: monospace; color: var(--text-light); }
.admin-config-desc {
    display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 2px;
}
.admin-config-value {
    display: flex; gap: 6px; align-items: center; min-width: 300px;
}
.admin-config-value .form-control { flex: 1; font-size: 0.82rem; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .topbar { padding: 10px 16px; }
    .app-tabs { padding: 12px 16px 0; }
    .panel { padding: 16px; }
    .debate-input { flex-wrap: wrap; }
    .debate-input .form-control { min-width: 100%; }
    .admin-tabs { overflow-x: auto; }
    .admin-config-item { flex-direction: column; align-items: stretch; }
    .admin-config-value { min-width: 0; }
    .admin-form-grid { grid-template-columns: 1fr; }
    .admin-apikey-row { flex-direction: column; }
}

/* ============================================
   AUTO-DEBATE: Turn Order Card
   ============================================ */
.turn-order-card {
    background: transparent !important;
    padding: 0 !important;
}
.turn-order-inner {
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 420px;
    margin: 1rem auto;
}
.turn-order-title {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 1rem;
    text-align: center;
}
.turn-order-title i { margin-right: 0.4rem; }
.turn-order-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.turn-order-item:last-of-type { border-bottom: none; }
.turn-order-num { font-size: 1.1rem; }
.turn-order-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.75rem;
}
.turn-order-name { font-weight: 600; font-size: 0.95rem; }
.turn-order-model { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.turn-order-start {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    animation: pulse-text 1.5s ease-in-out infinite;
}
.turn-order-start i { color: var(--primary); margin-right: 0.3rem; }
@keyframes pulse-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================
   AUTO-DEBATE: Thinking Dots Animation
   ============================================ */
.ai-thinking .thinking-dots {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}
.thinking-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dot-bounce 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   AUTO-DEBATE: Status Bar (countdown + thinking)
   ============================================ */
.auto-debate-bar {
    padding: 0.6rem 1rem;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid rgba(255,255,255,0.06);
}
.adb-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    position: relative;
}
.adb-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.7rem;
    flex-shrink: 0;
}
.adb-text { flex: 1; color: var(--text-secondary); }
.adb-text strong { color: var(--text-primary); }
.adb-countdown {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    min-width: 32px;
    text-align: center;
}
.adb-progress {
    position: absolute;
    bottom: -0.6rem;
    left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}
.adb-progress-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 1s linear;
}
.adb-status.thinking .fa-spinner { color: var(--primary); }

/* Pause button — big, red and prominent */
.btn-pause-debate {
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    animation: pulse-pause 2s ease-in-out infinite;
    transition: all 0.2s;
}
.btn-pause-debate:hover {
    background: #dc2626 !important;
    transform: scale(1.05);
    animation: none;
}
@keyframes pulse-pause {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Resume button — green and prominent */
.btn-resume-debate {
    background: #22c55e !important;
    color: white !important;
    border: none !important;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    animation: pulse-resume 2s ease-in-out infinite;
    transition: all 0.2s;
}
.btn-resume-debate:hover {
    background: #16a34a !important;
    transform: scale(1.05);
    animation: none;
}
@keyframes pulse-resume {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
}

/* Close debate button — dark red, less prominent than pause */
.btn-close-debate {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
    border: 1px solid #991b1b !important;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-close-debate:hover {
    background: #991b1b !important;
    color: white !important;
    transform: scale(1.05);
}

/* Waiting room (pre-debate) */
.waiting-room {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    min-height: 300px;
}
.waiting-room-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    animation: pulse-resume 2s ease-in-out infinite;
}
.waiting-room h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
}
.waiting-room p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 400px;
}
.waiting-room-link {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 1.5rem;
}
.waiting-room-link input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}
.waiting-room-link input:focus {
    border-color: var(--primary);
    outline: none;
}
.waiting-viewers {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}
.waiting-viewers .viewer-chip {
    margin: 2px 4px;
}

/* Promote audience message to debate button */
.btn-promote-msg {
    background: none;
    border: 1px solid #06b6d4;
    color: #06b6d4;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.2s;
    vertical-align: middle;
}
.btn-promote-msg:hover {
    background: #06b6d4;
    color: #0f0f1a;
}
.btn-promote-msg.promoted {
    border-color: #22c55e;
    color: #22c55e;
    cursor: default;
}

/* ============================================
   ELEVENLABS TTS: Voice Selector
   ============================================ */
.voice-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.voice-selector select {
    flex: 1;
    font-size: 0.82rem;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s;
    cursor: pointer;
}
.voice-selector select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Audio play button on messages */
.btn-audio-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(139,92,246,0.3);
    background: rgba(139,92,246,0.1);
    color: var(--accent);
    font-size: 0.65rem;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s;
    vertical-align: middle;
}
.btn-audio-play:hover {
    background: rgba(139,92,246,0.2);
    border-color: var(--accent);
    transform: scale(1.1);
}

/* Speaking indicator (message currently playing audio) */
.d-msg.speaking {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(139,92,246,0.2);
    animation: pulse-speaking 1.5s ease-in-out infinite;
}
@keyframes pulse-speaking {
    0%, 100% { box-shadow: 0 0 0 1px rgba(139,92,246,0.2); }
    50% { box-shadow: 0 0 16px rgba(139,92,246,0.3); }
}

/* ============================================
   ADMIN: Voice Management
   ============================================ */
.admin-voices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.admin-voice-category {
    margin-bottom: 24px;
}

.admin-voice-category-title {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.admin-warning {
    background: rgba(251, 146, 60, 0.08);
    border: 1px solid rgba(251, 146, 60, 0.25);
    color: var(--warning);
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Audio mute button */
.btn-mute-audio {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-mute-audio:hover {
    border-color: var(--accent);
    color: var(--accent);
}
