/* 网址安全检测平台 - 全局样式（首页+结果页+列表页） */
:root {
    --primary: #2563eb;
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #16a34a;
    --info: #0891b2;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ===== 头部 ===== */
.header {
    text-align: center;
    padding: 30px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
    position: relative;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* 语言切换 */
.lang-switch {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.lang-switch button,
.lang-switch a {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: inline-block;
    text-decoration: none;
}

.lang-switch button:hover,
.lang-switch button.active,
.lang-switch a:hover,
.lang-switch a.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    color: var(--text);
}

/* ===== 布局 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 结果页双栏布局 */
.container.result-page {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

@media (max-width: 900px) {
    .main-layout,
    .container.result-page {
        grid-template-columns: 1fr;
    }
    .lang-switch {
        position: static;
        justify-content: center;
        margin-bottom: 15px;
    }
}

/* ===== 扫描区（首页） ===== */
.scan-section {
    background: var(--card);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
}

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

.url-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.scan-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.scan-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
}

.scan-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.api-config {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

.api-config summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.api-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.api-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}

/* ===== 进度条 ===== */
.progress-container {
    display: none;
    margin: 20px 0;
}

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

/* 修复：改用 GPU 合成的 transform，消除未合成动画警告 */
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    border-radius: 4px;
    transform: scaleX(var(--progress, 0));
    transform-origin: left center;
    transition: transform 0.5s ease;
    will-change: transform;
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== 结果区 ===== */
.results-container {
    display: none;
}

.score-card {
    background: var(--card);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    text-align: center;
}

.score-circle {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    position: relative;
}

.score-circle svg {
    transform: rotate(-90deg);
}

.score-circle-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.score-circle-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
}

.score-label {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.score-desc {
    color: var(--text-muted);
}

/* 风险颜色 */
.risk-safe { color: var(--success); }
.risk-low { color: #22c55e; }
.risk-medium { color: var(--warning); }
.risk-high { color: #f97316; }
.risk-critical { color: var(--danger); }

.stroke-safe { stroke: var(--success); }
.stroke-low { stroke: #22c55e; }
.stroke-medium { stroke: var(--warning); }
.stroke-high { stroke: #f97316; }
.stroke-critical { stroke: var(--danger); }

/* ===== 卡片网格 ===== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .input-group { flex-direction: column; }
}

/* ===== 通用卡片 ===== */
.card {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.icon-blue { background: rgba(37, 99, 235, 0.2); }
.icon-green { background: rgba(22, 163, 74, 0.2); }
.icon-orange { background: rgba(245, 158, 11, 0.2); }
.icon-red { background: rgba(220, 38, 38, 0.2); }
.icon-purple { background: rgba(124, 58, 237, 0.2); }
.icon-cyan { background: rgba(8, 145, 178, 0.2); }

/* ===== 信息行 ===== */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

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

/* 修复：加深标签颜色，确保对比度 ≥ 4.5:1 */
.info-label {
    color: #cbd5e1;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.info-value {
    font-weight: 500;
    word-break: break-all;
    text-align: right;
}

/* ===== 徽章 ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* 修复：调亮徽章文字，确保在半透明背景上对比度足够 */
.badge-success { background: rgba(22, 163, 74, 0.2); color: #86efac; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fde68a; }
.badge-danger { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }
.badge-info { background: rgba(8, 145, 178, 0.2); color: #a5f3fc; }

/* ===== 漏洞 ===== */
.vuln-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vuln-item {
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
}

.vuln-high { background: rgba(220, 38, 38, 0.1); border-color: var(--danger); }
.vuln-medium { background: rgba(245, 158, 11, 0.1); border-color: var(--warning); }
.vuln-low { background: rgba(37, 99, 235, 0.1); border-color: var(--primary); }

.vuln-title {
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vuln-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.vuln-fix {
    font-size: 0.85rem;
    color: #93c5fd;
    background: rgba(37, 99, 235, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
}

/* ===== 警告/建议框 ===== */
.warning-box {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.warning-box h3 {
    color: #f87171;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.warning-list { list-style: none; }

.warning-list li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

.warning-list li::before {
    content: "⚠️";
    position: absolute;
    left: 0;
}

.rec-box {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.rec-box h3 {
    color: #93c5fd;
    margin-bottom: 12px;
}

.rec-list { list-style: none; }

.rec-list li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

.rec-list li::before {
    content: "💡";
    position: absolute;
    left: 0;
}

/* ===== 端口 ===== */
.port-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.port-item {
    background: var(--bg);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

.port-num {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.port-service {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== DNS ===== */
.dns-record {
    background: var(--bg);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

/* ===== 空状态/加载 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* ===== 历史记录（首页） ===== */
.history-section { margin-top: 30px; }

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.history-url { font-weight: 500; }

.history-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 修复：加深时间戳颜色 */
.history-time {
    color: #cbd5e1;
    font-size: 0.85rem;
}

/* ===== 导出按钮 ===== */
.export-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: flex-end;
}

.export-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.export-btn:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

/* ===== 动画 ===== */
.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 侧栏（结果页 sb-item） ===== */
.sidebar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
    overflow: visible;
}

.sidebar h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.sb-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.sb-item:hover {
    background: rgba(255,255,255,0.03);
}

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

/* ===== 侧栏（首页最近检测） ===== */
.recent-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.recent-item:hover {
    background: rgba(255,255,255,0.03);
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
    border-radius: 6px;
}

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

.recent-host {
    font-weight: 500;
    word-break: break-all;
    font-size: 0.9rem;
}

/* 修复：加深最近检测元信息颜色 */
.recent-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.8rem;
    color: #cbd5e1;
}

/* ===== 报告链接 ===== */
.report-link {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    margin: 20px 0;
    transition: all 0.3s;
}

.report-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
}

/* ===== 导航（首页 .nav-links） ===== */
.nav-links {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 16px;
    font-size: 1.05rem;
    font-weight: 600;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

/* 修复：加深 active 状态颜色，确保对比度 */
.nav-links a.active {
    color: #60a5fa;
    background: rgba(37, 99, 235, 0.12);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* ===== 导航（结果页/列表页 .nav） ===== */
.nav {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 16px;
    font-size: 1.05rem;
    font-weight: 600;
}

.nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav a:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.nav a.active {
    color: #60a5fa;
    background: rgba(37, 99, 235, 0.12);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page-btn, .page-num {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: 0.9rem;
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
}

.page-btn:hover, .page-num:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    color: var(--text);
}

.page-num.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
}

/* ===== 表格（列表页） ===== */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    text-align: left;
    padding: 12px 14px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    font-size: 0.9rem;
}

td {
    padding: 14px;
}

tr:hover {
    background: rgba(255,255,255,0.02);
}

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

/* ===== Footer ===== */
.main-footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ===== 手机端响应式优化 ===== */
@media (max-width: 768px) {
    .header { padding: 20px 15px; }
    .header h1 { font-size: 1.5rem; }
    .header p { font-size: 1rem; }
    
    .lang-switch {
        position: static;
        justify-content: center;
        margin-bottom: 12px;
    }
    
    .container { padding: 12px; }
    .container.result-page { grid-template-columns: 1fr; }
    .main-layout { grid-template-columns: 1fr; gap: 16px; }
    
    .input-group { flex-direction: column; }
    .scan-btn { width: 100%; }
    
    .grid-2 { grid-template-columns: 1fr; gap: 16px; }
    
    .score-circle { width: 120px; height: 120px; }
    .score-circle svg { width: 120px; height: 120px; }
    .score-value { font-size: 2rem; }
    
    .sidebar {
        position: static;
        margin-top: 20px;
        width: 100%;
    }
    
    .card { padding: 16px; }
    .info-row { flex-direction: column; gap: 4px; }
    .info-value { text-align: left; }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .history-meta { width: 100%; justify-content: space-between; }
    
    .vuln-title { flex-direction: column; align-items: flex-start; gap: 4px; }
    
    .api-inputs { grid-template-columns: 1fr; }
    
    .export-bar { justify-content: center; }
    
    .nav-links, .nav {
        font-size: 0.95rem;
        gap: 12px;
    }
    
    .list-container .card { padding: 12px; }
}