:root {
    --bg-color: #F3F3F6;
    --text-color-primary: #1E1E1E;
    --input-bg-color: #FFFFFF;
    --border-color: #C6C6C9;
    --button-bg-color: #007bff;
    --button-text-color: #FFFFFF;
    --button-hover-bg-color: #0056b3;
    --success-bg-color: #d4edda;
    --success-text-color: #155724;
    --success-border-color: #c3e6cb;
    --error-bg-color: #f8d7da;
    --error-text-color: #721c24;
    --error-border-color: #f5c6cb;
}

html.dark {
    --bg-color: #1C1F21;
    --text-color-primary: #FFFFFF;
    --input-bg-color: #404547;
    --border-color: #37393c;
    --button-bg-color: #7FBBFF;
    --button-text-color: #1C1F21;
    --button-hover-bg-color: #a8d3ff;
}

body { 
    font-family: sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-color-primary); 
    margin: 0; 
    padding: 20px; 
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 有 main-wrapper 时（管理后台页面）顶部对齐 */
body.has-wrapper {
    align-items: flex-start;
    padding-top: 60px;
}

.main-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; 
    gap: 20px;
    align-items: flex-start;
    max-width: 1400px;
    margin: 0 auto;
}

.container { 
    background: var(--input-bg-color); 
    padding: 24px; 
    border-radius: 8px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
    width: 100%; 
    max-width: 350px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.container#admin-dashboard {
    max-width: calc(100% - 390px);
    min-width: 600px;
    flex: 1;
}

h1 { 
    text-align: center; 
    color: var(--text-color-primary);
    font-size: 20px;
    margin: 0 0 20px 0;
}

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

label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: bold; 
}

input[type="text"], input[type="password"] { 
    width: 100%; 
    padding: 10px; 
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    box-sizing: border-box; 
    background-color: var(--input-bg-color);
    color: var(--text-color-primary);
}

button { 
    width: 100%; 
    padding: 12px; 
    background-color: var(--button-bg-color); 
    color: var(--button-text-color); 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 16px; 
    margin-top: 10px;
}

button:hover { 
    background-color: var(--button-hover-bg-color); 
}

hr {
    margin: 20px 0;
    border: 1px solid var(--border-color);
}

.message { 
    padding: 10px; 
    margin-top: 20px; 
    border-radius: 4px; 
    text-align: center; 
}

.success { 
    background-color: var(--success-bg-color); 
    color: var(--success-text-color); 
    border: 1px solid var(--success-border-color); 
}

.error { 
    background-color: var(--error-bg-color); 
    color: var(--error-text-color); 
    border: 1px solid var(--error-border-color); 
}

.controls {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.controls button {
    width: auto;
    padding: 8px 12px;
    font-size: 14px;
    margin-top: 0;
}
/* --- Admin Dashboard Styles --- */
.panel {
    background-color: var(--input-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.panel:first-child {
    margin-top: 0;
}

.panel:last-child {
    margin-bottom: 0;
}

.panel h2 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

#task-table-container {
    max-height: 350px;
    overflow: auto;
}

#task-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#task-table th, #task-table td {
    border: 1px solid var(--border-color);
    padding: 10px 8px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 列宽分配 */
#task-table th:nth-child(1), #task-table td:nth-child(1) { width: 100px; } /* Task ID */
#task-table th:nth-child(2), #task-table td:nth-child(2) { width: 90px; } /* Status */
#task-table th:nth-child(3), #task-table td:nth-child(3) { width: 150px; } /* Created At */
#task-table th:nth-child(4), #task-table td:nth-child(4) { width: auto; } /* File */
#task-table th:nth-child(5), #task-table td:nth-child(5) { width: 70px; text-align: center; } /* Progress */
#task-table th:nth-child(6), #task-table td:nth-child(6) { width: 80px; text-align: center; } /* Actions */

#task-table thead {
    background-color: var(--bg-color);
    position: sticky;
    top: 0;
}

#task-table thead th {
    white-space: nowrap;
}

#task-table tbody tr:nth-child(even) {
    background-color: var(--bg-color);
}

#task-table .status {
    font-weight: bold;
    white-space: nowrap;
}

#task-table .status-completed { color: #28a745; }
#task-table .status-failed { color: #dc3545; }
#task-table .status-processing { color: #007bff; }

#log-container {
    margin-top: 0;
}

#log-content {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 12px;
    line-height: 1.4;
}

.log-actions {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: stretch;
}

.log-actions button {
    width: auto;
    padding: 10px 20px;
    font-size: 14px;
    margin-top: 0;
    box-sizing: border-box;
    flex: 1;
    min-width: 100px;
    max-width: 150px;
}

.log-actions button.danger {
    background-color: #dc3545;
    color: white;
}

.log-actions button.danger:hover {
    background-color: #c82333;
}

/* 响应式布局 */
@media (max-width: 1100px) {
    .main-wrapper {
        flex-direction: column;
        align-items: center;
    }
    
    .container, .container#admin-dashboard {
        max-width: 100%;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 50px 10px 10px 10px;
        align-items: flex-start;
    }
    
    body.has-wrapper {
        padding-top: 50px;
    }
    
    .main-wrapper {
        width: 100%;
    }
    
    .container {
        padding: 16px;
        max-width: 100%;
    }
    
    .container#admin-dashboard {
        max-width: 100%;
        min-width: auto;
    }
    
    h1 {
        font-size: 18px;
    }
    
    label {
        font-size: 14px;
        word-wrap: break-word;
    }
    
    #task-table-container {
        max-height: 250px;
        overflow-x: auto;
    }
    
    #task-table {
        table-layout: auto;
        font-size: 12px;
        min-width: 400px;
    }
    
    #task-table th, #task-table td {
        padding: 6px 4px;
        white-space: nowrap;
    }
    
    .controls {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 100;
    }
    
    .controls button {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .log-actions {
        flex-direction: column;
    }
    
    .log-actions button {
        max-width: none;
        width: 100%;
    }
    
    #log-content {
        max-height: 200px;
        font-size: 11px;
    }
    
    .panel {
        padding: 12px;
    }
    
    .panel h2 {
        font-size: 16px;
    }
}


/* 表格链接样式 */
#task-table a {
    color: var(--button-bg-color);
    text-decoration: none;
    font-size: 18px;
}

#task-table a:hover {
    color: var(--button-hover-bg-color);
}

#task-table td small {
    color: #888;
    font-size: 11px;
}

/* 标题样式 */
.panel h2 {
    font-size: 18px;
}

/* 控制按钮样式优化 */
.controls button {
    background-color: var(--button-bg-color);
    color: var(--button-text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.controls button:hover {
    background-color: var(--button-hover-bg-color);
}
