/* 现代化样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 色彩系统 */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* 背景色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    /* 文字色 */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* 边框色 */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* 圆角 */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    /* 间距 */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* 字体大小 */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: var(--text-sm);
}

/* 主容器 */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-md);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* 头部样式 */
.header {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header h1 {
    color: var(--text-primary);
    font-size: var(--text-2xl);
    font-weight: 700;
    margin: 0;
}

.controls {
    display: flex;
    gap: var(--space-sm);
}

/* 按钮样式 */
.btn {
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    white-space: nowrap;
}

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

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

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

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

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

.btn-secondary:hover {
    background-color: #475569;
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
}

/* 主要内容区域 - 新布局 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    min-height: 0;
}

/* 顶部三栏布局 */
.top-three-columns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-lg);
    align-items: stretch;
}

/* 源代码输入卡片 */
.source-code-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.card-header h3 {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0;
}

.card-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.auto-detect-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* 源代码容器 */
.source-code-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

#sourceCodeInput {
    width: 100%;
    height: 100%;
    min-height: 200px;
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: var(--text-xs);
    line-height: 1.6;
    resize: vertical;
    outline: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

#sourceCodeInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
    background: var(--bg-primary);
}

/* 信息卡片 */
.info-card {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.info-card h3 {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--primary-color);
}

.info-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-light);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item strong {
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 80px;
    flex-shrink: 0;
}

.info-item span {
    color: var(--text-primary);
    word-break: break-word;
    text-align: right;
    flex: 1;
}

/* 规格信息区域 */
.specs-section {
    background: var(--bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.specs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--primary-color);
    flex-shrink: 0;
}

.specs-header h3 {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0;
}

.specs-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.specs-count {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: normal;
}

.batch-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-tertiary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
}

.batch-actions.active {
    display: flex;
}

#selectedCount {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

/* 规格网格 */
.specs-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-md);
    padding: var(--space-sm);
    min-height: auto;
}

/* 规格卡片 - 新布局：左右分栏 */
.spec-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: auto;
    height: fit-content;
}

.spec-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.spec-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* 规格编号 - 绝对定位 */
.spec-number {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    background: var(--primary-color);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    z-index: 10;
}

/* 规格内容 - 左右分栏布局 */
.spec-content {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    margin-top: var(--space-lg); /* 为绝对定位的编号留出空间 */
}

/* 左侧图片区域 */
.spec-image-container {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.spec-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.spec-card:hover .spec-image {
    transform: scale(1.05);
}

.spec-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

/* 右侧信息区域 */
.spec-info-container {
    flex: 1;
    min-width: 0;
}

/* 规格详情列表 */
.spec-details {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.spec-details-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-xs);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-light);
}

.spec-details-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.spec-details-item .label {
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 60px;
    flex-shrink: 0;
    padding-right: var(--space-sm);
}

.spec-details-item .value {
    color: var(--text-primary);
    word-break: break-word;
    text-align: right;
    flex: 1;
    min-width: 0;
}

/* 规格操作按钮 */
.spec-actions {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    display: flex;
    gap: var(--space-xs);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.spec-card:hover .spec-actions {
    opacity: 1;
}

/* 空状态 */
.no-data {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-xl);
    font-style: italic;
    grid-column: 1 / -1;
}

/* 模态弹窗 - 现代版 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(0 0 0 / 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-primary);
    margin: 2% auto;
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 80%;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    color: var(--text-primary);
    margin: 0;
    font-size: var(--text-xl);
    font-weight: 600;
}

.close {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

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

.modal-body {
    margin-bottom: var(--space-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* 源代码查看模态框 */
.source-code-modal {
    max-width: 80vw;
    max-height: 85vh;
}

.source-code-viewer {
    width: 100%;
    height: 60vh;
    min-height: 400px;
}

#expandedSourceCode {
    width: 100%;
    height: 100%;
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: var(--text-sm);
    line-height: 1.6;
    resize: none;
    outline: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 设置模态框 */
.settings-modal {
    max-width: 600px;
}

.settings-section h4 {
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    font-size: var(--text-lg);
    font-weight: 600;
}

.settings-controls {
    display: flex;
    gap: var(--space-lg);
    height: 300px;
}

.separator-setting {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.separator-setting label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.separator-input {
    padding: var(--space-sm);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    background: var(--bg-primary);
    outline: none;
    transition: border-color 0.2s ease;
    width: 200px;
}

.separator-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.help-text {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.field-list {
    flex: 1;
}

.field-select {
    width: 100%;
    height: 100%;
    padding: var(--space-sm);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    background: var(--bg-primary);
    outline: none;
    transition: border-color 0.2s ease;
}

.field-select:focus {
    border-color: var(--primary-color);
}

.settings-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 120px;
}

/* 开关样式 - 现代版 */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-medium);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* 悬浮操作按钮 */
.floating-actions {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 1000;
}

.floating-btn {
    padding: var(--space-md) var(--space-lg);
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    transition: all 0.3s ease;
}

.floating-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px -5px rgb(0 0 0 / 0.2);
}

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    color: white;
    font-size: var(--text-sm);
    font-weight: 500;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    animation: notificationSlideIn 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification.success {
    background-color: var(--success-color);
}

.notification.error {
    background-color: var(--error-color);
}

.notification.warning {
    background-color: var(--warning-color);
}

/* 选择框样式 */
.checkbox-group {
    margin-top: var(--space-md);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 全屏图片查看器 */
.fullscreen-image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: zoom-out;
}

.fullscreen-image-viewer img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.fullscreen-image-viewer .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 36px;
    cursor: pointer;
    background: none;
    border: none;
    outline: none;
    z-index: 10001;
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image-viewer .close-btn:hover {
    color: #ccc;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .top-three-columns {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .source-code-card,
    .info-card {
        min-height: auto;
    }
    
    .specs-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: var(--space-sm);
    }
    
    .header {
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-sm);
        text-align: center;
    }
    
    .floating-actions {
        bottom: 20px;
        right: 20px;
    }
    
    .floating-btn {
        min-width: 100px;
        padding: var(--space-sm) var(--space-md);
        font-size: var(--text-xs);
    }
    
    .specs-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .spec-content {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .spec-image-container {
        width: 60px;
        height: 60px;
        align-self: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: var(--space-lg);
    }
    
    .source-code-modal {
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .source-code-viewer {
        height: 50vh;
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .specs-grid {
        grid-template-columns: 1fr;
    }
    
    .spec-card {
        padding: var(--space-sm);
    }
    
    .spec-number {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
    
    .spec-details-item {
        flex-direction: column;
        gap: var(--space-xs);
    }
    
    .spec-details-item .label,
    .spec-details-item .value {
        text-align: left;
        min-width: auto;
    }
    
    .batch-actions {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-xs);
    }
    
    .specs-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }
    
    .specs-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* 滚动条样式 - 现代版 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}