/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4A90E2;
    --secondary-color: #50C878;
    --danger-color: #E74C3C;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --bg-light: #F8F9FA;
    --bg-white: #FFFFFF;
    --border-color: #E1E8ED;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    padding-top: 120px;
    color: var(--text-primary);
}

/* 主容器 */
.app-container {
    max-width: 80%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 840px 1fr;
    gap: 20px;
    min-height: calc(100vh - 140px); /* 减去header和footer的空间 */
    margin-bottom: 40px;
}

/* 左侧面板 */
.left-panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    /* 移除独立滚动 */
}

.left-panel::-webkit-scrollbar {
    width: 8px;
}

.left-panel::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.left-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.left-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Header */
.app-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--bg-light);
}

.app-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Section 样式 */
.text-input-section,
.upload-section,
.settings-section,
.action-section {
    margin-bottom: 24px;
}

.text-input-section h3,
.upload-section h3,
.settings-section h3,
.action-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 文本输入框 */
.text-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    transition: all 0.3s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

/* 按钮行 */
.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-half {
    flex: 1;
}

/* 小按钮 */
.btn-mini {
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mini:hover {
    background: var(--bg-light);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background: #c0392b;
}

/* 表单右侧 */
.form-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-name {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
}

/* 背景预览 */
.bg-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-md);
    margin-top: 12px;
    object-fit: contain;
}
.upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-light);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
    color: var(--primary-color);
}

.upload-btn.info-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.upload-btn.info-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-btn .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 设置组 */
.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.help-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    cursor: help;
    margin-left: 4px;
}

/* 选择框样式 */
.styled-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.3s ease;
}

.styled-select:hover {
    border-color: var(--primary-color);
}

.styled-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 滑块样式 */
.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.slider-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-light);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(74, 144, 226, 0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 高级设置 */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.collapsible-header .chevron {
    width: 20px;
    height: 20px;
    fill: var(--text-secondary);
    transition: transform 0.3s ease;
}

.collapsible-header.active .chevron {
    transform: rotate(180deg);
}

.advanced-settings {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.setting-group-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.setting-group-inline label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0;
}

.input-number {
    width: 100px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: right;
}

.input-number:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 边距网格 */
.margin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* 按钮样式 */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #357ABD 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    margin-top: 12px;
}

.btn-secondary:hover {
    background: #45B868;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary .icon,
.btn-secondary .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 8px 0;
}

.btn-link:hover {
    color: #357ABD;
}

/* 小按钮 */
.upload-btn-small {
    padding: 8px 16px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn-small:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.file-name {
    display: inline-block;
    margin-left: 8px;
    color: var(--primary-color);
    font-size: 12px;
}

/* 信息框 */
.info-box {
    background: linear-gradient(135deg, #E3F2FD 0%, #E8EAF6 100%);
    border-left: 4px solid var(--primary-color);
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

.info-box p {
    margin-bottom: 8px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

/* 右侧面板 */
.right-panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.preview-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light);
}

.preview-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.preview-content {
    flex: 1;
    padding: 20px;
    /* overflow: hidden; */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #F5F7FA;
    min-height: 600px;
}

.preview-image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
}

.preview-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: var(--shadow-md);
}

.preview-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    fill: var(--border-color);
    margin-bottom: 16px;
}

.preview-placeholder p {
    font-size: 14px;
}

#previewImage {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* 翻页按钮 */
.preview-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.btn-page {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-page:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 60px;
    text-align: center;
}

/* Modal 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loveseed-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 24px;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 600;
    margin-bottom: 20px;
}

.loveseed-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Loading 遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loadingText {
    margin-top: 20px;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .app-container {
        grid-template-columns: 320px 1fr;
        gap: 16px;
    }
}

@media (max-width: 992px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .left-panel {
        max-height: none;
    }
    
    .right-panel {
        min-height: 600px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .app-container {
        gap: 16px;
        min-height: auto;
    }
    
    .left-panel,
    .right-panel {
        padding: 20px;
    }
    
    .margin-grid {
        grid-template-columns: 1fr;
    }
}

/* 禁用状态 */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 成功/错误提示 */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #D4EDDA;
    color: #155724;
    border-left: 4px solid #28A745;
}

.alert-error {
    background: #F8D7DA;
    color: #721C24;
    border-left: 4px solid #DC3545;
}

.alert-info {
    background: #D1ECF1;
    color: #0C5460;
    border-left: 4px solid #17A2B8;
}

/* 页脚样式 */
.app-footer {
    width: 100%;
    padding: 40px 0;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 40px;
    color: white;
    text-align: center;
}

.footer-content {
    max-width: 80%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.footer-content p {
    font-size: 14px;
    opacity: 0.9;
}

.footer-content a {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s;
}

.footer-content a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.friend-links {
    display: flex;
    gap: 20px;
    font-size: 14px;
    opacity: 0.9;
}

.friend-links span {
    font-weight: 500;
}
