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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* 左侧面板样式 */
.left-panel {
    width: 40%;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: #343a40;
    color: white;
    padding: 20px;
    border-bottom: 1px solid #495057;
}

.panel-header h2 {
    margin-bottom: 15px;
    font-size: 1.5em;
}

.experiment-selector select {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    background: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
}

.experiment-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    line-height: 1.6;
}

.experiment-content h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.experiment-content h4 {
    color: #6c757d;
    margin: 15px 0 10px 0;
    font-size: 1.1em;
}

.experiment-content p {
    margin-bottom: 10px;
    color: #495057;
}

.experiment-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.experiment-content li {
    margin-bottom: 5px;
    color: #495057;
}

.experiment-content code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #e83e8c;
}

.experiment-content pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    margin: 10px 0;
    overflow-x: auto;
}

.experiment-content pre code {
    background: none;
    padding: 0;
    color: #495057;
}

.experiment-actions {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 10px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-2px);
}

.memory-info {
    margin-top: 10px;
    text-align: center;
    color: #6c757d;
    font-size: 12px;
}

.memory-info small {
    display: block;
    padding: 5px;
    background: #e9ecef;
    border-radius: 3px;
    border-left: 3px solid #28a745;
}

/* 分页导航样式 */
.experiment-pagination {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-info {
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    gap: 10px;
}

.pagination-controls .btn {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    transition: all 0.3s ease;
}

.pagination-controls .btn:hover:not(:disabled) {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.pagination-controls .btn:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #dee2e6;
}

/* 分页内容样式 */
.experiment-page {
    display: none;
}

.experiment-page.active {
    display: block;
}

.experiment-page h4 {
    color: #495057;
    margin: 15px 0 10px 0;
    font-size: 1.1em;
    border-left: 3px solid #007bff;
    padding-left: 10px;
}

.experiment-page h5 {
    color: #6c757d;
    margin: 12px 0 8px 0;
    font-size: 1em;
}

.experiment-page .step-number {
    display: inline-block;
    background: #007bff;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 8px;
}

.experiment-page .step-content {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 15px;
    margin: 10px 0;
}

.experiment-page .step-content h6 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
}

.experiment-page .step-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.experiment-page .step-content li {
    margin: 4px 0;
    color: #495057;
    font-size: 14px;
}

.experiment-content-html {
    line-height: 1.6;
    color: #495057;
}

.page-content {
    line-height: 1.6;
}

.page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 10px 0;
}

.page-content p {
    margin: 10px 0;
    color: #495057;
}

.page-content h1, .page-content h2, .page-content h3, .page-content h4, .page-content h5, .page-content h6 {
    margin: 15px 0 10px 0;
    color: #495057;
}

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

.page-content li {
    margin: 5px 0;
    color: #495057;
}

.form-actions-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.form-actions-inline .form-text {
    margin: 0;
    flex: 1;
}

/* 富文本编辑器样式 */
.rich-text-editor {
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    outline: none;
    cursor: text;
    font-size: 14px;
    line-height: 1.6;
    transition: border-color 0.3s ease;
}

.rich-text-editor:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.rich-text-editor:empty:before {
    content: attr(data-placeholder);
    color: #6c757d;
    font-style: italic;
}

.rich-text-editor.focused:not(:empty):before {
    display: none;
}

.rich-text-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 10px 0;
    cursor: pointer;
    outline: 2px solid transparent;
    transition: outline-color 0.2s ease, transform 0.1s ease;
    user-select: none;
    display: inline-block;
    vertical-align: top;
}

.rich-text-editor img:hover {
    outline-color: #007bff;
    transform: scale(1.02);
}

.rich-text-editor img:focus {
    outline-color: #007bff;
    box-shadow: 0 2px 12px rgba(0,123,255,0.3);
}

.rich-text-editor img.selected {
    outline: 2px solid #007bff;
    box-shadow: 0 2px 12px rgba(0,123,255,0.3);
}

.rich-text-editor img.resize-handle {
    resize: both;
    overflow: hidden;
}

.rich-text-editor p {
    margin: 5px 0;
}

.rich-text-editor p:first-child {
    margin-top: 0;
}

.rich-text-editor p:last-child {
    margin-bottom: 0;
}

/* 图片调整大小控制器样式 */
.image-size-control {
    position: absolute;
    background: #007bff;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 实验选择器样式 */
.experiment-selector {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-small:hover {
    background: #138496;
}

/* 自定义实验管理样式 */
.modal-content.large {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.experiment-manager {
    margin-top: 20px;
}

.manager-tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.manager-tabs .tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: #6c757d;
}

.manager-tabs .tab-btn.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.manager-tab {
    display: none;
}

.manager-tab.active {
    display: block;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.experiment-list {
    max-height: 400px;
    overflow-y: auto;
}

.experiment-item {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.experiment-item h4 {
    margin: 0 0 10px 0;
    color: #495057;
}

.experiment-item p {
    margin: 5px 0;
    color: #6c757d;
    font-size: 14px;
}

.experiment-item-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.experiment-item-actions .btn {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

/* 右侧面板样式 */
.right-panel {
    width: 60%;
    display: flex;
    flex-direction: column;
}

.editor-tabs {
    display: flex;
    background: #343a40;
    border-bottom: 1px solid #495057;
}

.tab-btn {
    background: none;
    border: none;
    color: #adb5bd;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: white;
    background: #495057;
}

.tab-btn.active {
    color: white;
    background: #495057;
    border-bottom-color: #007bff;
}

.editor-container {
    flex: 1;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.editor-tab {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex: 1;
}

.editor-tab.active {
    display: flex;
    flex-direction: column;
}

.CodeMirror {
    height: 100% !important;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100%;
}

/* 修复行号遮挡问题 - 强制正确的布局 */
.CodeMirror-gutters {
    background: #2d2d2d !important;
    border-right: 1px solid #555 !important;
    width: 3em !important;
    min-width: 3em !important;
}

.CodeMirror-linenumber {
    color: #999 !important;
    text-align: right !important;
    padding-right: 8px !important;
    width: 100% !important;
    display: inline-block !important;
}

.CodeMirror-lines {
    padding-left: 0 !important;
}

.CodeMirror-code {
    margin-left: 0 !important;
}

.CodeMirror-sizer {
    margin-left: 3em !important;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close:hover {
    color: #000;
}

.result-success {
    color: #28a745;
    font-size: 18px;
    text-align: center;
    padding: 20px;
}

.result-error {
    color: #dc3545;
    font-size: 18px;
    text-align: center;
    padding: 20px;
}

.result-info {
    color: #17a2b8;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .left-panel {
        width: 100%;
        height: 40%;
    }
    
    .right-panel {
        width: 100%;
        height: 60%;
    }
}

/* 分页编辑样式 */
.pages-editor {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background: #f8f9fa;
    margin-top: 10px;
}

.pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    border-radius: 5px 5px 0 0;
}

.pages-count {
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

.pages-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}

.page-item {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-bottom: 10px;
    background: white;
    transition: all 0.3s ease;
}

.page-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 5px 5px 0 0;
}

.page-header h5 {
    margin: 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 5px;
}

.page-actions .btn {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    transition: all 0.3s ease;
}

.page-actions .btn:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.page-actions .btn-danger:hover {
    background: #dc3545;
    border-color: #dc3545;
}

.page-actions .btn-warning:hover {
    background: #ffc107;
    color: #212529;
    border-color: #ffc107;
}

.page-preview {
    padding: 12px 15px;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
}

.page-preview p {
    margin: 5px 0;
}

.page-preview strong {
    color: #495057;
    font-weight: 600;
}

.no-pages {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 5px;
}

/* 页面编辑模态框样式 */
#pageEditModal .modal-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

#pageEditModal .form-group {
    margin-bottom: 15px;
}

#pageEditModal .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

#pageEditModal .form-group input,
#pageEditModal .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

#pageEditModal .form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* 图片管理样式 */
.images-editor {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background: #f8f9fa;
    margin-top: 10px;
}

.images-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    border-radius: 5px 5px 0 0;
}

.images-count {
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
}

.images-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.image-item {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background: white;
    transition: all 0.3s ease;
    overflow: hidden;
}

.image-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.image-preview {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.image-info {
    padding: 10px;
}

.image-info h6 {
    margin: 0 0 5px 0;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-info p {
    margin: 0 0 10px 0;
    color: #6c757d;
    font-size: 12px;
}

.image-actions {
    display: flex;
    gap: 5px;
}

.image-actions .btn {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    transition: all 0.3s ease;
}

.image-actions .btn:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.image-actions .btn-danger:hover {
    background: #dc3545;
    border-color: #dc3545;
}

.no-images {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 5px;
    grid-column: 1 / -1;
}

/* 上传进度条样式 */
.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    margin: 5px 0;
}

.form-text {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 12px;
}

/* 图片选择网格样式 */
.image-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    margin: 15px 0;
}

.image-select-item {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.image-select-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.2);
    transform: translateY(-2px);
}

.image-select-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
}

.image-select-item p {
    margin: 0;
    font-size: 12px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
