/*
    Article ReAngle - 样式表
    定义了页面的整体布局、组件样式、响应式设计和动画效果。
*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* 左右布局 */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.left-pane,
.right-pane {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

section {
    margin-bottom: 30px;
}

h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

/* 标签页样式 */
.input-tabs,
.result-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.tab-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 面板操作区与添加按钮 */
.panel-actions {
    margin-top: 10px;
}

.add-btn {
    padding: 8px 12px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.add-btn:hover {
    background: #5468e0;
}

/* 输入面板 */
.input-panel {
    display: none;
}

.input-panel.active {
    display: block;
}

#inputText {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

#inputText:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 文件上传 */
.file-upload {
    text-align: center;
    padding: 40px;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.file-upload:hover {
    border-color: #667eea;
    background: #f7fafc;
}

.file-label {
    display: block;
    cursor: pointer;
}

.file-label span {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 5px;
    color: #4a5568;
}

.file-label small {
    color: #718096;
}

#fileInput {
    display: none;
}

/* URL输入 */
#urlInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

#urlInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 更大更美观的链接输入卡片容器（URL 与 YouTube 共用） */
.link-input-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}

.link-input-card input[type="url"] {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
}

.link-input-card input[type="url"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 风格控制 */
.style-controls {
    display: grid;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #4a5568;
}

.control-group select,
.control-group input[type="text"],
.control-group textarea {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.control-group select:focus,
.control-group input[type="text"]:focus,
.control-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.control-group textarea {
    min-height: 60px;
    max-height: 120px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
}

/* 文本域 + 下拉按钮 容器 */
.prompt-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.prompt-dropdown-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    height: 24px;
    width: 24px;
    border: none;
    border-radius: 4px;
    background: #e6f0ff;
    /* 浅蓝背景 */
    color: #1e40af;
    /* 深蓝箭头 */
    cursor: pointer;
    font-size: 16px;
    line-height: 24px;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    outline: none;
    z-index: 2;
}

.prompt-dropdown-btn:hover {
    background: #d6e4ff;
    /* hover 更明显 */
    color: #1e3a8a;
}

/* 悬浮下拉列表（绝对定位，不占额外布局空间） */
.preset-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    max-height: 192px;
    /* 约4项高度 */
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* 给 prompt 文本域右侧留出空间给下拉箭头 */
.prompt-wrapper textarea#promptInput {
    width: 100%;
    padding-right: 44px;
    /* 为内置箭头预留空间，保持原宽度视觉 */
}

/* 自定义滚动条（WebKit） */
.preset-dropdown::-webkit-scrollbar {
    width: 8px;
}

.preset-dropdown::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}

.preset-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}

.preset-dropdown::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 预设风格选择器 */

.preset-item {
    text-align: left;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #2d3748;
}

.preset-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.control-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.control-group.half-width {
    flex: 1;
}

.control-group input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.control-group input[type="password"]:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 滑块样式 */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

/* 处理按钮 */
#processBtn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#processBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

#processBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 已添加输入（放在输入面板下方，整行显示） */
.added-queue {
    width: 100%;
    margin-top: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
}

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

.queue-header h3 {
    margin: 0;
    font-size: 16px;
    color: #4a5568;
}

.queue-clear-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 420px;
    overflow: auto;
}

.queue-empty {
    color: #718096;
    font-size: 14px;
    padding: 8px 0;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    background: #fff;
}

.queue-item .qi-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #f4f6ff;
    color: #667eea;
    font-weight: 700;
    font-size: 14px;
    flex: 0 0 28px;
}

.queue-item .qi-body {
    flex: 1;
    min-width: 0;
}

.qi-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qi-meta {
    color: #718096;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item .qi-del {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #718096;
    padding: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    flex: 0 0 auto;
}

.queue-item .qi-del:hover {
    color: #ef4444;
    border-color: #f3c7c7;
    background: #fff5f5;
}

/* 加载动画 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #4a5568;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* 结果面板 */
.result-panel {
    display: none;
}

.result-panel.active {
    display: block;
}

.result-content {
    background: #f7fafc;
    border-radius: 8px;
    padding: 20px;
}

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

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

.result-actions button {
    padding: 8px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.result-actions button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.content-display {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 15px;
    min-height: 200px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
}

/* 对比视图 - 左右两列布局 */
.compare-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.compare-column h3 {
    margin-bottom: 10px;
    color: #4a5568;
    font-size: 1.1rem;
    text-align: left;
}

.similarity-info {
    text-align: center;
    padding: 15px;
    background: #e6fffa;
    border-radius: 8px;
    color: #234e52;
    font-weight: 600;
}

/* 响应式设计 */
@media (max-width: 992px) {
    .two-column {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    main {
        padding: 20px;
    }

    .compare-content {
        grid-template-columns: 1fr;
    }

    .result-header {
        flex-direction: column;
        align-items: stretch;
    }

    .result-actions {
        justify-content: center;
    }
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 文件选择样式 */
.selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 14px;
    color: #495057;
}

.remove-file {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-file:hover {
    background: #c82333;
}

/* 待开发标签样式 */
.coming-soon {
    font-size: 0.7em;
    color: #ff6b6b;
    background: #ffe0e0;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
    font-weight: bold;
}

/* 处理中状态样式 */
.processing-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #4a5568;
}

.processing-state .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.processing-state p {
    font-size: 16px;
    margin: 0;
    color: #718096;
}

/* 错误状态样式 */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #4a5568;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.error-state h3 {
    color: #e53e3e;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.error-state p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.error-hint {
    color: #718096;
    font-size: 14px;
    font-style: italic;
}

/* 文本变化高亮样式 */
.text-added {
    background-color: #d4edda;
    color: #155724;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 500;
    display: inline;
}

.text-changed {
    background-color: #c3e6cb;
    color: #0f5132;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 500;
    display: inline;
    border: 1px solid #a3d9a3;
}

.text-removed {
    background-color: #f8d7da;
    color: #721c24;
    text-decoration: line-through;
    padding: 1px 3px;
    border-radius: 2px;
    opacity: 0.7;
    display: inline;
}

/* 确保对比视图中的文本保持格式 */
#rewrittenContentCompare {
    white-space: pre-wrap;
    line-height: 1.6;
    font-family: inherit;
}

/* 高亮文本在对比视图中的特殊样式 */
#rewrittenContentCompare .text-changed {
    background-color: #c3e6cb !important;
    color: #0f5132 !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
    font-weight: 600 !important;
    border: 1px solid #a3d9a3 !important;
}

/* 段落对比视图样式 - 改进的布局 */
.paragraph-comparison {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.paragraph-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    align-items: stretch;
    position: relative;
    min-height: 80px;
}

/* 段落分隔线 - 浅灰色虚线 */
.paragraph-pair:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: repeating-linear-gradient(to right,
            #ccc 0px,
            #ccc 8px,
            transparent 8px,
            transparent 16px);
    border-bottom: 1px dashed #ccc;
}

.paragraph-original,
.paragraph-rewritten {
    display: flex;
    flex-direction: column;
    min-height: 80px;
    position: relative;
}

.paragraph-original {
    border-right: 1px solid #e2e8f0;
    background: #fafbfc;
}

.paragraph-rewritten {
    background: white;
}

.paragraph-content {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
    color: #4a5568;
    padding: 20px;
    min-height: 60px;
    position: relative;
    flex: 1;
}

.paragraph-original .paragraph-content {
    background: transparent;
    border: none;
}

.paragraph-rewritten .paragraph-content {
    background: transparent;
    border: none;
}

.empty-paragraph {
    background: #f8f9fa !important;
    border: 1px dashed #dee2e6 !important;
    color: #6c757d !important;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    text-align: center;
}

.empty-paragraph::before {
    content: "此段落在改写版本中不存在";
    font-size: 12px;
    color: #6c757d;
}

/* 段落编号 - 每侧单独徽标 */
.paragraph-block::before {
    content: attr(data-paragraph-number) "/" attr(data-total);
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-6px, -70%);
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid #cbd5e0;
    line-height: 1;
    z-index: 2;
}

/* 左右两侧视觉区分 */
.paragraph-block[data-side="left"]::before {
    background: #e2e8f0;
}

.paragraph-block[data-side="right"]::before {
    background: #d1fae5;
    border-color: #a7f3d0;
}

/* 段落分割线样式 - 无方框版本 */
.paragraphs-with-separators {
    display: flex;
    flex-direction: column;
}

.paragraph-block {
    margin-bottom: 0;
    position: relative;
}

.paragraph-block:last-child {
    margin-bottom: 0;
}

.paragraph-content {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
    color: #4a5568;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    margin: 0;
}

.paragraph-separator {
    height: 1px;
    background: repeating-linear-gradient(to right,
            #cbd5e0 0px,
            #cbd5e0 8px,
            transparent 8px,
            transparent 16px);
    margin: 20px 0;
    width: 100%;
}

/* 响应式设计 - 改进的移动端布局 */
@media (max-width: 768px) {
    .compare-content {
        flex-direction: column;
    }

    .compare-column h3 {
        border-right: none;
        border-left: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .compare-column:last-child h3 {
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }

    .paragraph-pair {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .paragraph-original {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        background: #f8f9fa;
    }

    .paragraph-rewritten {
        background: white;
    }

    .paragraph-content {
        padding: 15px;
    }

    .paragraph-pair::before {
        top: 5px;
        left: 5px;
        font-size: 9px;
    }
}



/* Input Section Specifics */
.input-section h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 8px;
}

/* Refactored inline styles */
.input-intro-text {
    color: #64748b;
    margin-bottom: 25px;
    /* Increase space after line */
    font-size: 0.95rem;
    line-height: 1.5;
    background: #f8fafc;
    padding: 10px 15px;
    border-radius: 6px;
    border-left: 4px solid #cbd5e1;
    /* Move the separator line here? Or just use this box style? */
    /* The user asked to put it between h2 and line.
       If I use a box style, it effectively separates h2 and content.
       Let's try to mimic the user's specific request visually:
       H2
       Text
       Line
    */
    background: transparent;
    border-radius: 0;
    border-left: none;
    padding: 0 0 15px 0;
    border-bottom: 2px solid #e2e8f0;
}


.coming-soon-placeholder {
    text-align: center;
    padding: 50px;
    color: #718096;
}