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

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.container {
    width: 80%;
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header h1 {
    color: #333;
    font-size: 24px;
}

.btn-global-settings {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-global-settings:hover {
    background: #5568d3;
}

.main-content {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.text-input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0;
    overflow: hidden;
}

.steps-config-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-left: 2px solid #e0e0e0;
    padding-left: 20px;
    min-height: 0;
    overflow: hidden;
}

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

.section-header h2 {
    color: #333;
    font-size: 18px;
}

.main-textarea {
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s;
    line-height: 1.6;
}

.main-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.text-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-execute-all {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-execute-all:hover {
    background: #218838;
}

.btn-execute-all:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-clear {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

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

.btn-add-step {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-add-step:hover {
    background: #218838;
}

.rewrite-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.rewrite-step {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background: #f9f9f9;
    transition: all 0.3s;
}

/* 折叠时隐藏步骤内容（提示词输入框） */
.rewrite-step.collapsed .step-content {
    display: none;
}

.rewrite-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.step-number {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-label {
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

.btn-toggle {
    background: #667eea;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-toggle:hover {
    background: #5568d3;
}

.step-actions {
    display: flex;
    gap: 8px;
}

.btn-execute-step {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.btn-execute-step:hover {
    background: #5568d3;
}

.btn-execute-step:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-step-settings {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.btn-step-settings:hover {
    background: #5a6268;
}

.btn-delete-step {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.btn-delete-step:hover {
    background: #c82333;
}

.step-content {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.step-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: #666;
}

.status-indicator {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.has-custom {
    background: #d4edda;
    color: #155724;
}

.status-indicator.using-global {
    background: #d1ecf1;
    color: #0c5460;
}

.step-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

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

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    color: #333;
    font-size: 20px;
}

.modal-close {
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

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

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

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

.btn-save {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-save:hover {
    background: #5568d3;
}

.btn-cancel {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-cancel:hover {
    background: #5a6268;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

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

.step-info-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.step-info-label {
    font-weight: 500;
    color: #333;
}

.step-info-value {
    color: #666;
    word-break: break-all;
}

.step-prompt-container {
    margin-bottom: 15px;
}

.step-prompt-label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.step-prompt-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
    line-height: 1.5;
}

.step-prompt-input:focus {
    outline: none;
    border-color: #667eea;
}

.step-api-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.empty-steps {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 14px;
}

/* 响应式布局 */
@media (max-width: 1024px) {
    .container {
        width: 95%;
    }
    
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .steps-config-section {
        border-left: none;
        border-top: 2px solid #e0e0e0;
        padding-left: 0;
        padding-top: 20px;
    }
    
    .main-textarea {
        min-height: 300px;
    }
    
    .rewrite-steps {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .container {
        width: 98%;
    }
    
    body {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
