/* ========== CSS Variables ========== */
:root {
    --primary-color: #0078d4;
    --secondary-color: #106ebe;
    --accent-color: #42b983;
    --dark-bg: #1e1e1e;
    --sidebar-bg: #252526;
    --content-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --hover-bg: #f5f5f5;
    --code-bg: #282c34;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --sidebar-width: 320px;
}

/* ========== Global Reset ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: #f9f9f9;
    zoom: 0.85;
}

* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

pre,
code {
    max-width: 100%;
    overflow-x: auto;
}

/* ========== Header ========== */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-home-link {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.3s ease;
    font-weight: 500;
}

.header-home-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    font-size: 2rem;
}

.role-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ========== Main Container ========== */
.main-container {
    display: flex;
    margin-top: 70px;
    min-height: calc(100vh - 120px);
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cccccc;
    position: fixed;
    top: 70px;
    left: 0;
    bottom: 50px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #3e3e3e;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

.sidebar-header {
    padding: 1.5rem;
    background: #1e1e1e;
    border-bottom: 1px solid #3e3e3e;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h3 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.search-box {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid #3e3e3e;
    border-radius: 6px;
    background: #1e1e1e;
    color: #cccccc;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #2a2a2a;
}

/* ========== Navigation Menu ========== */
.nav-menu {
    padding: 1rem 0;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #cccccc;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    padding-left: 2rem;
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
    border-left: 4px solid var(--accent-color);
}

.nav-link i {
    font-size: 0.85rem;
    width: 20px;
}

/* ========== Section Navigation ========== */
.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.nav-section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-section-header.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-section-header i:first-child {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.nav-section-header.collapsed i:first-child {
    transform: rotate(-90deg);
}

.nav-section-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section-content.collapsed {
    max-height: 0;
}

.nav-section-content .nav-link {
    padding-left: 3rem;
    font-size: 0.9rem;
}

.coming-soon {
    padding: 0.5rem 1.5rem;
}

.coming-soon-item {
    padding: 0.5rem 0 0.5rem 3rem;
    color: #888;
    font-size: 0.85rem;
}

/* ========== Content Area ========== */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    background: var(--content-bg);
    min-height: calc(100vh - 120px);
}

.content-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.content-loading i {
    margin-right: 1rem;
    font-size: 1.5rem;
}

/* ========== Content Styles ========== */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid var(--primary-color);
}

.page-title {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.topic-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.8rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
}

.section-content {
    margin-bottom: 2rem;
}

.section-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.section-content ul,
.section-content ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.section-content li {
    margin-bottom: 0.5rem;
}

/* ========== Info Boxes ========== */
.info-box {
    padding: 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.info-box.info {
    background: #e7f3ff;
    border-color: var(--info);
}

.info-box.success {
    background: #d4edda;
    border-color: var(--success);
}

.info-box.warning {
    background: #fff3cd;
    border-color: var(--warning);
}

.info-box.danger {
    background: #f8d7da;
    border-color: var(--danger);
}

.info-box-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========== Code Blocks ========== */
.code-block {
    position: relative;
    margin: 1.5rem 0;
    max-width: 100%;
    overflow-x: auto;
}

.code-header {
    background: #21252b;
    color: #abb2bf;
    padding: 0.5rem 1rem;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.code-language {
    font-weight: 600;
    text-transform: uppercase;
}

.copy-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.copy-button:hover {
    background: var(--secondary-color);
}

.code-block pre {
    margin: 0;
    border-radius: 0 0 6px 6px;
    overflow-x: auto;
    max-width: 100%;
}

.code-block pre code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    display: block;
    white-space: pre;
}

/* Inline code */
code:not(pre code) {
    background: #f4f4f4;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #e83e8c;
    word-wrap: break-word;
}

/* ========== Tables ========== */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.comparison-table th {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.comparison-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.comparison-table tr:nth-child(even) {
    background: #f8f9fa;
}

.comparison-table tr:hover {
    background: var(--hover-bg);
}

/* ========== Cards ========== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.card-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ========== Footer ========== */
.footer {
    background: var(--sidebar-bg);
    color: #cccccc;
    text-align: center;
    padding: 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 0.9rem;
}

/* ========== Responsive Design ========== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }

    .content {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    body {
        zoom: 1;
    }

    .mobile-menu-toggle {
        display: block !important;
    }

    .header {
        padding: 0.75rem 1rem;
    }

    .header-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }

    .logo {
        font-size: 1.2rem;
        order: 2;
    }

    .mobile-menu-toggle {
        order: 1;
    }

    .logo i {
        font-size: 1.5rem;
    }

    .header-info {
        width: 100%;
        order: 3;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .header-home-link {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    .role-badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
        white-space: normal;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        width: 100%;
        max-width: 300px;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1001;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-container {
        margin-top: 90px;
    }

    .content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .page-header {
        padding: 1.5rem 0;
    }

    .page-title {
        font-size: 1.75rem;
        word-wrap: break-word;
    }

    .page-subtitle {
        font-size: 0.95rem;
    }

    .topic-section {
        max-width: 100%;
        overflow-x: hidden;
    }

    .section-title {
        font-size: 1.3rem;
        word-wrap: break-word;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 10px !important;
    }

    .card {
        padding: 1rem;
    }

    .card i {
        font-size: 1.8rem !important;
    }

    .card h3 {
        font-size: 0.85rem;
        word-wrap: break-word;
    }

    .code-block {
        font-size: 0.8rem;
        max-width: 100%;
        overflow-x: auto;
    }

    .code-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .code-block pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .comparison-table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem;
        min-width: 100px;
    }

    .info-box {
        padding: 1rem;
        max-width: 100%;
        word-wrap: break-word;
    }

    .info-box-title {
        font-size: 0.95rem;
    }

    /* Ensure all text elements wrap properly */
    p,
    li,
    .card-description {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Prevent images from overflowing */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Horizontal scroll for wide content */
    pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
}

@media (max-width: 480px) {
    .header {
        padding: 0.5rem 0.75rem;
    }

    .logo {
        font-size: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
        word-wrap: break-word;
    }

    .section-title {
        font-size: 1.1rem;
        word-wrap: break-word;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .card {
        padding: 0.75rem;
    }

    .card i {
        font-size: 1.5rem !important;
        margin-bottom: 0.3rem !important;
    }

    .card h3 {
        font-size: 0.75rem;
        word-wrap: break-word;
    }

    .content {
        padding: 0.75rem;
        max-width: 100vw;
    }

    .code-block {
        font-size: 0.75rem;
        overflow-x: auto;
    }

    .comparison-table {
        font-size: 0.75rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 0.4rem;
        font-size: 0.7rem;
    }
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* ========== Utility Classes ========== */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.badge {
    display: inline-block;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 4px;
    margin: 0.25rem;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: #333;
}

.badge-danger {
    background: var(--danger);
    color: white;
}

.badge-info {
    background: var(--info);
    color: white;
}