/* =========================================
   SecGuard - 安全检测工具
   ========================================= */

/* Base */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --gray-50: #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;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .9em;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary) !important;
    text-decoration: none !important;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--gray-600) !important;
    font-size: 14px;
    text-decoration: none !important;
    transition: all .15s;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900) !important; }
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary) !important;
    font-weight: 600;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.username {
    font-size: 14px;
    color: var(--gray-500);
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
}
.header-actions { display: flex; gap: 8px; }

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}
.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}
.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}
.table th {
    font-weight: 600;
    color: var(--gray-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.table tr:hover td { background: var(--gray-50); }
.table td code { font-size: 13px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-ip { background: var(--primary-light); color: var(--primary); }
.badge-domain { background: #f3e8ff; color: #7c3aed; }
.badge-pending { background: var(--gray-200); color: var(--gray-600); }
.badge-running { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }

/* Progress Bar */
.progress-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}
.progress-bar span {
    font-size: 12px;
    color: var(--gray-500);
    min-width: 32px;
}
.progress-fill {
    height: 6px;
    background: var(--primary);
    border-radius: 3px;
    transition: width .5s ease;
}
.progress-bar-lg .progress-fill { height: 10px; border-radius: 5px; }
.progress-bar-lg { width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: var(--font);
    transition: border-color .15s;
    outline: none;
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-input-lg { font-size: 18px !important; padding: 14px 18px !important; }
.form-help { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    transition: all .15s;
    text-decoration: none !important;
    white-space: nowrap;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-primary {
    background: var(--primary);
    color: white !important;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
    background: transparent;
    border-color: var(--gray-300);
    color: var(--gray-600) !important;
}
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.auth-container { width: 100%; max-width: 400px; padding: 20px; }
.auth-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}
.auth-header p { color: var(--gray-500); font-size: 14px; margin-top: 4px; }
.auth-form .form-group { margin-bottom: 18px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--gray-500); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-500);
}
.empty-state p { margin-bottom: 16px; font-size: 15px; }

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}
.page-link {
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    font-size: 14px;
    color: var(--gray-600) !important;
    text-decoration: none !important;
}
.page-link.active { background: var(--primary); color: white !important; border-color: var(--primary); }
.page-link:hover:not(.active) { background: var(--gray-50); }

/* Scan Form */
.scan-form { max-width: 600px; }
.checks-list {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 16px;
    margin: 20px 0;
}
.checks-list h4 { font-size: 14px; margin-bottom: 12px; color: var(--gray-600); }
.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 14px;
}
.check-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--gray-500);
    flex-shrink: 0;
}
.check-icon.active { background: var(--success); color: white; }
.check-name { flex: 1; }
.check-status { font-size: 12px; color: var(--gray-400); }
.check-status.running { color: var(--warning); }
.check-status.done { color: var(--success); }

/* Scan Progress */
.scan-progress { margin-top: 24px; }
.scan-progress h3 { margin-bottom: 16px; font-size: 18px; }
.checks-status { margin-top: 16px; }

/* Report Page */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px;
}
.report-meta { flex: 1; }
.meta-row { margin-bottom: 8px; display: flex; gap: 12px; }
.meta-label {
    font-size: 13px;
    color: var(--gray-500);
    min-width: 80px;
    flex-shrink: 0;
}
.meta-value { font-size: 14px; word-break: break-all; }
.report-score { text-align: center; margin-left: 32px; }
.score-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    margin: 0 auto 8px;
    border: 4px solid;
}
.score-safe { border-color: var(--success); color: var(--success); }
.score-attention { border-color: var(--warning); color: var(--warning); }
.score-risky { border-color: #ea580c; color: #ea580c; }
.score-danger { border-color: var(--danger); color: var(--danger); }
.score-label { font-size: 13px; color: var(--gray-500); }

/* AI Analysis */
.ai-summary {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.ai-severity {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}
.ai-critical { color: var(--danger); }
.ai-high { color: #ea580c; }
.ai-medium { color: var(--warning); }
.ai-low { color: var(--primary); }
.ai-info { color: var(--info); }
.ai-summary-text { font-size: 15px; line-height: 1.7; }

.findings-list { margin-bottom: 20px; }
.finding-item {
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    margin-bottom: 8px;
}
.finding-critical { border-left: 4px solid var(--danger); }
.finding-high { border-left: 4px solid #ea580c; }
.finding-medium { border-left: 4px solid var(--warning); }
.finding-low { border-left: 4px solid var(--primary); }
.finding-header { margin-bottom: 6px; font-size: 14px; }
.finding-detail { font-size: 13px; color: var(--gray-600); margin-bottom: 4px; }
.finding-risk { font-size: 12px; color: var(--gray-500); }

.recommendations {
    list-style: none;
    padding: 0;
}
.recommendations li {
    padding: 8px 0 8px 24px;
    position: relative;
    font-size: 14px;
}
.recommendations li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

/* Check Results */
.check-result {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.check-result-header {
    padding: 12px 16px;
    background: var(--gray-50);
    display: flex;
    align-items: center;
    gap: 10px;
}
.check-result-header h4 { font-size: 14px; flex: 1; }
.check-result-body { padding: 12px 16px; }
.check-result-body p { font-size: 14px; margin-bottom: 8px; }
.check-detail {
    background: var(--gray-50);
    padding: 12px;
    border-radius: var(--radius);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}
.raw-report {
    background: var(--gray-900);
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 500px;
    overflow-y: auto;
}

/* Severity badges */
.severity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.severity-critical { background: #fee2e2; color: #991b1b; }
.severity-high { background: #ffedd5; color: #9a3412; }
.severity-medium { background: #fef3c7; color: #92400e; }
.severity-low { background: #dbeafe; color: #1e40af; }
.severity-info { background: var(--gray-200); color: var(--gray-600); }

.check-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}
.check-completed { background: #dcfce7; color: #166534; }
.check-failed { background: #fee2e2; color: #991b1b; }
.check-running { background: #fef3c7; color: #92400e; }
.check-pending { background: var(--gray-200); color: var(--gray-500); }

/* Result actions */
.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 24px 0;
}

/* Utilities */
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }

/* Reports Table - Expandable */
.reports-table td { vertical-align: middle; }
.toggle-cell { text-align: center; padding: 0 4px !important; }
.toggle-btn {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--gray-500);
    transition: all .15s;
    line-height: 1;
}
.toggle-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
    border-color: var(--primary);
}
.toggle-btn.expanded svg {
    transform: rotate(90deg);
}
.toggle-btn svg {
    display: block;
    transition: transform .2s ease;
}
.report-detail-row td {
    padding: 0 !important;
    background: var(--gray-50);
}
.report-detail-body {
    padding: 20px 32px;
    border-top: 1px solid var(--gray-200);
    max-height: 600px;
    overflow-y: auto;
}
.detail-loading {
    text-align: center;
    color: var(--gray-400);
    padding: 20px;
    font-size: 14px;
}
.detail-error {
    text-align: center;
    color: var(--danger);
    padding: 20px;
}

/* Inline report summary */
.inline-summary { margin-bottom: 12px; }
.inline-summary:last-child { margin-bottom: 0; }
.inline-severity {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}
.inline-severity .sev-icon { font-size: 18px; }
.inline-severity .sev-text { font-size: 14px; }
.sev-critical { color: var(--danger); }
.sev-high { color: #ea580c; }
.sev-medium { color: var(--warning); }
.sev-low { color: var(--primary); }
.sev-info { color: var(--info); }

.inline-summary-text {
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.6;
    margin-bottom: 12px;
}

.inline-checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.inline-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    font-size: 13px;
}
.inline-check-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}
.inline-check-icon.ok { background: #dcfce7; color: #166534; }
.inline-check-icon.fail { background: #fee2e2; color: #991b1b; }
.inline-check-icon.warn { background: #fef3c7; color: #92400e; }
.inline-check-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-check-sev {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 10px;
}

.inline-findings { margin-bottom: 12px; }
.inline-finding {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
}
.inline-finding:last-child { border-bottom: none; }
.inline-finding .f-sev {
    font-weight: 700;
    min-width: 50px;
    flex-shrink: 0;
}
.inline-finding .f-text { color: var(--gray-700); }

.inline-recommendations {
    background: var(--primary-light);
    border-radius: 6px;
    padding: 12px 16px;
}
.inline-recommendations h5 {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 6px;
}
.inline-recommendations ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.inline-recommendations li {
    font-size: 13px;
    color: var(--gray-600);
    padding: 3px 0 3px 16px;
    position: relative;
}
.inline-recommendations li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
}

.inline-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

/* Rating pill in table */
.rating-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    min-width: 32px;
    text-align: center;
}
.rating-pill.loading { background: var(--gray-200); color: var(--gray-500); }
.rating-pill.safe { background: #dcfce7; color: #166534; }
.rating-pill.attention { background: #fef3c7; color: #92400e; }
.rating-pill.risky { background: #ffedd5; color: #9a3412; }
.rating-pill.danger { background: #fee2e2; color: #991b1b; }

/* Responsive */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .report-header { flex-direction: column; }
    .report-score { margin-left: 0; margin-top: 16px; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .header-inner { padding: 0 12px; gap: 8px; }
    .nav-link { padding: 6px 10px; font-size: 13px; }
}
