/* 全局樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 側邊欄樣式 */
.sidebar {
    width: 300px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: #e2e8f0;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    border-right: 1px solid #475569;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 1000;
}

.logo {
    position: relative;
}

.logo h2 {
    margin-bottom: 30px;
    text-align: center;
    font-size: 1.5em;
    border-bottom: 2px solid #06b6d4;
    padding-bottom: 15px;
    color: #06b6d4;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.mobile-toggle {
    display: none;
    position: absolute;
    top: 1px;
    right: 10px;
    background: rgba(6, 182, 212, 0.2);
    border: 1px solid #06b6d4;
    color: #06b6d4;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.mobile-toggle:hover {
    background: rgba(6, 182, 212, 0.3);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.course-item {
    background: rgba(6, 182, 212, 0.1);
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(6, 182, 212, 0.3);
    backdrop-filter: blur(10px);
}

.course-item:hover {
    background: rgba(6, 182, 212, 0.2);
    transform: translateX(5px);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.course-item.active {
    background: rgba(6, 182, 212, 0.3);
    border-left: 4px solid #06b6d4;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.course-title {
    padding: 15px;
    font-weight: 600;
    font-size: 1.1em;
}

.course-description {
    padding: 0 15px 15px;
    font-size: 0.9em;
    opacity: 0.9;
    line-height: 1.4;
}

/* 主內容區域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    margin-left: 300px;
    min-height: 100vh;
}

.content-header {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 50%, #0e7490 100%);
    color: white;
    padding: 30px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.3);
}

.content-header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.content-header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.content-body {
    flex: 1;
    display: flex;
}

/* 章節列表 */
.chapter-list {
    width: 250px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-right: 1px solid #475569;
    padding: 20px;
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 300px;
    z-index: 999;
}

.chapter-item {
    background: rgba(6, 182, 212, 0.1);
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(6, 182, 212, 0.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    color: #e2e8f0;
}

.chapter-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.2);
}

.chapter-item.active {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    border-color: #06b6d4;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.chapter-title {
    padding: 15px;
    font-weight: 600;
    font-size: 1em;
}

/* 內容區域 */
.content-area {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    margin-left: 250px;
}

.welcome-message {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.welcome-message h2 {
    color: #06b6d4;
    margin-bottom: 20px;
    font-size: 2em;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.welcome-message p {
    font-size: 1.2em;
    color: #94a3b8;
    margin-bottom: 40px;
}

.profile-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.profile-card {
    background: rgba(6, 182, 212, 0.1);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid rgba(6, 182, 212, 0.3);
    backdrop-filter: blur(10px);
}

.profile-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.2);
}

.profile-card h3 {
    color: #06b6d4;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-shadow: 0 0 5px rgba(6, 182, 212, 0.3);
}

.profile-card p {
    color: #94a3b8;
    line-height: 1.6;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.feature {
    background: rgba(6, 182, 212, 0.1);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid rgba(6, 182, 212, 0.3);
    backdrop-filter: blur(10px);
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.2);
}

.feature h3 {
    color: #06b6d4;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-shadow: 0 0 5px rgba(6, 182, 212, 0.3);
}

.feature p {
    color: #94a3b8;
    line-height: 1.6;
}

/* Markdown 內容樣式 */
.markdown-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

.markdown-content h1 {
    color: #06b6d4;
    border-bottom: 3px solid #06b6d4;
    padding-bottom: 10px;
    margin-bottom: 30px;
    font-size: 2.2em;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.markdown-content h2 {
    color: #0891b2;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.8em;
    text-shadow: 0 0 5px rgba(8, 145, 178, 0.3);
}

.markdown-content h3 {
    color: #0ea5e9;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.4em;
    text-shadow: 0 0 5px rgba(14, 165, 233, 0.3);
}

.markdown-content p {
    margin-bottom: 20px;
    color: #e2e8f0;
}

.markdown-content code {
    background: rgba(6, 182, 212, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.markdown-content pre {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    border: 1px solid #475569;
}

.markdown-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.markdown-content blockquote {
    border-left: 4px solid #06b6d4;
    background: rgba(6, 182, 212, 0.1);
    padding: 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.markdown-content ul, .markdown-content ol {
    margin: 20px 0;
    padding-left: 30px;
}

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

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.markdown-content th, .markdown-content td {
    border: 1px solid #e9ecef;
    padding: 12px;
    text-align: left;
}

.markdown-content th {
    background: #06b6d4;
    color: white;
    font-weight: 600;
}

.markdown-content tr:nth-child(even) {
    background: rgba(6, 182, 212, 0.1);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
        position: relative;
        z-index: 1000;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-body {
        flex-direction: column;
    }
    
    .chapter-list {
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        position: relative;
        z-index: 999;
        left: 0;
        height: auto;
    }
    
    .content-area {
        padding: 20px;
        margin-left: 0;
    }
    
    .content-header h1 {
        font-size: 2em;
    }
    
    .profile-section {
        grid-template-columns: 1fr;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    /* 手機版課程項目優化 */
    .course-item {
        margin-bottom: 8px;
        padding: 12px;
        min-height: 44px; /* 確保觸控目標足夠大 */
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .course-title {
        padding: 12px;
        font-size: 1em;
        line-height: 1.3;
    }
    
    .course-description {
        padding: 0 12px 12px;
        font-size: 0.85em;
        line-height: 1.4;
    }
    
    /* 手機版章節項目優化 */
    .chapter-item {
        margin-bottom: 6px;
        min-height: 44px; /* 確保觸控目標足夠大 */
        display: flex;
        align-items: center;
    }
    
    .chapter-title {
        padding: 12px;
        font-size: 0.9em;
        line-height: 1.3;
    }
    
    /* 手機版觸控優化 */
    .course-item:active,
    .chapter-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* 手機版個人資料卡片優化 */
    .profile-card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    .profile-card h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }
    
    .profile-card p {
        font-size: 0.9em;
        line-height: 1.5;
    }
    
    /* 手機版選單控制 */
    .mobile-toggle {
        display: block;
    }
    
    .sidebar.collapsed {
        max-height: 80px;
        overflow: hidden;
    }
    
    .sidebar.collapsed .course-list {
        display: none;
    }
    
    .sidebar.collapsed .logo h2 {
        margin-bottom: 10px;
        padding-bottom: 5px;
    }
}

/* 載入動畫 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.2em;
    color: #667eea;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 錯誤樣式 */
.error {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
    background: #fdf2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin: 20px 0;
}

.error h3 {
    color: #dc2626;
    margin-bottom: 15px;
}

.error p {
    color: #7f1d1d;
    margin-bottom: 0;
}
