/* style.css - Modern Document Processor Theme */
:root {
    --bg-color: #f7f9fc;
    --panel-bg: #ffffff;
    --border-color: #e0e4e9;
    --accent-color: #4285f4;
    --accent-hover: #357ae8;
    --text-color: #202124;
    --subtle-text: #5f6368;
    --shadow: 0 2px 8px rgba(0,0,0,0.07);
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

#app-container {
    display: flex;
    height: 100vh;
}

/* --- 主内容区 --- */
#main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    width: 100%;
    height: 100vh;
    box-sizing: border-box;
    transition: width 0.3s ease, margin-left 0.3s ease;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: var(--subtle-text);
}

.panel-header h3 {
    margin: 0;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- 左右面板 --- */
#left-panel, #right-panel {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    overflow: hidden;
}

/* --- 左侧输入面板 --- */
#input-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 15px;
}

#source-text {
    width: 100%;
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    font-size: 16px;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#source-text:focus {
    outline: none;
    border-color: var(--accent-color);
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: var(--subtle-text);
    transition: background-color 0.2s, border-color 0.2s;
    cursor: pointer;
}

.drop-zone.dragover {
    background-color: #e8f0fe;
    border-color: var(--accent-color);
}

.file-info { font-weight: bold; color: var(--accent-color); }

/* --- 右侧输出面板 --- */

/* --- 风格选项卡 --- */
#style-tabs {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--panel-bg);
}

.tab-header {
    display: flex;
    background-color: #f1f3f4;
}

.tab-link {
    padding: 12px 20px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 15px;
    color: var(--subtle-text);
    position: relative;
    transition: color 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-link:hover {
    color: var(--text-color);
}

.tab-link.active {
    color: var(--accent-color);
    font-weight: 600;
    background-color: var(--panel-bg);
    border-bottom-color: var(--accent-color);
}

.tab-content-wrapper {
    padding: 15px;
}

.tab-content {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
}

.tab-content.active {
    display: flex;
}

#custom-actions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.tab-content button, #add-custom-action-btn {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    background-color: #f8f9fa;
    color: var(--text-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab-content button:hover, #add-custom-action-btn:hover {
    background-color: #f1f3f4;
    border-color: #cdd2d8;
}

.custom-action-button-wrapper {
    position: relative;
}

.custom-action-button-wrapper button {
    background-color: #e8f0fe;
    border-color: #c4d8fa;
    padding-right: 30px; /* Space for the delete icon */
}

.delete-action-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    color: #a0baf3;
    cursor: pointer;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.delete-action-btn:hover {
    background-color: #d1e0fe;
    color: var(--accent-hover);
}

#add-custom-action-btn {
    border-style: dashed;
}

.tab-content button.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    font-weight: bold;
}

/* 提示词编辑区样式 */
#prompt-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}
#prompt-editor label {
    font-size: 14px;
    color: var(--subtle-text);
}
#prompt-template-area {
    width: 100%;
    min-height: 80px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
}
#prompt-template-area:focus {
    outline: none;
    border-color: var(--accent-color);
}
#submit-btn {
    padding: 10px 18px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: background-color 0.2s;
    align-self: flex-end; /* 按钮靠右 */
}
#submit-btn:hover {
    background-color: var(--accent-hover);
}


#output-area-container {
    flex-grow: 1;
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

#output-area {
    height: 100%;
    padding: 15px;
    font-size: 16px;
    line-height: 1.6;
    overflow-y: auto;
    box-sizing: border-box;
    word-wrap: break-word;
}

#output-area:empty:before {
    content: attr(data-placeholder);
    color: var(--subtle-text);
}

#output-area pre {
    background-color: #f1f3f4;
    padding: 1em;
    border-radius: 4px;
    white-space: pre-wrap;
}

#download-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

#download-buttons button, #show-history-btn {
    padding: 10px 18px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

#download-buttons button:hover, #show-history-btn:hover {
    background-color: var(--accent-hover);
}

#download-buttons button:disabled {
    background-color: #e0e0e0;
    cursor: not-allowed;
}

/* --- 加载动画 (改进) --- */
#loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    gap: 15px; /* 为元素之间添加间距 */
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

#loading-overlay p {
    margin: 0;
    font-weight: 500;
    color: var(--subtle-text);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- 新增：进度条样式 --- */
#progress-bar-container {
    width: 80%;
    max-width: 300px;
    height: 10px;
    background-color: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 5px;
    /* 过渡效果将在JS中动态设置 */
}

/* --- 历史记录 --- */
#history-sidebar {
    width: 300px;
    background: #e8ecf1;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: -300px;
    top: 0;
    height: 100%;
    z-index: 100;
    transition: left 0.3s ease;
}

#history-sidebar.visible {
    left: 0;
}

#main-content.history-visible {
    margin-left: 300px;
    width: calc(100% - 300px);
}

#history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

#history-header h3 { margin: 0; }
#history-toggle-btn { font-size: 24px; background: none; border: none; cursor: pointer; }

#history-list {
    list-style: none;
    padding: 10px; margin: 0;
    overflow-y: auto;
}

#history-list li {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

#history-list li:hover { background: #dce3ec; }
#history-list li.active { background: #fff; font-weight: bold; }
#history-list li .history-title { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
#history-list li .history-date { display: block; font-size: 12px; color: var(--subtle-text); margin-top: 5px;}

.delete-history-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    display: none;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
}

#history-list li:hover .delete-history-btn {
    display: block;
}

.delete-history-btn:hover {
    background-color: #cfd8e3;
    color: #f44336;
}


/* --- 模态框 --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex; justify-content: center; align-items: center; z-index: 200;
}

.modal-content {
    background: white; padding: 25px; border-radius: 12px;
    width: 500px; max-width: 90%; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-content h3 { margin-top: 0; }
.modal-content input, .modal-content textarea {
    width: 100%; padding: 10px; margin-bottom: 15px;
    border: 1px solid var(--border-color); border-radius: 5px; box-sizing: border-box;
}

.modal-content textarea { height: 150px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions button {
    padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer;
}

#save-custom-action-btn { background-color: var(--accent-color); color: white; }
#cancel-custom-action-btn { background-color: #eee; }