/* Study Guide Specific Styles */
.study-layout {
    display: flex;
    min-height: calc(100vh - 60px);
    margin-top: 60px; /* Offset for fixed nav */
    background: #0b1120; /* Dark blue near black */
    position: relative;
}

/* Mobile Sidebar Toggle Button in Top Nav */
.sidebar-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(217, 167, 74, 0.15);
    border: 1px solid rgba(217, 167, 74, 0.4);
    color: var(--usd-gold);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover, .sidebar-toggle-btn:active {
    background: rgba(217, 167, 74, 0.3);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Close Button Inside Sidebar Header (Mobile) */
.sidebar-close-btn {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-close-btn:hover {
    background: rgba(255, 0, 85, 0.2);
    border-color: #ff0055;
    color: #ff6688;
}

/* Dim Backdrop Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.study-sidebar {
    width: 320px;
    background: #111827; /* Slightly lighter dark slate for sidebar */
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    overflow-y: auto;
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 0 20px 15px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    color: var(--text-color);
    margin: 0;
    font-size: 1.1rem;
}

.nav-section {
    margin-bottom: 25px;
}

.nav-section-title {
    padding: 0 20px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--usd-gold);
    margin-bottom: 10px;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-list li a {
    display: block;
    padding: 8px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-list li a:hover, .nav-list li a.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--usd-cyan);
    border-left-color: var(--usd-cyan);
}

.nav-list li a i {
    width: 20px;
    margin-right: 8px;
    text-align: center;
}

.study-content {
    flex: 1;
    margin-left: 320px; /* Sidebar width */
    padding: 40px;
    max-width: 900px;
    transition: margin-left 0.3s ease;
}

/* Floating Mobile Toggle Button if user scrolls down */
.mobile-fab-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 1030;
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border: 1px solid rgba(0, 212, 255, 0.4);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(2, 132, 199, 0.4);
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: transform 0.2s, box-shadow 0.2s;
}

.mobile-fab-toggle:hover, .mobile-fab-toggle:active {
    transform: scale(1.05);
    background: linear-gradient(135deg, #0369a1, #075985);
}

/* Responsive Breakpoint for Mobile & Tablet */
@media (max-width: 992px) {
    .sidebar-toggle-btn {
        display: inline-flex;
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    .mobile-fab-toggle {
        display: inline-flex;
    }

    .study-sidebar {
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
    }

    .study-sidebar.open {
        transform: translateX(0);
    }

    .study-content {
        margin-left: 0 !important;
        padding: 24px 16px;
        width: 100%;
        max-width: 100%;
    }

    .markdown-body {
        padding: 24px 18px !important;
        border-radius: 8px !important;
        margin-bottom: 24px !important;
    }

    .top-nav {
        padding: 8px 14px;
    }

    .top-nav-inner {
        gap: 8px;
    }

    .nav-dept-name {
        font-size: 0.85rem;
    }
}

/* Markdown Content Styling */
.markdown-body {
    color: var(--text-color);
    line-height: 1.6;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 30px;
}

.markdown-body h1 {
    color: var(--usd-cyan);
}

.markdown-body ul {
    padding-left: 20px;
}

.markdown-body li {
    margin-bottom: 8px;
}

.markdown-body code {
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #fca5a5;
}

[data-theme="light"] .markdown-body code {
    background: rgba(0,0,0,0.05);
    color: #ef4444;
}

/* --- SOLID BACKGROUND FOR TEXT CONTENT --- */
.markdown-body {
    background: #1c2331; /* Solid dark window background */
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 50px;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
}

.obsidian-link {
    display: inline-block;
    color: var(--usd-cyan);
    background: rgba(0, 212, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    border: 1px solid rgba(0, 212, 255, 0.2);
    transition: all 0.2s;
}

.obsidian-link:hover {
    background: rgba(0, 212, 255, 0.25);
    border-color: var(--usd-cyan);
    color: #fff;
}

/* Tool Card & Inputs */
.tool-card {
    animation: fadeIn 0.3s ease-in-out;
}

.tool-input {
    width: 100%;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    margin-top: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tool-input:focus {
    outline: none;
    border-color: var(--usd-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
}

.tool-btn {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 8px;
    margin-bottom: 8px;
}

.tool-btn:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* KaTeX Math Styling & MathML Suppression */
.katex-mathml {
    display: none !important;
}

.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 0;
    margin: 16px 0;
}

/* Markdown Tables Styling */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.95rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.markdown-body th {
    background: rgba(30, 41, 59, 0.9);
    color: var(--usd-gold);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.markdown-body td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.markdown-body tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* 3D Flashcard Trainer Styles */
.flashcard-scene {
    perspective: 1000px;
    margin: 24px auto;
    max-width: 600px;
    height: 320px;
    cursor: pointer;
}

.flashcard-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.flashcard-card.is-flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    box-sizing: border-box;
    text-align: center;
}

.flashcard-front {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 2px solid rgba(0, 212, 255, 0.3);
    color: #f8fafc;
}

.flashcard-back {
    background: linear-gradient(145deg, #0f172a, #1e293b);
    border: 2px solid rgba(0, 255, 136, 0.4);
    color: #00ff88;
    transform: rotateY(180deg);
}

.quiz-option {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-option:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--usd-cyan);
}

.quiz-option.correct {
    background: rgba(0, 255, 136, 0.2) !important;
    border-color: #00ff88 !important;
    color: #00ff88;
}

.quiz-option.incorrect {
    background: rgba(255, 0, 85, 0.2) !important;
    border-color: #ff0055 !important;
    color: #ff6688;
}

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