/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #7c3aed;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #059669;
    --info: #0891b2;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 6px 12px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 25px -3px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
}

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

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

/* 头部 */
header {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

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

header h1 {
    font-size: 2.5rem;
    color: var(--dark);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

header h1 i {
    color: var(--primary);
}

.subtitle {
    color: var(--gray-600);
    font-size: 1.125rem;
    margin-bottom: 20px;
}

.badges {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow);
}

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

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

/* 卡片样式 */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
    overflow: hidden;
}

.card:last-child {
    margin-bottom: 0;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
}

.card-header h3 {
    font-size: 1.25rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-actions {
    display: flex;
    gap: 12px;
}

/* 按钮样式 */
.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--gray-50);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

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

.btn-analyze {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--radius);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    width: 100%;
    margin-top: 20px;
}

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

.btn-analyze:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.btn-text:hover {
    background: var(--gray-100);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* 代码输入区域 */
.code-input-container {
    padding: 24px;
}

.input-modes {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.mode-btn {
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    color: var(--gray-700);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    transition: all 0.2s;
}

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

.mode-btn:hover:not(.active) {
    border-color: var(--gray-300);
    background: var(--gray-200);
}

.input-mode {
    display: none;
}

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

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

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

.editor-info {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--gray-500);
}

#codeInput {
    width: 100%;
    min-height: 300px;
    padding: 20px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    background: var(--gray-50);
    color: var(--gray-800);
    transition: border-color 0.2s;
}

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

#codeInput::placeholder {
    color: var(--gray-400);
    font-family: inherit;
}

/* 文件上传区域 */
.upload-area {
    border: 3px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    transition: all 0.3s;
    background: var(--gray-50);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--gray-100);
}

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

.upload-area h4 {
    font-size: 1.25rem;
    color: var(--dark);
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--gray-600);
    margin-bottom: 4px;
}

.file-size {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 24px !important;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 20px;
}

.file-info i {
    color: var(--primary);
    font-size: 24px;
}

.file-info div {
    flex: 1;
    text-align: left;
}

.file-info span {
    display: block;
}

#fileName {
    font-weight: 500;
    color: var(--dark);
}

#fileSize {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* 分析选项 */
.analysis-controls {
    margin-top: 30px;
}

.analysis-options {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 20px;
}

.analysis-options h4 {
    color: var(--dark);
    margin-bottom: 16px;
    font-size: 1rem;
}

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

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

.checkbox input {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-400);
    border-radius: 4px;
    position: relative;
    transition: all 0.2s;
}

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

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

.checkbox:hover .checkmark {
    border-color: var(--primary);
}

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

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.history-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
}

.history-item i {
    color: var(--primary);
    font-size: 18px;
}

.history-content {
    flex: 1;
}

.history-title {
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 4px;
}

.history-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
    display: flex;
    gap: 12px;
}

/* 结果区域 */
.results-container {
    padding: 24px;
    min-height: 600px;
}

.status-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    color: var(--gray-500);
}

.status-message {
    max-width: 400px;
}

.status-message i {
    font-size: 48px;
    color: var(--gray-300);
    margin-bottom: 20px;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

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

.summary-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 2px solid;
    box-shadow: var(--shadow);
}

.severity-critical {
    border-color: var(--danger);
    background: linear-gradient(135deg, #fee, #fff);
}

.severity-high {
    border-color: var(--warning);
    background: linear-gradient(135deg, #fef3c7, #fff);
}

.severity-medium {
    border-color: var(--info);
    background: linear-gradient(135deg, #cffafe, #fff);
}

.severity-low {
    border-color: var(--success);
    background: linear-gradient(135deg, #d1fae5, #fff);
}

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

.severity-critical .summary-icon {
    background: var(--danger);
    color: white;
}

.severity-high .summary-icon {
    background: var(--warning);
    color: white;
}

.severity-medium .summary-icon {
    background: var(--info);
    color: white;
}

.severity-low .summary-icon {
    background: var(--success);
    color: white;
}

.summary-content h4 {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.summary-count {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.severity-critical .summary-count {
    color: var(--danger);
}

.severity-high .summary-count {
    color: var(--warning);
}

.severity-medium .summary-count {
    color: var(--info);
}

.severity-low .summary-count {
    color: var(--success);
}

/* 选项卡 */
.results-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

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

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

.tab-pane {
    display: none;
}

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

/* 问题列表 */
.issues-list {
    max-height: 500px;
    overflow-y: auto;
}

.issue-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.issue-item:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow);
}

.issue-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.severity-badge {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-critical .severity-badge {
    background: var(--danger);
    color: white;
}

.severity-high .severity-badge {
    background: var(--warning);
    color: white;
}

.severity-medium .severity-badge {
    background: var(--info);
    color: white;
}

.severity-low .severity-badge {
    background: var(--success);
    color: white;
}

.issue-title {
    font-weight: 600;
    color: var(--dark);
    flex: 1;
}

.issue-location {
    font-size: 0.875rem;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.issue-description {
    color: var(--gray-700);
    margin-bottom: 12px;
    line-height: 1.6;
}

.issue-code {
    background: var(--gray-900);
    color: var(--gray-100);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-family: 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 12px 0;
    overflow-x: auto;
}

.issue-solution {
    background: var(--success-light);
    border: 1px solid var(--success);
    color: var(--success-dark);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-top: 12px;
    font-size: 0.875rem;
}

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

.code-viewer pre {
    margin: 0;
    padding: 20px;
    overflow-x: auto;
}

.code-viewer code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #abb2bf;
}

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

.metric-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.metric-label {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.metric-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

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

/* 系统信息 */
.system-info {
    padding: 20px;
}

.info-item {
    display: flex;
    margin-bottom: 12px;
}

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

.info-label {
    font-weight: 500;
    color: var(--gray-700);
    min-width: 100px;
}

.info-value {
    color: var(--gray-600);
    flex: 1;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.status-dot.online {
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* 页脚 */
footer {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

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

.footer-links {
    display: flex;
    gap: 24px;
}

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

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

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    color: var(--dark);
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.sample-list {
    display: grid;
    gap: 16px;
}

.sample-item {
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

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

.sample-item h4 {
    color: var(--dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

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

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

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .main-content {
        gap: 16px;
    }

    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .footer-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }
}

/* 高亮覆盖 */
.hljs {
    background: transparent !important;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}