/* 基本重置和全局样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

:root {
    --primary-blue: #2B65EC;
    --deep-space-gray: #1A1A1A;
    --terminal-green: #00FF00;
    --warning-red: #FF4444;
    --bg-color: #f4f7f6; /* 浅色模式背景 */
    --text-color: #333; /* 浅色模式文字 */
    --card-bg: #fff;
    --sidebar-bg: #e9ecef;
    --sidebar-text: #343a40;
    --sidebar-hover-bg: #d1d8de;
    --border-color: #dee2e6;
    --gradient-start: #6366f1;
    --gradient-end: #8b5cf6;
    --header-bg: #fff;
}

body.dark-mode {
    --bg-color: var(--deep-space-gray);
    --text-color: #f8f9fa;
    --card-bg: #2c2c2c;
    --sidebar-bg: #252525;
    --sidebar-text: #f8f9fa;
    --sidebar-hover-bg: #383838;
    --border-color: #444;
    --header-bg: #2c2c2c;
}

.container {
    display: flex;
    min-height: 100vh;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
}

/* 侧边栏样式 */
.sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px;
    transition: background-color 0.3s, color 0.3s;
}

.left-sidebar {
    width: 25%;
    border-right: 1px solid var(--border-color);
}

.right-sidebar {
    width: 25%;
    border-left: 1px solid var(--border-color);
    padding-top: 70px; /* Align with main content header */
}

.logo {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: 30px;
    text-align: center;
}

.logo i {
    margin-right: 10px;
}

#main-nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#main-nav .nav-item > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 5px;
    margin-bottom: 5px;
    transition: background-color 0.2s, color 0.2s;
    font-weight: 500;
}

#main-nav .nav-item > a i:first-child {
    margin-right: 10px;
    width: 20px; /* For icon alignment */
    text-align: center;
}

#main-nav .nav-item > a .fa-chevron-down {
    transition: transform 0.3s ease;
}

#main-nav .nav-item.active > a .fa-chevron-down {
    transform: rotate(180deg);
}

#main-nav .nav-item > a:hover, #main-nav .nav-item.active > a {
    background-color: var(--primary-blue);
    color: #fff;
}

#main-nav .submenu {
    list-style-type: none;
    padding-left: 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

#main-nav .submenu.open {
    max-height: 500px; /* Adjust as needed */
}

#main-nav .submenu li a {
    display: block;
    padding: 8px 15px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.9em;
}

#main-nav .submenu li a:hover {
    background-color: var(--sidebar-hover-bg);
}

.theme-switcher {
    margin-top: auto; /* Pushes to bottom if sidebar is flex column */
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#theme-toggle {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

#theme-toggle i {
    margin-right: 8px;
}

/* 主内容区 */
.main-content {
    width: 50%;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-color);
}

.main-header {
    background-color: var(--header-bg);
    padding: 15px 20px;
    margin: -20px -20px 20px -20px; /* Extend to full width */
    border-bottom: 1px solid var(--border-color);
    /* position: sticky; */
    top: 0;
    z-index: 100;
}

.search-bar {
    display: flex;
}

#search-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px 0 0 5px;
    font-size: 1em;
    background-color: var(--card-bg);
    color: var(--text-color);
}

#search-button {
    padding: 10px 15px;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
}

.content-section {
    margin-bottom: 40px;
}

.content-section h2 {
    color: var(--primary-blue);
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.command-category h3 {
    color: var(--text-color);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* 命令卡片样式 */
.command-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s ease;
}

.command-card:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.command-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.command-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

.command-syntax {
    background-color: var(--deep-space-gray);
    color: var(--terminal-green);
    padding: 8px 12px;
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1em;
    display: inline-block;
    word-break: break-all;
}

body.dark-mode .command-syntax {
    background-color: #333; /* Darker gray for dark mode syntax bg */
}

.command-card p {
    margin-bottom: 10px;
    font-size: 0.95em;
}

.command-description, .command-scenario, .command-notes, .command-tips, .command-related {
    padding-left: 25px; /* Indent for icon alignment */
    position: relative;
}

.command-card p::before {
    position: absolute;
    left: 0;
    font-family: "Font Awesome 5 Free"; 
    font-weight: 900; 
    margin-right: 10px;
}

.command-description::before { content: "\f05a"; color: var(--primary-blue); } /* fas fa-info-circle */
.command-scenario::before { content: "\f140"; color: var(--terminal-green); } /* fas fa-bullseye */
.command-notes::before { content: "\f071"; color: var(--warning-red); } /* fas fa-exclamation-triangle */
.command-tips::before { content: "\f0eb"; color: #f0ad4e; } /* fas fa-lightbulb */
.command-related::before { content: "\f0c1"; color: #5bc0de; } /* fas fa-link */


/* 右侧工具栏 */
.right-sidebar h3 {
    color: var(--primary-blue);
    margin-top: 0;
    margin-bottom: 10px;
}

#history-list {
    list-style-type: none;
    padding: 0;
    margin-bottom: 20px;
}

#history-list li {
    padding: 5px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.9em;
}

#custom-snippets {
    width: calc(100% - 22px); /* Account for padding and border */
    height: 150px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    margin-bottom: 10px;
    background-color: var(--card-bg);
    color: var(--text-color);
}

#save-snippet-button {
    background-color: var(--terminal-green);
    color: var(--deep-space-gray);
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
}

/* 浮动终端模拟器 */
#floating-terminal-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-blue);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
}

#floating-terminal-window {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 400px;
    height: 300px;
    background-color: var(--deep-space-gray);
    border: 1px solid var(--primary-blue);
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: none; /* Hidden by default */
    flex-direction: column;
    z-index: 999;
}

.terminal-header {
    background-color: var(--primary-blue);
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}

.terminal-header span {
    font-weight: bold;
}

#close-floating-terminal {
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
}

#actual-floating-terminal, #web-terminal {
    flex-grow: 1;
    padding: 10px;
    overflow: hidden; /* Xterm will handle scrolling */
    background-color: var(--deep-space-gray);
}

/* Web版终端容器 */
#web-terminal-container {
    height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    margin-top: 20px;
}

/* 特色功能模块通用样式 */
.feature-section {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.feature-section p {
    margin-bottom: 15px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .left-sidebar, .right-sidebar {
        width: 20%;
    }
    .main-content {
        width: 60%;
    }
}

@media (max-width: 992px) {
    .container {
        flex-direction: column;
    }
    .left-sidebar, .right-sidebar, .main-content {
        width: 100%;
    }
    .left-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .right-sidebar {
        border-left: none;
        padding-top: 20px;
    }
    .main-header {
        position: static; /* Remove sticky header on smaller screens */
    }
}

@media (max-width: 768px) {
    #floating-terminal-window {
        width: 90%;
        height: 250px;
        bottom: 70px;
        right: 5%;
    }
    .command-syntax {
        font-size: 1em;
    }
}

/* Xterm.js specific styling */
.xterm {
    height: 100% !important;
}

.xterm .xterm-viewport {
    background-color: var(--deep-space-gray) !important;
}

.xterm .xterm-screen {
    background-color: var(--deep-space-gray) !important;
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: #1e4aa8; /* Darker blue on hover */
}