/**
 * Study Mode View CSS
 * Split-screen layout: Study plan in the middle, chat on the right
 * Matches test-mode-past-paper.css design language
 */

/* CSS Variables for Study Mode */
.study-mode-view {
    --sm-bg: #020408;
    --sm-surface: rgba(255, 255, 255, 0.03);
    --sm-border: rgba(255, 255, 255, 0.08);
    --sm-accent: #f4c542;
    --sm-accent-glow: rgba(244, 197, 66, 0.4);
    --sm-text: #f8fafc;
    --sm-text-dim: #64748b;
    --sm-glass: blur(12px);

    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--main-bg);
    color: var(--sm-text);
    z-index: 50;
    display: none;
    grid-template-columns: 1fr 420px;
}

.study-mode-view.active:not(.study-animated) {
    display: grid;
    animation: fadeInUp 0.8s ease-out;
}

.study-mode-view.active.study-animated {
    display: grid;
    animation: none;
}

/* Fade-in animation for consistency with other modes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ambient Orbs */
.sm-orb {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(150px);
    pointer-events: none;
    z-index: 0;
}

/* Back Button */
.sm-back-btn {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 2000;
    background: var(--sm-surface);
    border: 1px solid var(--sm-border);
    padding: 10px 18px;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sm-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-2px);
}

/* Study Plan Zone (Middle) */
.sm-plan-zone {
    padding: 80px 40px 40px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: radial-gradient(circle at top left, rgba(244, 197, 66, 0.02), transparent);
    position: relative;
    height: 100%;
    z-index: 1;
}

.sm-plan-sheet {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 500px;
}

.sm-plan-header {
    margin-bottom: 32px;
}

.sm-plan-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--sm-text);
    margin: 0 0 8px 0;
}

.sm-plan-header p {
    font-size: 15px;
    color: var(--sm-text-dim);
    margin: 0;
}

/* Study Plan Content */
.sm-plan-content {
    background: var(--sm-surface);
    border: 1px solid var(--sm-border);
    border-radius: 20px;
    padding: 32px;
    backdrop-filter: var(--sm-glass);
    min-height: 300px;
}

/* Loading State */
.sm-plan-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    gap: 16px;
    color: var(--sm-text-dim);
}

.sm-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--sm-border);
    border-top-color: var(--sm-accent);
    border-radius: 50%;
    animation: sm-spin 1s linear infinite;
}

@keyframes sm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Markdown Content */
.sm-plan-markdown {
    color: var(--sm-text);
    line-height: 1.7;
}

.sm-plan-markdown h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 24px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--sm-border);
    color: var(--sm-accent);
}

.sm-plan-markdown h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: var(--sm-text);
}

.sm-plan-markdown p {
    margin: 12px 0;
    color: var(--sm-text-dim);
}

.sm-plan-markdown ul,
.sm-plan-markdown ol {
    padding-left: 24px;
    margin: 12px 0;
}

.sm-plan-markdown li {
    margin-bottom: 8px;
    color: var(--sm-text-dim);
}

.sm-plan-markdown strong {
    color: var(--sm-accent);
    font-weight: 600;
}

.sm-plan-markdown code {
    background: rgba(244, 197, 66, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--sm-accent);
}

/* Action Buttons */
.sm-plan-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

.sm-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--sm-border);
}

.sm-action-btn.primary {
    background: var(--sm-accent);
    color: #1a1a1a;
    border-color: var(--sm-accent);
}

.sm-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--sm-accent-glow);
}

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

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

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

.sm-bubble {
    padding: 16px;
    border-radius: 20px;
    font-size: 14px;
    max-width: 85%;
    line-height: 1.6;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

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

.sm-ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sm-bubble-content {
    flex: 1;
}

.sm-user-bubble {
    background: var(--sm-accent);
    color: #1a1a1a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Chat Input */
.sm-input-box {
    padding: 25px;
    background: rgba(0, 0, 0, 0.2);
}

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

.sm-input-inner input {
    flex: 1;
    background: none;
    border: none;
    color: white;
    outline: none;
    font-size: 14px;
}

.sm-input-inner input::placeholder {
    color: var(--sm-text-dim);
}

.sm-send-btn {
    background: var(--sm-accent);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1a1a1a;
}

.sm-send-btn:hover {
    transform: scale(1.1);
}

/* Global Study Mode Active State */
body.study-mode-active .main-header {
    display: none !important;
}

body.study-mode-active .main-content {
    height: 100vh;
    padding-top: 0 !important;
}

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

    .sm-ai-sidebar {
        display: none;
    }

    .sm-plan-zone {
        padding: 80px 20px 40px;
    }

    .sm-back-btn {
        top: 20px;
        left: 20px;
    }
}