/*
 * Study Buddy Main Stylesheet
 * Following Design System v1.0
 */

/* --- Access Gate --- */
.access-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
}

.access-gate.hidden {
    display: none;
}

.access-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    text-align: center;
    max-width: 380px;
    width: 100%;
}

.access-logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}

.access-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 28px;
}

.access-input-wrapper {
    display: flex;
    gap: 8px;
}

.access-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-app);
    outline: none;
    transition: border-color 0.2s;
}

.access-input:focus {
    border-color: var(--accent-primary);
}

.access-submit {
    padding: 12px 16px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.access-submit:hover {
    background: var(--accent-hover);
}

.access-error {
    color: #EF4444;
    font-size: 0.8125rem;
    margin-top: 12px;
}

:root {
    /* Base Colors */
    --bg-app: #F7F7F5;
    --bg-card: #FFFFFF;
    --text-primary: #2D2D2D;
    --text-secondary: #6B7280;
    
    /* Accent Colors */
    --accent-primary: #4F46E5;
    --accent-hover: #4338CA;
    --accent-light: #EEF2FF;
    
    /* Functional Colors */
    --success: #22C55E;
    --warning: #F59E0B;
    --ai-bubble: #F0F0EE;
    --user-bubble: #EEF2FF;
    
    /* Borders & Shadows */
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- Navigation --- */
.main-nav {
    background: var(--bg-card);
    padding: 0 24px;
    height: 72px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.nav-logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: -0.01em;
}

.nav-tabs {
    display: flex;
    height: 100%;
}

.nav-tab {
    padding: 0 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    height: 100%;
}

.nav-tab i {
    font-size: 1.2rem;
}

.nav-tab:hover {
    color: var(--accent-primary);
}

.nav-tab.active {
    color: var(--accent-primary);
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--accent-primary);
    border-radius: 3px 3px 0 0;
}

.language-switcher {
    display: flex;
    background: #F3F4F6;
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 2px;
}

.lang-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: calc(var(--radius-md) - 2px);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.lang-btn.active {
    background: white;
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

/* --- Page Structure --- */
.page {
    display: none;
    padding: 32px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.page.active {
    display: block;
}

#chat-page.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 72px);
    padding: 24px;
}

/* --- Chat Layout --- */
.chat-container {
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-header-minimal {
    padding: 8px 24px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

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

.session-info-minimal {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    opacity: 0.7;
}

.new-session-btn-minimal {
    background: var(--bg-app);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.new-session-btn-minimal:hover {
    color: var(--accent-primary);
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.new-session-btn-minimal i {
    font-size: 1.1rem;
}

/* --- Messages --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.assistant-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-content {
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.assistant-message .message-content {
    background-color: var(--ai-bubble);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* AI Assistant Avatar replacement (Initial 'S') */
.assistant-message::before {
    content: 'S';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.user-message .message-content {
    background-color: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.user-message .message-time {
    text-align: right;
}

/* --- Typing Indicator --- */
.typing-indicator {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.typing-indicator::before {
    content: 'S';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 20px;
    background-color: var(--ai-bubble);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
}

.typing-dots span {
    display: block;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0.4;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Chat Input --- */
.chat-input {
    background: white;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.quick-start-btn {
    background: var(--bg-app);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-start-btn:hover {
    background: var(--accent-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.input-wrapper {
    display: flex;
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px 8px 4px 4px; /* Slightly more right padding for the button */
    transition: all 0.2s ease;
    align-items: flex-end; /* Button will sink to bottom when multiline */
    box-shadow: var(--shadow-sm);
    position: relative;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#userInput {
    flex: 1;
    padding: 12px 12px 12px 16px; 
    border: none;
    background: transparent;
    font-size: 0.95rem;
    outline: none;
    resize: none;
    min-height: 48px; /* Roughly fits one line + padding */
    max-height: 150px;
    font-family: inherit;
    color: var(--text-primary);
    line-height: 1.5;
}

#sendButton {
    width: 36px;
    height: 36px;
    margin-bottom: 6px; /* Sinks to bottom but keeps a small margin aligning it with one-line text */
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary); /* Use primary accent color */
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

#sendButton:disabled {
    background: var(--bg-app);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

#sendButton i {
    font-size: 1rem;
}

.input-info {
    margin-top: 8px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- Subject Learning Buttons (Card Style) --- */
.learning-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.learning-button {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.learning-button:hover {
    border-color: var(--accent-primary);
    background: var(--accent-light);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.learning-button i {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

/* --- Markdown Rendering in AI Messages --- */
.message-content h1, .message-content h2, .message-content h3 {
    margin: 16px 0 8px 0;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.4rem; }
.message-content h2 { font-size: 1.25rem; }
.message-content h3 { font-size: 1.1rem; }

.message-content p {
    margin-bottom: 12px;
}

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

.message-content ul, .message-content ol {
    margin-bottom: 12px;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #1F2937;
    color: #F9FAFB;
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 16px 0;
}

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

/* --- Problems Library --- */
.problems-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.problems-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.problems-stats {
    display: flex;
    gap: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.problems-stats span strong {
    color: var(--text-primary);
    font-weight: 600;
}

.problems-filters {
    padding: 16px 24px;
    background: #F9FAFB;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.problems-filters select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
}

#review-due-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

#review-due-btn:hover {
    background: var(--accent-hover);
}

.problems-list {
    padding: 24px;
}

.problem-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.problem-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.problem-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
}

.problem-actions button {
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.problem-actions button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-review {
    background: var(--accent-light) !important;
    color: var(--accent-primary) !important;
    border-color: rgba(79, 70, 229, 0.2) !important;
}

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

.btn-edit:hover {
    background: #F9FAFB;
    color: var(--text-primary);
    border-color: #D1D5DB;
}

.btn-delete {
    margin-left: auto; /* Push delete button to the far right */
}

.btn-delete:hover {
    background: #FEF2F2 !important;
    color: #DC2626 !important;
    border-color: #FECACA !important;
}

/* --- Knowledge Graph --- */
.graph-container {
    height: calc(100vh - 136px);
    min-height: 600px; /* Ensure sufficient minimum height */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.graph-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.graph-controls {
    display: flex;
    gap: 12px;
}

.graph-controls button {
    background: var(--bg-app);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.graph-controls button:hover {
    background: var(--accent-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.graph-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative; /* For cytoscape absolute positioning context */
}

.graph-sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.graph-filters h3, .node-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.filter-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.85rem;
    outline: none;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

.node-info {
    background: #F9FAFB;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex: 1; /* Allow it to grow to fill space */
}

.node-info p {
    font-size: 0.9rem;
    margin-bottom: 8px;
    line-height: 1.5;
}

.node-info button {
    margin-top: 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.node-info button[style*="f44336"] {
    background: #EF4444; /* Red color for delete */
    margin-top: 8px;
}

.node-info button:hover {
    filter: brightness(1.1);
}

.graph-canvas-container {
    flex: 1;
    background: var(--bg-app);
    position: relative; /* Ensure cytoscape can position absolute children */
    overflow: hidden;
}

#graph-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* --- Modals --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 2000;
    /* Perfect centering using flex */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 540px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); /* More prominent shadow for floating effect */
    position: relative;
    /* Center it relative to the flex container */
    margin: auto;
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 90vh; /* Prevent it from being taller than viewport */
    overflow: hidden; /* Do not scroll the outer container */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    z-index: 10;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-header .close {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.modal-header .close:hover {
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto; /* Scroll only the body */
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Modal Form Elements */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #F9FAFB;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.form-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.form-section input[type="text"],
.form-section textarea,
.form-section select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: white;
    transition: all 0.2s ease;
    outline: none;
}

.form-section input[type="text"]::placeholder,
.form-section textarea::placeholder {
    color: #9CA3AF;
}

.form-section input[type="text"]:focus,
.form-section textarea:focus,
.form-section select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-section textarea {
    resize: vertical;
    min-height: 80px;
}

/* Collect Options (Selectable Cards) */
.collect-options {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.collect-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: white;
}

.collect-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.collect-option > span {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.collect-option > span i {
    font-size: 1.25rem;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.collect-option p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

.collect-option:hover {
    border-color: #C7D2FE; /* Lighter indigo */
    background: var(--bg-app);
}

.collect-option:has(input[type="radio"]:checked) {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.collect-option:has(input[type="radio"]:checked) > span i {
    color: var(--accent-primary);
}

/* Modal Actions (Buttons) */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 32px;
    border-top: 1px solid var(--border-color);
    background: #F9FAFB;
    z-index: 10;
}

.modal-actions button {
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

/* Primary Button (Save) */
#save-collection {
    background: var(--accent-primary);
    color: white;
}

#save-collection:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* Secondary Button (Cancel) */
#cancel-collection,
.btn-cancel {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

#cancel-collection:hover,
.btn-cancel:hover {
    background: var(--bg-app);
    color: var(--text-primary);
}

/* Review Modal Specifics */
.review-problem-container {
    background: #F9FAFB;
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.review-problem-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.review-problem-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px dashed var(--border-color);
}

.review-instruction {
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

/* Review Modal Actions (Correct / Incorrect) */
.review-actions {
    justify-content: space-between; /* Cancel on left, answers on right */
}

.review-actions-right {
    display: flex;
    gap: 12px;
}

.btn-correct {
    background: var(--success);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-correct:hover {
    background: #16A34A;
    transform: translateY(-1px);
}

.btn-incorrect {
    background: white;
    color: #DC2626; /* Red text */
    border: 1px solid #FECACA;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-incorrect:hover {
    background: #FEF2F2;
    border-color: #F87171;
}

.btn-cancel {
    order: -1; /* Move cancel to the far left */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-nav {
        padding: 0 16px;
        height: 64px;
    }
    
    .nav-logo { font-size: 1.1rem; }
    .nav-tab { padding: 0 12px; font-size: 0.85rem; }
    .nav-tab span { display: none; } /* Hide text on mobile nav tabs */
    
    .page { padding: 16px; }
    
    .chat-messages { padding: 20px 16px; }
    .message { max-width: 92%; }
    
    .graph-content { flex-direction: column; }
    .graph-sidebar { width: 100%; height: 300px; border-right: none; border-bottom: 1px solid var(--border-color); }
}

/* --- Action Buttons in Chat (Hint, Answer, Collect) --- */
.chat-problem-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    align-items: flex-start;
}

.chat-hint-section.inline-action,
.problem-collect-btn-container {
    display: inline-flex;
    flex-direction: column;
}

.chat-hint-section:not(.inline-action) {
    margin-top: 12px;
}

.chat-hint-toggle-btn,
.hint-toggle-btn,
.problem-collect-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid rgba(79, 70, 229, 0.3);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

/* For non-flex layouts where margin is still needed */
.chat-hint-section:not(.inline-action) .chat-hint-toggle-btn {
    margin-top: 8px;
    margin-right: 8px;
}

.chat-hint-toggle-btn i,
.hint-toggle-btn i,
.problem-collect-btn i {
    font-size: 1rem;
}

.chat-hint-toggle-btn:hover,
.hint-toggle-btn:hover,
.problem-collect-btn:not(:disabled):hover {
    background: var(--accent-light);
    color: var(--accent-hover);
    border-color: rgba(79, 70, 229, 0.5);
    transform: translateY(-1px);
}

.chat-hint-toggle-btn.active,
.hint-toggle-btn.active {
    background: var(--accent-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.chat-hint-content,
.hint-content {
    margin-top: 12px;
    padding: 16px;
    background: #F9FAFB;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
    font-size: 0.9rem;
    color: var(--text-primary);
    width: 100%; /* Ensure content takes full width below buttons */
}

/* Make content drop below the flex row of buttons */
.chat-problem-actions .chat-hint-content {
    position: absolute;
    left: 0;
    right: 0;
    margin-top: 40px; /* Push below the buttons row */
}

/* Smooth collapse animation for solution/answer in Modals */
.smooth-collapse {
    animation: expandContent 0.3s ease-out;
}

@keyframes expandContent {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.problem-collect-btn {
    /* Styles are unified with .chat-hint-toggle-btn above */
}

.problem-collect-btn.collected {
    background: rgba(34, 197, 94, 0.08);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.3);
    cursor: default;
    opacity: 0.8;
}
