* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 左側工具列 */
.sidebar {
    width: 100px;
    background-color: #2c3e50;
    color: white;
    padding: 20px;
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 20px;
    border-bottom: 2px solid #45B8AC;
    padding-bottom: 10px;
}

.tool-section {
    margin-bottom: 25px;
}

.tool-section h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #bdc3c7;
}

/* 中間主要編輯區 */
.main-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    margin: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 右邊草稿區 */
.draft-area {
    width: 300px;
    display: flex;
    flex-direction: column;
    background-color: white;
    margin: 10px 10px 10px 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 編輯區頭部 */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #ecf0f1;
    border-bottom: 2px solid #45B8AC;
}

.editor-header h2 {
    font-size: 18px;
    color: #2c3e50;
}

/* 視圖切換按鈕 */
.view-toggle {
    display: flex;
    gap: 5px;
}

.toggle-btn {
    padding: 8px 16px;
    border: 1px solid #45B8AC;
    background-color: white;
    color: #45B8AC;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s;
}

.toggle-btn:hover {
    background-color: #e8f8f5;
}

.toggle-btn.active {
    background-color: #45B8AC;
    color: white;
}

.view-toggle .btn {
    width: auto;
    padding: 8px 16px;
    margin-bottom: 0;
}

/* 編輯區內容 */
.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.preview-area,
.code-area {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    overflow: auto;
    padding: 20px;
}

.preview-area.active,
.code-area.active {
    display: block;
}

/* 預覽模式 - 覆寫為 flex 佈局 */
.preview-area {
    display: none;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.preview-area.active {
    display: flex;
}

/* 預覽可編輯內容區 */
.preview-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    outline: none;
}

.preview-content[contenteditable="true"] {
    cursor: text;
    box-shadow: inset 0 0 0 2px rgba(69, 184, 172, 0.25);
}

/* 預覽模式編輯工具列 */
.preview-edit-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f0faf9;
    border-bottom: 1px solid #c8e9e6;
    flex-wrap: wrap;
    min-height: 38px;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-label {
    font-size: 11px;
    color: #7f8c8d;
    margin-right: 2px;
    white-space: nowrap;
    user-select: none;
}

.toolbar-btn {
    padding: 3px 9px;
    border: 1px solid #d0ece9;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.5;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #e8f8f5;
    border-color: #45B8AC;
    color: #45B8AC;
}

.toolbar-btn.active {
    background: #45B8AC;
    border-color: #45B8AC;
    color: white;
}

.toolbar-btn strong,
.toolbar-btn em,
.toolbar-btn u {
    pointer-events: none;
}


.toolbar-separator {
    width: 1px;
    height: 20px;
    background: #d5ecea;
    margin: 0 4px;
    flex-shrink: 0;
}


.code-area {
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    background-color: #f8f9fa;
    color: #2c3e50;
}

.preview-area {
    background-color: white;
    border: 1px solid #e0e0e0;
}

.placeholder {
    color: #95a5a6;
    text-align: center;
    padding: 40px;
    font-style: italic;
}

/* 按鈕樣式 */
.btn {
    width: 100%;
    padding: 10px 15px;
    margin-bottom: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    background-color: #45B8AC;
    color: white;
}

.btn:hover {
    background-color: #3a9d93;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background-color: #3498db;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: #27ae60;
}

.btn-success:hover {
    background-color: #229954;
}

/* 抓取工具區域 */
.fetch-tools {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.fetch-tools h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: #2c3e50;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 12px;
    color: #555;
    margin-bottom: 5px;
    font-weight: 500;
}

.input-group input[type="text"],
.input-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.input-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.item-count {
    margin-top: 10px;
    padding: 10px;
    background-color: #e8f8f5;
    border-left: 4px solid #45B8AC;
    border-radius: 4px;
    font-size: 13px;
    color: #2c3e50;
    display: none;
}

.item-count.show {
    display: block;
}

/* 操作按鈕 */
.action-buttons {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.action-buttons .btn {
    margin-bottom: 8px;
}

/* 模態框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #e74c3c;
}

.modal-content p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.modal-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
    line-height: 1.8;
}

.modal-content .btn {
    width: auto;
    padding: 10px 30px;
    margin-top: 10px;
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .draft-area {
        width: 400px;
    }
}

@media (max-width: 992px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .draft-area {
        width: 100%;
        height: 400px;
    }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: #3a9d93;
}

/* 預覽區域內的樣式調整 */
.preview-area table {
    max-width: 100%;
}

.preview-area img {
    max-width: 100%;
    height: auto;
}

/* 工作項目區樣式 */
.task-list {
    padding: 5px;
    flex: 1;
    overflow-y: auto;
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    margin-bottom: 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #45B8AC;
    transition: all 0.3s;
}

.task-item:hover {
    background-color: #e8f8f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.task-item.completed {
    border-left-color: #27ae60;
    background-color: #e8f5e9;
}

.task-checkbox {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    color: #45B8AC;
    min-width: 30px;
}

.task-item.completed .task-checkbox {
    color: #27ae60;
}

.task-content {
    flex: 1;
}

.task-title {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    font-size: 14px;
}

.task-description {
    display: block;
    font-size: 12px;
    color: #7f8c8d;
    line-height: 1.4;
}

.task-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.task-option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #555;
}

.task-option-label span {
    min-width: 38px;
    font-weight: 500;
    color: #7f8c8d;
}

.task-option-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: #2c3e50;
    background-color: white;
    transition: border-color 0.2s;
}

.task-option-input:focus {
    outline: none;
    border-color: #45B8AC;
    box-shadow: 0 0 0 2px rgba(69, 184, 172, 0.2);
}

.task-execute {
    width: 100%;
    padding: 6px 16px;
    margin: 10px 0 0 0;
    font-size: 12px;
}

.btn-small {
    padding: 6px 16px;
    font-size: 12px;
}

.task-item.completed .task-execute {
    background-color: #95a5a6;
    cursor: default;
}

.task-item.completed .task-execute:hover {
    background-color: #95a5a6;
    transform: none;
}

/* 工作項目日誌 */
.task-log {
    border-top: 2px solid #e0e0e0;
    padding: 15px 20px;
    background-color: #f8f9fa;
}

.task-log-toggle {
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
    transition: color 0.2s;
}

.task-log-toggle:hover {
    color: #45B8AC;
}

.task-log-arrow {
    font-size: 10px;
    color: #95a5a6;
    transition: transform 0.25s ease, color 0.2s;
    transform: rotate(0deg);
}

.task-log-toggle[aria-expanded="true"] .task-log-arrow {
    transform: rotate(90deg);
    color: #45B8AC;
}

.task-log-content {
    font-size: 12px;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 10px;
}

.task-log-content.collapsed {
    display: none;
}

.task-log-entry {
    padding: 8px;
    margin-bottom: 6px;
    background-color: white;
    border-radius: 4px;
    border-left: 3px solid #45B8AC;
}

.task-log-entry.success {
    border-left-color: #27ae60;
    background-color: #e8f5e9;
}

.task-log-entry.error {
    border-left-color: #e74c3c;
    background-color: #ffebee;
}

.task-log-time {
    color: #95a5a6;
    font-size: 11px;
    margin-right: 8px;
}

.task-log-message {
    color: #2c3e50;
}