/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Main Content Layout */
.main-content {
    display: flex;
    min-height: calc(100vh - 200px);
    gap: 0;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: 1.3rem;
}

.toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.topic-list {
    list-style: none;
    padding: 0;
}

.topic-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s;
}

.topic-item:hover {
    background: #f1f5f9;
    padding-left: 2rem;
}

.topic-item.active {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    font-weight: 600;
}

.topic-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.topic-title {
    font-size: 0.95rem;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Welcome Screen */
.welcome-screen {
    text-align: center;
    padding: 3rem 1rem;
}

.welcome-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.welcome-screen h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.welcome-screen > p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.info-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.info-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.info-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.info-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Topic Content */
.topic-content {
    animation: fadeIn 0.4s ease;
}

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

.topic-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.topic-header h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.topic-meta {
    opacity: 0.9;
}

/* Subtopics */
.subtopics {
    display: grid;
    gap: 1.5rem;
}

.subtopic-card {
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.subtopic-card:hover {
    box-shadow: var(--shadow-lg);
}

.subtopic-header {
    padding: 1.2rem 1.5rem;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary-color);
}

.subtopic-header:hover {
    background: #f1f5f9;
}

.subtopic-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.toggle-icon {
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: transform 0.3s;
}

.subtopic-card.expanded .toggle-icon {
    transform: rotate(180deg);
}

.subtopic-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.subtopic-card.expanded .subtopic-content {
    max-height: 5000px;
}

.subtopic-body {
    padding: 1.5rem;
    white-space: pre-line;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Nested Subtopics */
.nested-subtopics {
    margin-top: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
}

.nested-subtopic {
    margin-bottom: 1.5rem;
}

.nested-subtopic-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: #f1f5f9;
    border-radius: 4px;
}

.nested-subtopic-content {
    padding-left: 1rem;
    color: var(--text-primary);
    line-height: 1.8;
}

/* Back Button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.back-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }

    .header h1 {
        font-size: 1.7rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .toggle-btn {
        display: block;
    }

    .content-area {
        padding: 1rem;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .topic-header {
        padding: 1.5rem;
    }

    .topic-header h2 {
        font-size: 1.5rem;
    }

    .info-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .info-card {
        padding: 1.5rem;
    }

    .welcome-icon {
        font-size: 3.5rem;
    }

    .welcome-screen h2 {
        font-size: 1.6rem;
    }

    /* Mobile Menu Toggle */
    .mobile-menu-btn {
        position: fixed;
        bottom: 2rem;
        right: 2rem;
        width: 60px;
        height: 60px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        font-size: 1.5rem;
        box-shadow: var(--shadow-lg);
        cursor: pointer;
        z-index: 999;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .topic-item {
        padding: 0.8rem 1rem;
    }

    .topic-title {
        font-size: 0.85rem;
    }

    .subtopic-header {
        padding: 1rem;
    }

    .subtopic-title {
        font-size: 0.95rem;
    }

    .subtopic-body {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* Overlay for mobile sidebar */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.overlay.active {
    display: block;
}

/* Print Styles */
@media print {
    .sidebar,
    .back-btn,
    .toggle-btn {
        display: none;
    }

    .content-area {
        padding: 0;
    }

    .subtopic-content {
        max-height: none !important;
    }
}
