/* Test Mode Past Paper View Styles */
.test-mode-past-paper-view {
    --tm-bg: #020408;
    --tm-surface: rgba(255, 255, 255, 0.03);
    --tm-border: rgba(255, 255, 255, 0.08);
    --tm-accent: #3b82f6;
    --tm-accent-glow: rgba(59, 130, 246, 0.4);
    --tm-warning: #f59e0b;
    --tm-text: #f8fafc;
    --tm-text-dim: #64748b;
    --tm-glass: blur(12px);

    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--main-bg);
    color: var(--tm-text);
    z-index: 50;
    /* Standard content level, below sidebar overlay if any */
    display: none;
    /* Hidden by default */
    grid-template-columns: 1fr 420px;
}

.test-mode-past-paper-view.active {
    display: grid;
}

/* Paper Area (Middle) */
.tm-paper-zone {
    padding: 10px;
    overflow-y: scroll;
    scroll-behavior: smooth;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.02), transparent);
    position: relative;
    height: 100%;
}

/* Bento Stats Header */
.tm-bento-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 15px;
    max-width: 900px;
    margin: 0 auto 30px auto;
}

.tm-bento-item {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: var(--tm-glass);
}

.tm-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--tm-text-dim);
    font-weight: 700;
    letter-spacing: 1px;
}

.tm-stat-val {
    font-size: 1.2rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    display: block;
    margin-top: 5px;
}

.tm-progress-mini {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.tm-progress-bar {
    height: 100%;
    background: var(--tm-accent);
    box-shadow: 0 0 10px var(--tm-accent);
}

/* Paper Sheet / List Container */
.tm-paper-sheet {
    width: 100%;
    max-width: none;
    /* Allow full width as requested */
    min-height: 500px;
}

/* AI Sidebar (Right) */
.tm-ai-sidebar {
    background: rgba(2, 4, 8, 0.8);
    backdrop-filter: blur(40px);
    border-left: 1px solid var(--tm-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

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

.tm-chat-stream {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tm-bubble {
    padding: 16px;
    border-radius: 20px;
    font-size: 14px;
    max-width: 85%;
    line-height: 1.6;
}

.tm-ai-bubble {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-bottom-left-radius: 4px;
}

.tm-user-bubble {
    background: var(--tm-accent);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.tm-input-box {
    padding: 25px;
    background: rgba(0, 0, 0, 0.2);
}

.tm-input-inner {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    padding: 12px 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
}

.tm-input-inner input {
    flex: 1;
    background: none;
    border: none;
    color: white;
    outline: none;
    margin-left: 10px;
}

/* Floating Formula Dock */
.tm-formula-dock {
    position: fixed;
    bottom: 30px;
    left: calc(50% - 210px);
    transform: translateX(-50%);
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(20px);
    padding: 12px 30px;
    border-radius: 100px;
    border: 1px solid var(--tm-border);
    display: flex;
    gap: 25px;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    z-index: 1000;
}

.tm-formula-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--tm-accent);
    font-weight: 500;
}

/* Navigation Back Button override for this view */
.tm-back-btn {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 2000;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    padding: 10px 18px;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    gap: 8px;
    align-items: center;
}

.tm-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Past Paper Grid overrides for this view */
.test-mode-past-paper-view .past-papers-container {
    background: transparent !important;
    padding: 0 !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Full Height Fixes */
.tm-paper-sheet {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.test-mode-past-paper-view .past-paper-viewer {
    height: 100% !important;
    min-height: 0 !important;
    flex: 1;
}

/* Global Test Mode Active State, but only if no specific conversation is loaded */
body.test-mode-active:not(:has(.main-content.has-chat)) .main-header {
    display: none !important;
}

/* Also hide header on initial page load for testmode URL, but not if there's a conversation */
body[data-special-mode="testmode"][data-has-conversation="false"] .main-header {
    display: none !important;
}

body.test-mode-active .main-content {
    height: 100vh;
    padding-top: 0 !important;
    /* Remove header offset */
}

/* Ensure container takes full height */
body.test-mode-active .tm-paper-zone {
    height: 100vh;
    padding-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .test-mode-past-paper-view {
        grid-template-columns: 1fr;
    }

    .tm-ai-sidebar {
        display: none;
        /* Hide chat on small screens? Or overlay? */
    }
}