/* ====== CSS Variables & Theme ====== */
:root {
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --accent-light: #eef2ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --sidebar-width: 280px;
    --header-height: 60px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --accent-color: #58a6ff;
    --accent-hover: #79c0ff;
    --accent-light: #1c2d41;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
}

/* ====== Reset & Base ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* ====== Top Navigation ====== */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-left {
    display: flex;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo:hover {
    color: var(--accent-color);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.nav-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.download-btn:hover {
    background-color: var(--accent-hover);
}

.lang-switch,
.theme-switch {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.lang-switch {
    width: auto;
    padding: 8px 12px;
    gap: 6px;
    font-size: 0.9rem;
}

.lang-switch:hover,
.theme-switch:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ====== Main Layout ====== */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ====== Sidebar ====== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 20px 0;
    transition: var(--transition);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.sidebar-nav {
    padding: 0 12px;
}

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

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-bottom: 4px;
}

.nav-item {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--accent-light);
    color: var(--accent-color);
    font-weight: 500;
}

.nav-item.sub-item {
    padding-left: 24px;
    font-size: 0.85rem;
}

/* ====== Content Area ====== */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    max-width: 100%;
    min-height: calc(100vh - var(--header-height) - 60px);
}

/* ====== Home Page ====== */
.home-page {
    max-width: 1200px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg-secondary) 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 60px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.hero-desc {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 32px;
    line-height: 1.8;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.btn {
    padding: 12px 28px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    transform: translateY(-2px);
}

/* ====== Features Grid ====== */
.features-grid {
    margin-bottom: 60px;
}

.features-grid h2 {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 40px;
    color: var(--text-primary);
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.feature-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.feature-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background-color: var(--bg-tertiary);
    cursor: zoom-in;
    position: relative;
}

.feature-image::after {
    content: '\f00e';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: white;
    opacity: 0;
    transition: var(--transition);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.feature-image:hover::after {
    opacity: 0.8;
}

.feature-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.feature-image:hover img {
    transform: scale(1.05);
}

.feature-info {
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    border-top: 1px solid var(--border-color);
}

.feature-info:hover {
    background-color: var(--accent-light);
}

.feature-info:hover h3 {
    color: var(--accent-color);
}

.feature-info h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
    color: var(--text-primary);
    transition: var(--transition);
}

.feature-info h3::after {
    content: ' →';
    opacity: 0;
    transition: var(--transition);
}

.feature-info:hover h3::after {
    opacity: 1;
}

.feature-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ====== Why Section ====== */
.why-section {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    border: 1px solid var(--border-color);
}

.why-section h2 {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 40px;
    color: var(--text-primary);
}

.why-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 32px;
}

.why-item {
    text-align: center;
}

.why-item i {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin-bottom: 16px;
}

.why-item h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

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

/* ====== Document Page ====== */
.doc-page {
    max-width: 1120px;
    margin: 0 auto;
}

.doc-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 48px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* ====== Markdown Styles ====== */
.doc-content h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.doc-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-top: 48px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.doc-content h3 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.doc-content h4 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.doc-content p {
    margin-bottom: 16px;
    line-height: 1.8;
    color: var(--text-primary);
}

.doc-content ul,
.doc-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.doc-content li {
    margin-bottom: 8px;
    line-height: 1.7;
}

.doc-content code {
    background-color: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
}

.doc-content pre {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.doc-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.doc-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 20px;
    margin: 24px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Table wrapper for responsive scrolling */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 24px;
    -webkit-overflow-scrolling: touch;
}

.doc-content table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table-wrapper + * {
    margin-top: 0;
}

.doc-content th,
.doc-content td {
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
}

.doc-content td {
    white-space: normal;
    word-break: break-word;
}

.doc-content th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.doc-content tr:hover {
    background-color: var(--bg-secondary);
}

.doc-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 16px 0;
}

.doc-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 32px 0;
}

.doc-content a {
    color: var(--accent-color);
    text-decoration: underline;
}

.doc-content a:hover {
    color: var(--accent-hover);
}

/* ====== Footer ====== */
.footer {
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 24px;
    margin-left: var(--sidebar-width);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--accent-color);
}

/* ====== Mobile Menu Button ====== */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}

.mobile-menu-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ====== Sidebar Overlay ====== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 899;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* ====== Responsive ====== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .content {
        margin-left: 240px;
    }
    
    .footer {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    /* Mobile Menu Button */
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Sidebar - hidden by default, slide in when active */
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 900;
        display: block;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .content {
        margin-left: 0;
        padding: 20px;
    }
    
    .footer {
        margin-left: 0;
    }
    
    .hero {
        padding: 40px 16px;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.2rem;
    }
    
    .hero-desc {
        font-size: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        padding: 0 20px;
    }
    
    .nav-right {
        gap: 4px;
    }
    
    .nav-link {
        display: none;
    }
    
    .feature-cards {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    /* Document page mobile optimizations */
    .doc-content {
        padding: 24px 16px;
    }
    
    .doc-content h1 {
        font-size: 1.75rem;
    }
    
    .doc-content h2 {
        font-size: 1.5rem;
        margin-top: 32px;
    }
    
    .doc-content h3 {
        font-size: 1.2rem;
        margin-top: 24px;
    }
    
    .doc-content pre {
        padding: 12px;
        font-size: 0.85rem;
    }
    
    .doc-content th,
    .doc-content td {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    /* Why section mobile */
    .why-section {
        padding: 40px 20px;
    }
    
    .why-grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
    
    /* Lang switch mobile */
    .lang-switch span {
        display: none;
    }
    
    .lang-switch {
        width: 40px;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .top-nav {
        padding: 0 12px;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .why-grid {
        grid-template-columns: 1fr;
    }
    
    .content {
        padding: 16px 12px;
    }
    
    .doc-content {
        padding: 20px 12px;
    }
    
    .doc-content h1 {
        font-size: 1.5rem;
    }
    
    .doc-content h2 {
        font-size: 1.35rem;
    }
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ====== Selection ====== */
::selection {
    background-color: var(--accent-color);
    color: white;
}

/* ====== Loading State ====== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ====== Image Modal ====== */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
}

.image-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.image-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}
