/* 全局样式 */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #7c3aed;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --success-color: #059669;
    --info-color: #0891b2;

    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-light: #334155;
    --border-color: #475569;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.header-content {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.badges {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

/* 主要内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    flex: 1;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* 卡片样式 */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

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

.card-header h3 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* 输入区域样式 */
.code-input-container {
    padding: 1.5rem;
}

.input-modes {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card-light);
    padding: 0.5rem;
    border-radius: var(--radius);
}

.mode-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

.mode-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

/* 文本输入模式 */
.input-mode {
    display: none;
}

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

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.language-tag {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.editor-info {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

#codeInput {
    width: 100%;
    min-height: 300px;
    background: var(--bg-card-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

#codeInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 文件上传模式 */
.upload-area {
    text-align: center;
    padding: 3rem 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card-light);
    transition: all 0.3s;
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.upload-area i {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-area h4 {
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.file-size {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-dark);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.file-info>div {
    flex: 1;
    margin-left: 1rem;
}

#fileName {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

#fileSize {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 分析控制 */
.analysis-controls {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.analysis-options {
    margin-bottom: 1.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    margin-right: 0.75rem;
    position: relative;
    transition: all 0.2s;
}

.checkbox input:checked+.checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox input:checked+.checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* 按钮样式 */
.btn-primary,
.btn-outline,
.btn-text,
.btn-icon,
.btn-analyze {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

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

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 4px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-analyze {
    background: linear-gradient(135deg, var(--success-color), #10b981);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.875rem 2rem;
    width: 100%;
    margin-top: 1rem;
}

.btn-analyze:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

/* 历史记录 */
.history-list {
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem 1rem;
    background: var(--bg-card-light);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: var(--bg-card-light);
    transform: translateX(4px);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.history-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 结果区域 */
.results-container {
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.status-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
}

.status-message {
    color: var(--text-muted);
}

.status-message i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* 摘要卡片 */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: var(--bg-card-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.summary-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.summary-card.severity-critical .summary-icon {
    background: rgba(220, 38, 38, 0.2);
    color: var(--danger-color);
}

.summary-card.severity-high .summary-icon {
    background: rgba(217, 119, 6, 0.2);
    color: var(--warning-color);
}

.summary-card.severity-medium .summary-icon {
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary-color);
}

.summary-card.severity-low .summary-icon {
    background: rgba(5, 150, 105, 0.2);
    color: var(--success-color);
}

.summary-content h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.summary-count {
    font-size: 1.5rem;
    font-weight: 600;
}

/* 标签页 */
.results-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

.tab-content {
    flex: 1;
    overflow: hidden;
}

.tab-pane {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
}

.tab-pane.active {
    display: block;
}

/* 问题列表 */
.issues-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.issue-item {
    background: var(--bg-card-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    border-left: 4px solid;
}

.issue-item.severity-critical {
    border-left-color: var(--danger-color);
}

.issue-item.severity-high {
    border-left-color: var(--warning-color);
}

.issue-item.severity-medium {
    border-left-color: var(--primary-color);
}

.issue-item.severity-low {
    border-left-color: var(--success-color);
}

.issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.issue-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.issue-severity {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.issue-item.severity-critical .issue-severity {
    background: rgba(220, 38, 38, 0.2);
    color: var(--danger-color);
}

.issue-item.severity-high .issue-severity {
    background: rgba(217, 119, 6, 0.2);
    color: var(--warning-color);
}

.issue-item.severity-medium .issue-severity {
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary-color);
}

.issue-item.severity-low .issue-severity {
    background: rgba(5, 150, 105, 0.2);
    color: var(--success-color);
}

.issue-content {
    color: var(--text-secondary);
}

.issue-location {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.issue-suggestion {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
}

.issue-suggestion h5 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 代码视图 */
.code-viewer {
    background: #1a1a1a;
    border-radius: var(--radius);
    overflow: hidden;
}

.code-viewer pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}

.code-viewer code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* 修复建议 */
.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-item {
    background: var(--bg-card-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    border-left: 4px solid var(--success-color);
}

.suggestion-item h4 {
    color: var(--success-color);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.suggestion-content {
    color: var(--text-secondary);
}

/* 代码度量 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: var(--bg-card-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.metric-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 1s ease;
}

/* 系统信息 */
.system-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    font-weight: 500;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-indicator.active .status-dot {
    background: var(--success-color);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

/* 页脚 */
footer {
    margin-top: auto;
    padding: 1.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* 模态框 */
.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;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

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

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.sample-list {
    display: grid;
    gap: 1rem;
}

.sample-item {
    background: var(--bg-card-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.sample-item:hover {
    background: var(--bg-card);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.sample-item h4 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.sample-item p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 1.75rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .main-content {
        gap: 1rem;
    }

    .card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .card-header h3 {
        font-size: 1.1rem;
    }

    .result-controls {
        display: flex;
        gap: 0.5rem;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-links {
        flex-direction: column;
        gap: 0.75rem;
    }
}