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

/* 按钮基类 */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.btn-primary {
    background: #a5d6a7;
    color: #1b5e20;
}

.btn-primary:hover {
    background: #81c784;
}

.btn-secondary {
    background: #90caf9;
    color: #0d47a1;
}

.btn-secondary:hover {
    background: #64b5f6;
}

.btn-danger {
    background: #ef9a9a;
    color: #b71c1c;
}

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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f0f8ff;
    color: #333;
    line-height: 1.6;
}

header {
    background: #e3f2fd;
    color: #333;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 1rem auto 0;
    max-width: 1200px;
    width: 100%;
}

header h1 {
    font-size: 2rem;
    font-weight: normal;
    padding: 1rem 20px;
    margin: 0;
    text-align: center;
}

.container {
    display: flex;
    max-width: 1200px;
    margin: 20px auto;
    gap: 20px;
    padding: 0 20px;
}

/* 面板样式 */
.scripts-panel, .content-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.scripts-panel {
    flex: 1;
    max-width: 350px;
    height: 100%; /* 确保与.content-panel等高 */
}

.content-panel {
    flex: 2;
    height: 100%; /* 确保与.scripts-panel等高 */
}

.panel-header {
    background: #e3f2fd;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #d0e1f9;
}

.panel-header h2 {
    font-size: 1.2rem;
    color: #1976d2;
    font-weight: normal;
}

/* 脚本列表样式 */
.scripts-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 180px);
}

.script-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none; /* 防止拖拽时选择文本 */
}

.script-item:hover {
    background-color: #e3f2fd;
}

.script-item.active {
    background-color: #bbdefb;
    border-left: 4px solid #1976d2;
}

.script-item.dragging {
    opacity: 0.5;
    background-color: #90caf9;
}

.script-item.drag-over {
    border-top: 2px solid #1976d2;
}

.script-item h3 {
    font-size: 1rem;
    color: #1976d2;
    margin-bottom: 5px;
}

.script-item p {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 拖拽指示器 */
.drag-handle {
    float: right;
    cursor: move;
    color: #9e9e9e;
    margin-left: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.script-item:hover .drag-handle {
    opacity: 1;
}

/* 脚本内容样式 */
.script-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
}

.script-content .placeholder {
    text-align: center;
    color: #999;
    font-style: italic;
    margin: 10px 0; /* 上下边距各30px，实现对称 */
}

.script-content .placeholder + .placeholder {
    margin: 2px 0; /* 上下边距各2px，进一步缩短间距 */
}

.script-content .loading {
    text-align: center;
    color: #1976d2;
    margin-top: 50px;
}

.script-content .error {
    text-align: center;
    color: #f44336;
    font-weight: bold;
    margin-top: 50px;
}

.script-detail {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

.script-detail h3 {
    color: #1976d2;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d0e1f9;
}

.script-detail .description {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.8;
}


.code-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.left-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.code-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-header h4 {
    color: #1976d2;
    margin: 0;
}

.theme-selector {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f0f8ff; /* 与脚本内容背景色相近 */
    font-size: 0.85rem;
    cursor: pointer;
    color: #333;
    min-width: 100px;
}

.theme-selector:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* 代码区域内的主题选择框 */
.code-inline-theme-selector {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f6f8fa; /* 与highlight.js默认主题背景色相近 */
    font-size: 0.8rem;
    cursor: pointer;
    color: #333;
    min-width: 90px;
    z-index: 10;
}

.code-inline-theme-selector:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.edit-actions {
    display: flex;
    gap: 10px;
}

.code-actions {
    display: none;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-primary {
    background: #4caf50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #2196f3;
    color: white;
}

.btn-secondary:hover {
    background: #0b7dda;
}

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

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

.copy-btn {
    @extend .btn;
    @extend .btn-primary;
}

.edit-btn {
    @extend .btn;
    @extend .btn-secondary;
}

.delete-btn {
    @extend .btn;
    @extend .btn-danger;
}

.script-detail .actions {
    display: none;
}

.edit-btn, .delete-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.edit-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    background: #2196f3;
    color: white;
}

.edit-btn:hover {
    background: #0b7dda;
}

.delete-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    background: #f44336;
    color: white;
}

.delete-btn:hover {
    background: #d32f2f;
}


/* 编辑表单样式 */
.edit-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

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

.edit-form .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.edit-form .form-group input,
.edit-form .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

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

.edit-form .code-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.edit-form .code-editor textarea {
    flex: 1;
    min-height: 200px;
    font-family: 'Consolas', 'Courier New', monospace;
}

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

.edit-form .form-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.edit-form .form-actions .save-btn {
    @extend .btn;
    @extend .btn-primary;
}

.edit-form .form-actions .cancel-btn {
    @extend .btn;
    @extend .btn-danger;
}

.edit-form .form-actions .cancel-btn:hover {
    background: #da190b;
}

/* 添加按钮样式 */
.add-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
    flex-shrink: 0; /* 防止按钮在空间不足时缩小 */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.add-btn:hover {
    background: #45a049;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.add-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

.add-btn:disabled:hover {
    background: #cccccc;
    box-shadow: none;
}

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

.modal-content {
    background-color: #fefefe;
    margin: 2% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-height: 96vh;
    overflow-y: auto;
}

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

.close:hover,
.close:focus {
    color: #000;
}

.modal-content h2 {
    color: #1976d2;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d0e1f9;
}

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

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

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

.form-group textarea {
    resize: vertical;
}

.form-actions {
    text-align: right;
}

.form-actions button {
    padding: 10px 20px;
    margin-left: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.form-actions button[type="submit"] {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    background: #4caf50;
    color: white;
}

.form-actions button[type="submit"]:hover {
    background: #45a049;
}

.form-actions button[type="submit"]:disabled {
    background: #aaa;
    cursor: not-allowed;
}

.cancel-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    background: #f44336;
    color: white;
}

.cancel-btn:hover {
    background: #da190b;
}

/* 复制成功提示样式 */
.copy-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 4px;
    font-size: 1.1rem;
    z-index: 2000;
    display: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 返回主页按钮样式 */
.back-to-home {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #4a90e2;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    text-decoration: none;
}

.back-to-home:hover {
    background: #3a7bc8;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.back-to-home svg {
    width: 24px;
    height: 24px;
}


/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .scripts-panel {
        max-width: 100%;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .add-btn {
        align-self: flex-end;
    }
}