/**
 * 网络诊断系统样式
 * 现代化、响应式设计
 */

/* === CSS变量 === */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    
    --sidebar-bg: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    --sidebar-border: #e2e8f0;
    --sidebar-text: #334155;
    --sidebar-text-muted: #64748b;
    --sidebar-hover: #e2e8f0;
    --sidebar-active-bg: #e0e7ff;
    --sidebar-active-text: #4f46e5;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition: all 0.2s ease;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
}

/* === 深色主题 === */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    
    --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-border: #334155;
    --sidebar-text: #f1f5f9;
    --sidebar-text-muted: #94a3b8;
    --sidebar-hover: #334155;
    --sidebar-active-bg: rgba(99, 102, 241, 0.2);
    --sidebar-active-text: #a5b4fc;
}

[data-theme="dark"] .login-card {
    background: var(--card-bg);
}

[data-theme="dark"] .form-container {
    background: var(--card-bg);
}

/* === 基础样式 === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* === 容器 === */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* === 加载状态 === */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner.small {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* === 错误状态 === */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    gap: 16px;
}

.error-icon {
    font-size: 64px;
}

.error-message {
    color: var(--error-color);
    padding: 12px;
    text-align: center;
}

/* === 头部 === */
.header {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    padding: 24px;
    border-radius: var(--radius-xl);
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-content {
    flex: 1;
    min-width: 200px;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.task-desc {
    opacity: 0.9;
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-white {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    border: none;
}

.btn-white:hover {
    background: white;
}

/* === 头部内的诊断状态 === */
.diag-status-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

.diag-status-inline .loading-spinner {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

/* === 区块 === */
.section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--text-primary);
}

.targets-summary {
    font-size: 13px;
    color: var(--text-muted);
}

/* === 检测目标列表 === */
.targets-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.target-item {
    background: var(--bg-color);
    border-radius: var(--radius);
    padding: 16px;
    transition: var(--transition);
}

.target-item.testing {
    background: #eff6ff;
    border: 1px solid var(--info-color);
    animation: pulse 1.5s ease-in-out infinite;
}

.target-item.success {
    background: #f0fdf4;
    border: 1px solid var(--success-color);
}

.target-item.error {
    background: #fef2f2;
    border: 1px solid var(--error-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.target-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.target-method {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.method-get { background: #dbeafe; color: #1d4ed8; }
.method-post { background: #dcfce7; color: #15803d; }
.method-put { background: #fef3c7; color: #b45309; }
.method-delete { background: #fee2e2; color: #b91c1c; }
.method-patch { background: #f3e8ff; color: #7c3aed; }
.method-wss { background: #fce7f3; color: #be185d; }
.method-ws { background: #fce7f3; color: #be185d; }

.target-name {
    font-weight: 500;
    color: var(--text-primary);
}

.target-url {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
    color: var(--text-muted);
    word-break: break-all;
}

.target-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.target-status.pending { background: var(--bg-color); color: var(--text-muted); }
.target-status.testing { background: #dbeafe; color: var(--info-color); }
.target-status.success { background: #dcfce7; color: var(--success-color); }
.target-status.slow { background: #fef3c7; color: var(--warning-color); }
.target-status.warning { background: #fef3c7; color: var(--warning-color); }
.target-status.error { background: #fee2e2; color: var(--error-color); }

/* === HTTP状态码 === */
.target-code {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: monospace;
}

.target-code:empty {
    display: none;
}

.target-code.code-success { background: #dcfce7; color: var(--success-color); }
.target-code.code-redirect { background: #dbeafe; color: var(--info-color); }
.target-code.code-client-error { background: #fef3c7; color: var(--warning-color); }
.target-code.code-server-error { background: #fee2e2; color: var(--error-color); }
.target-code.code-opaque { background: #f3e8ff; color: #7c3aed; }
.target-code.code-unknown { background: var(--bg-color); color: var(--text-muted); }

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-color);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.btn-danger:hover:not(:disabled) {
    background: #fef2f2;
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    font-size: 20px;
}

/* === 操作区域 === */
.action-section {
    text-align: center;
    padding: 20px 0;
}

/* === 诊断状态区域 === */
.diag-status-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.diag-progress {
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#diag-status-text {
    font-weight: 500;
    color: var(--text-primary);
}

#diag-progress-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* === 结果摘要 === */
.summary-card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.summary-card.healthy { border-left: 4px solid var(--success-color); }
.summary-card.slow { border-left: 4px solid var(--warning-color); }
.summary-card.warning { border-left: 4px solid var(--warning-color); }
.summary-card.critical { border-left: 4px solid var(--error-color); }

.summary-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.summary-icon {
    font-size: 32px;
}

.summary-title {
    font-size: 20px;
    font-weight: 600;
}

.summary-stats {
    display: flex;
    gap: 32px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* === 网络信息 === */
.network-info {
    background: var(--bg-color);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.network-info h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.network-details {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.network-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.network-item .label {
    font-size: 12px;
    color: var(--text-muted);
}

.network-item .value {
    font-weight: 600;
}

.network-item .value.online { color: var(--success-color); }
.network-item .value.offline { color: var(--error-color); }

/* === 结果详情 === */
.results-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.result-item {
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.result-item.success { border-left: 3px solid var(--success-color); }
.result-item.slow { border-left: 3px solid var(--warning-color); }
.result-item.warning { border-left: 3px solid var(--warning-color); }
.result-item.error { border-left: 3px solid var(--error-color); }

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.result-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.result-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.result-method {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.result-name {
    font-weight: 500;
    color: var(--text-primary);
}

.result-url {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success, .status-badge.code-success { background: #dcfce7; color: var(--success-color); }
.status-badge.error, .status-badge.code-server-error { background: #fee2e2; color: var(--error-color); }
.status-badge.code-redirect { background: #dbeafe; color: var(--info-color); }
.status-badge.code-client-error { background: #fef3c7; color: var(--warning-color); }
.status-badge.code-opaque { background: #f3e8ff; color: #7c3aed; }

.cors-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    background: #fef3c7;
    color: #b45309;
    text-transform: lowercase;
}

.result-time {
    font-weight: 600;
    color: var(--text-primary);
}

.expand-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: var(--transition);
}

.result-detail {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--border-color);
}

/* === 详情网格 === */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* === 时间条 === */
.timing-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--border-color);
    margin-bottom: 8px;
}

.timing-segment {
    height: 100%;
    transition: var(--transition);
}

.timing-segment.dns { background: #60a5fa; }
.timing-segment.connect { background: #34d399; }
.timing-segment.ttfb { background: #fbbf24; }
.timing-segment.download { background: #a78bfa; }

.timing-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-color.dns { background: #60a5fa; }
.legend-color.connect { background: #34d399; }
.legend-color.ttfb { background: #fbbf24; }
.legend-color.download { background: #a78bfa; }

/* === 错误详情 === */
.error-detail {
    padding: 16px;
    background: #fef2f2;
    border-radius: var(--radius);
}

.error-type {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.error-icon {
    font-size: 20px;
}

.error-name {
    font-weight: 600;
    color: var(--error-color);
}

.error-message {
    color: var(--text-primary);
    margin-bottom: 12px;
}

.error-suggestion {
    background: white;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.error-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* === 页脚 === */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 14px;
}

/* === 通知 === */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success { background: var(--success-color); color: white; }
.notification.error { background: var(--error-color); color: white; }
.notification.info { background: var(--info-color); color: white; }

.notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* === Spinner === */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===============================
   管理后台样式
   =============================== */

.admin-body {
    background: var(--bg-color);
}

/* === 登录页面 === */
.login-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
}

/* === 表单 === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: monospace;
}

/* 输入框带操作按钮 */
.input-with-action {
    display: flex;
    gap: 8px;
}

.input-with-action input {
    flex: 1;
}

.input-with-action .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-error {
    color: var(--error-color);
    font-size: 14px;
    margin-bottom: 16px;
    min-height: 20px;
}

.form-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.required {
    color: var(--error-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* === 管理面板布局 === */
.dashboard-section {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .btn-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .theme-text,
.sidebar.collapsed .logout-text,
.sidebar.collapsed .collapse-text {
    display: none;
}

.sidebar.collapsed .sidebar-header h2 {
    justify-content: center;
}

.sidebar-action {
    padding: 12px;
}

.sidebar-action .btn {
    width: 100%;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-action .btn {
    padding: 12px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-action .btn .btn-icon {
    font-size: 18px;
}

.sidebar-action .btn:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--sidebar-text-muted);
    margin-bottom: 4px;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
    cursor: pointer;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 11px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.nav-icon {
    font-size: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-text {
    font-weight: 500;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 主题切换按钮 */
.theme-toggle {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--sidebar-text-muted);
    transition: all 0.15s;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.sidebar.collapsed .theme-toggle {
    justify-content: center;
    padding: 10px;
}

.theme-icon {
    font-size: 16px;
}

.sidebar-footer .btn {
    width: 100%;
    justify-content: center;
    font-size: 13px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--sidebar-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar.collapsed .sidebar-footer .btn {
    padding: 10px;
}

.logout-icon {
    font-size: 14px;
}

.sidebar-footer .btn:hover {
    background: var(--sidebar-hover);
    border-color: var(--border-color);
    color: var(--sidebar-text);
}

/* 侧边栏收起/展开按钮 */
.sidebar-collapse-btn {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: var(--sidebar-text-muted);
    transition: all 0.15s;
}

.sidebar-collapse-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.collapse-icon {
    font-size: 14px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-collapse-btn {
    padding: 10px;
}

.sidebar.collapsed .collapse-icon {
    transform: rotate(180deg);
}

/* === 主内容区 === */
.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
}

.page-actions {
    display: flex;
    gap: 8px;
}

.form-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 700px;
    box-shadow: var(--shadow);
}

/* === 任务网格 === */
.tasks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.task-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.task-name {
    font-size: 18px;
    font-weight: 600;
}

.task-count {
    background: var(--bg-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.task-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.task-urls {
    margin-bottom: 16px;
}

.task-url {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.task-url:last-child {
    border-bottom: none;
}

.task-url .method {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.task-url .url {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-secondary);
}

.more-urls {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 0;
}

.task-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === 结果网格 === */
.results-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.result-card.healthy { border-left: 4px solid var(--success-color); }
.result-card.slow { border-left: 4px solid var(--warning-color); }
.result-card.warning { border-left: 4px solid var(--warning-color); }
.result-card.critical { border-left: 4px solid var(--error-color); }

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.result-client {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.client-ip {
    font-weight: 600;
    font-family: monospace;
}

.result-time {
    font-size: 13px;
    color: var(--text-muted);
}

.result-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.result-badge.healthy { background: #dcfce7; color: var(--success-color); }
.result-badge.slow { background: #fef3c7; color: var(--warning-color); }
.result-badge.warning { background: #fef3c7; color: var(--warning-color); }
.result-badge.critical { background: #fee2e2; color: var(--error-color); }

.result-summary {
    display: flex;
    gap: 32px;
    margin-bottom: 12px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-item .label {
    font-size: 12px;
    color: var(--text-muted);
}

.summary-item .value {
    font-size: 18px;
    font-weight: 600;
}

.summary-item .value.success { color: var(--success-color); }
.summary-item .value.error { color: var(--error-color); }

.result-network {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.network-tag {
    background: var(--bg-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.result-details {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.result-details summary {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 14px;
    padding: 8px 0;
}

.details-content {
    padding-top: 12px;
}

.detail-item {
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.detail-item.success { background: #f0fdf4; border: 1px solid #bbf7d0; }
.detail-item.error { background: #fef2f2; border: 1px solid #fecaca; }

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.detail-url {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-url .target-name {
    font-weight: 500;
    color: var(--text-primary);
}

.detail-result {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-result .time {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-result .error-type {
    color: var(--error-color);
    font-weight: 500;
}

/* 详细信息行 */
.detail-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

.detail-info-row .info-label {
    color: var(--text-muted);
    min-width: 70px;
}

.detail-info-row .info-value {
    color: var(--text-secondary);
}

.detail-info-row .info-time {
    color: var(--text-muted);
    font-size: 12px;
}

.detail-info-row .info-extra {
    color: var(--text-muted);
    font-size: 12px;
}

.detail-info-row.ssl-row .ssl-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.detail-info-row.ssl-row .ssl-badge.valid {
    background: #dcfce7;
    color: var(--success-color);
}

.detail-info-row.ssl-row .ssl-badge.invalid {
    background: #fee2e2;
    color: var(--error-color);
}

.detail-info-row .ssl-days {
    color: var(--text-muted);
    font-size: 12px;
}

.detail-info-row .ssl-issuer {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 8px;
}

/* 性能指标行 */
.detail-timing {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 8px;
}

.timing-item {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 4px;
}

/* 详细结果中的请求地址 */
.detail-target-url {
    padding: 4px 0;
    margin-bottom: 4px;
}

.detail-target-url .url-text {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    background: var(--bg-color);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* 错误详情 */
.detail-error {
    margin-top: 8px;
    padding: 8px;
    background: #fef2f2;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.detail-error .error-message {
    color: var(--error-color);
    display: block;
}

.detail-error .error-suggestion {
    color: var(--text-muted);
    font-size: 12px;
    display: block;
    margin-top: 4px;
}

.result-ua {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* === 空状态 === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state p {
    margin-bottom: 24px;
}

/* === 目标模式切换 === */
.target-mode-tabs {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.mode-tab {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.mode-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.mode-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* === 预设目标 === */
.preset-groups {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.preset-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.preset-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.preset-group-name {
    font-weight: 600;
}

.preset-count {
    font-size: 12px;
    color: var(--text-muted);
}

.preset-targets {
    padding: 8px;
}

.preset-target-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.preset-target-item:hover {
    background: var(--bg-color);
}

.preset-target-item .target-name {
    font-weight: 500;
    min-width: 80px;
}

.preset-target-item .target-url {
    color: var(--text-muted);
    font-size: 13px;
    font-family: monospace;
}

/* === 已选目标 === */
.selected-targets {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

.empty-targets {
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
}

.selected-target-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.selected-target-item:last-child {
    margin-bottom: 0;
}

.selected-target-item .target-name {
    font-weight: 500;
}

.selected-target-item .target-url {
    flex: 1;
    color: var(--text-muted);
    font-size: 12px;
    font-family: monospace;
}

.remove-target {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--error-color);
    color: white;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: var(--transition);
}

.remove-target:hover {
    background: #dc2626;
}

/* === 客户端信息卡片 === */
.client-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

.client-info-card h3 {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 12px;
}

.client-details {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.client-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.client-item .label {
    font-size: 12px;
    opacity: 0.8;
}

.client-item .value {
    font-weight: 600;
}

/* === 客户端位置 (管理后台) === */
.client-location {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.client-location .isp {
    color: var(--text-muted);
    font-size: 12px;
}

/* === 详细信息区块 === */
.info-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
}

.info-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
}

.info-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-all;
}

.info-value.warning {
    color: var(--warning-color);
}

/* === SSL区块 === */
.ssl-section {
    border-left: 3px solid var(--success-color);
}

.ssl-section.invalid {
    border-left-color: var(--error-color);
    background: #fef2f2;
}

.ssl-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

.ssl-badge.valid {
    background: #dcfce7;
    color: var(--success-color);
}

.ssl-badge.invalid {
    background: #fee2e2;
    color: var(--error-color);
}

.ssl-warnings {
    margin-top: 12px;
}

.ssl-warning {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
}

.ssl-warning.warning {
    background: #fef3c7;
    color: #b45309;
}

.ssl-warning.error {
    background: #fee2e2;
    color: var(--error-color);
}

.ssl-error {
    color: var(--error-color);
    font-size: 14px;
}

/* === 管理后台详细结果扩展 === */
.detail-dns,
.detail-location,
.detail-ssl {
    font-size: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

.detail-dns .dns-label,
.detail-location .location-label,
.detail-ssl .ssl-label {
    color: var(--text-muted);
    margin-right: 8px;
}

.detail-dns .dns-ips {
    font-family: monospace;
    color: var(--text-primary);
}

.detail-dns .dns-time {
    color: var(--text-muted);
    margin-left: 8px;
}

.detail-ssl.valid .ssl-valid {
    color: var(--success-color);
}

.detail-ssl.invalid .ssl-invalid {
    color: var(--error-color);
}

.detail-ssl .ssl-days {
    color: var(--text-muted);
}

.detail-ssl .ssl-issuer {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
}

/* === 时间条扩展 - SSL === */
.timing-segment.ssl {
    background: #f472b6;
}

.legend-color.ssl {
    background: #f472b6;
}

/* === 响应式 === */
@media (max-width: 768px) {
    .dashboard-section {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 8px 16px;
    }
    
    .nav-item {
        white-space: nowrap;
        margin-bottom: 0;
        margin-right: 4px;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .tasks-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-stats {
        flex-direction: column;
        gap: 16px;
    }
    
    .header {
        padding: 24px 16px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .page-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
}

/* === 二维码弹窗 === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.qrcode-modal-content {
    width: 320px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px 20px;
}

.qrcode-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.qrcode-container img {
    border-radius: 8px;
}

.qrcode-container canvas {
    border-radius: 8px;
}

.qrcode-link {
    display: flex;
    gap: 8px;
}

.qrcode-link input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-color);
}

.qrcode-link input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.qrcode-error {
    text-align: center;
    color: var(--error-color);
    padding: 40px 0;
}

/* 深色主题下的二维码样式调整 */
[data-theme="dark"] .qrcode-container {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
}
