/**
 * Gemini Arena Pro Module CSS
 * 
 * Grid-based layout for multi-model comparison.
 */

.arena-module {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
    --arena-sidebar-width: 260px;
    --slot-bg: var(--bg-surface);
    --slot-border: var(--line-subtle);
}

/* ── Sidebar ───────────────────── */
.arena-sidebar {
    width: var(--arena-sidebar-width);
    border-right: 1px solid var(--line-stark);
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    padding: 16px;
    gap: 16px;
}

.arena-sidebar-header,
.arena-sidebar-footer {
    flex-shrink: 0;
}

.arena-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.arena-history-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arena-history-item:hover {
    background: var(--bg-elevated);
    color: var(--text-display);
}

.arena-history-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border-left: 2px solid var(--primary);
}

/* ── Workspace ─────────────────── */
.arena-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.arena-header {
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line-subtle);
}

.arena-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-display);
}

.arena-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ── Grid System ───────────────── */
.arena-grid {
    flex: 1;
    display: grid;
    gap: 1px;
    background: var(--line-subtle);
    /* Creates gap lines */
    overflow: hidden;
}

/* Slot Configurations */
.arena-grid.slots-1 {
    grid-template-columns: 1fr;
}

.arena-grid.slots-2 {
    grid-template-columns: 1fr 1fr;
}

.arena-grid.slots-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.arena-grid.slots-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.arena-slot {
    background: var(--bg-color);
    /* App background */
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.slot-header {
    height: 40px;
    padding: 0 12px;
    border-bottom: 1px solid var(--slot-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
}

.model-selector {
    background: transparent;
    border: none;
    color: var(--text-display);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.model-selector option {
    background: var(--bg-elevated);
    color: var(--text-display);
}

.slot-metrics {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-disabled);
    display: flex;
    gap: 8px;
}

.slot-output {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-body);
}

/* ── Input Area ────────────────── */
.arena-input-area {
    padding: 20px 24px 30px;
    border-top: 1px solid var(--line-subtle);
    background: var(--bg-color);
}

.arena-input-wrapper {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
}

#arena-prompt {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--line-stark);
    border-radius: var(--radius-lg);
    padding: 16px 50px 16px 16px;
    color: var(--text-display);
    font-size: 1rem;
    resize: none;
    min-height: 56px;
    max-height: 200px;
    line-height: 1.5;
}

#arena-prompt:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-active);
}

.arena-send-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.arena-send-btn:hover {
    transform: scale(1.05);
}

.arena-system-pill {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    cursor: pointer;
}

.arena-system-pill:hover {
    text-decoration: underline;
}

/* ── Components ────────────────── */
.arena-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.arena-btn.primary {
    background: var(--primary);
    color: #000;
}

.arena-btn.ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--line-subtle);
}

.arena-btn.ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-display);
}

.arena-btn.small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.full-width {
    width: 100%;
}

.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    background: var(--bg-elevated);
    color: var(--text-muted);
    margin-right: 4px;
}

.status-badge.active {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
}

/* ── Modal ─────────────────────── */
.arena-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.arena-modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--line-stark);
    border-radius: var(--radius-lg);
    width: 500px;
    max-width: 90%;
    padding: 24px;
    box-shadow: var(--shadow-heavy);
}

.arena-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.arena-modal-header h3 {
    margin: 0;
    color: var(--text-display);
}

.arena-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.arena-setting-group {
    margin-bottom: 20px;
}

.arena-setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-subtle);
    text-transform: uppercase;
    font-weight: 700;
}

.arena-setting-group textarea {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--line-subtle);
    border-radius: var(--radius-md);
    padding: 10px;
    color: var(--text-body);
    resize: vertical;
}

.arena-hint {
    font-size: 0.8rem;
    color: var(--text-disabled);
    margin: 0 0 8px;
}

/* ── Expanded State ──────────────── */
.arena-slot.expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: var(--bg-base);
    margin: 0;
    padding: 0;
}

.arena-slot.expanded .slot-output {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    font-size: 1.1rem;
    /* Larger text for focus mode */
    line-height: 1.7;
}

/* ── Enhanced Typography & Message Styling ──────────────── */
.message {
    padding: 16px 20px !important;
    /* Override inline styles */
    border-radius: 12px !important;
    margin-bottom: 24px !important;
    line-height: 1.6;
    font-size: 0.95rem;
    border: 1px solid transparent;
    transition: all 0.2s;
    max-width: 95%;
}

/* User Message Bubble */
.message.user {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--line-subtle);
    border-bottom-right-radius: 2px !important;
    margin-left: auto;
    /* Align right ish if we wanted, but full width is fine for arena */
}

/* Assistant Message Bubble */
.message.assistant {
    background: transparent !important;
    /* Clearer background */
    border: 1px solid var(--line-subtle);
    border-top-left-radius: 2px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.assistant.streaming {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.02) !important;
}

/* Markdown typography improvements */
.message p {
    margin-bottom: 1em;
}

.message p:last-child {
    margin-bottom: 0;
}

.message ul,
.message ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.message li {
    margin-bottom: 0.5em;
}

.message code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Roboto Mono', monospace;
    font-size: 0.85em;
    color: var(--primary-bright);
}

.message pre {
    background: rgba(0, 0, 0, 0.3) !important;
    padding: 16px !important;
    border-radius: 8px !important;
    border: 1px solid var(--line-stark);
    overflow-x: auto;
    margin: 1.2em 0;
}

.message pre code {
    background: transparent;
    padding: 0;
    color: #e6edf3;
    font-size: 0.85em;
}

.message h1,
.message h2,
.message h3,
.message h4 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    font-weight: 700;
    color: var(--text-display);
    line-height: 1.3;
}

.message h1 {
    font-size: 1.4em;
    border-bottom: 1px solid var(--line-subtle);
    padding-bottom: 0.3em;
}

.message h2 {
    font-size: 1.25em;
}

.message h3 {
    font-size: 1.1em;
}

.message strong {
    color: var(--text-display);
    font-weight: 700;
}

.message blockquote {
    border-left: 3px solid var(--primary);
    margin: 1.2em 0;
    padding-left: 1em;
    color: var(--text-muted);
    font-style: italic;
}

.message table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
}

.message th,
.message td {
    padding: 8px 12px;
    border: 1px solid var(--line-subtle);
    text-align: left;
}

.message th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-display);
}

/* ── Mobile Breakpoint ──────────────── */
@media (max-width: 768px) {

    /* Stack sidebar on top of workspace, remove fixed width */
    .arena-module {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .arena-sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--line-stark);
        padding: 12px;
    }

    /* Collapse history list height so it doesn't dominate */
    .arena-history-list {
        max-height: 120px;
    }

    /* Input area: full width, tighter padding */
    .arena-input-area {
        padding: 12px 12px 20px;
    }

    /* Multi-slot grids go single-column on mobile */
    .arena-grid.slots-2,
    .arena-grid.slots-3,
    .arena-grid.slots-4 {
        grid-template-columns: 1fr;
        grid-template-rows: unset;
    }
}