/* 全局重置与变量声明 */
:root {
    --bg-main: #0a0b10;
    --bg-gradient: radial-gradient(circle at 50% 50%, #151624 0%, #0a0b10 100%);
    --card-bg: rgba(20, 21, 33, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-focus: rgba(138, 43, 226, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --color-primary: #8a2be2;
    --color-primary-glow: rgba(138, 43, 226, 0.3);
    --color-success: #10b981;
    --color-success-glow: rgba(16, 185, 129, 0.2);
    --color-warning: #f59e0b;
    --color-warning-glow: rgba(245, 158, 11, 0.2);
    --color-danger: #ef4444;
    --color-danger-glow: rgba(239, 68, 68, 0.2);
    --color-info: #00d2ff;
    --color-info-glow: rgba(0, 210, 255, 0.2);
    --color-purple: #8b5cf6;
    --color-purple-glow: rgba(139, 92, 246, 0.2);

    --font-sans: 'Outfit', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    background: var(--bg-main);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    padding: 24px;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

/* 布局容器 */
.app-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 顶部标题栏 */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 8px var(--color-primary-glow));
}

.app-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 30%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* 仪表盘统计卡片 */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.total::before { background: var(--color-info); }
.stat-card.total { box-shadow: 0 4px 20px rgba(0, 210, 255, 0.05); }

.stat-card.valid::before { background: var(--color-success); }
.stat-card.valid { box-shadow: 0 4px 20px rgba(16, 185, 129, 0.05); }

.stat-card.exhausted::before { background: var(--color-warning); }
.stat-card.exhausted { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.05); }

.stat-card.invalid::before { background: var(--color-danger); }
.stat-card.invalid { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.05); }

.stat-card.pending::before { background: var(--text-muted); }
.stat-card.pending { box-shadow: 0 4px 20px rgba(255, 255, 255, 0.02); }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 主内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    align-items: start;
}

/* 磨砂玻璃通用卡片 */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.glass-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 10px;
}

/* 配置表单组 */
.config-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.config-row {
    display: flex;
    gap: 12px;
}

.config-group.half {
    width: 50%;
}

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
select,
textarea {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--color-purple);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.input-tip {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* 文件拖拽导入区 */
.file-drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.01);
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
    border-color: var(--color-info);
    background: rgba(0, 210, 255, 0.04);
}

.upload-icon {
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
}

.file-drop-zone p {
    font-size: 12px;
    color: var(--text-secondary);
}

.file-drop-zone p span {
    color: var(--color-info);
    text-decoration: underline;
    font-weight: 500;
}

/* 按钮通用样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-icon {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, #4a00e0 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.45);
}

.btn-primary:disabled {
    background: #2a2b3d;
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-danger);
    color: white;
    box-shadow: 0 4px 12px var(--color-danger-glow);
}

.btn-danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    box-shadow: 0 4px 12px var(--color-success-glow);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.btn-full {
    width: 100%;
}

/* 控制台顶部及按钮排布 */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.panel-header h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.actions-group {
    display: flex;
    gap: 8px;
}

/* 过滤与搜索栏 */
.filter-export-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}

.search-filter {
    display: flex;
    gap: 10px;
    flex-grow: 1;
}

.search-filter input {
    flex-grow: 1;
}

/* 导出下拉菜单 */
.export-dropdown-wrapper {
    position: relative;
}

.export-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #181926;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 6px;
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.export-dropdown-wrapper.active .export-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.export-item {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.export-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-info);
}

/* 结果表格 */
.table-container {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    max-height: 520px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th, td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

th {
    background: #141523;
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 14px;
}

/* Key 遮罩显示 */
.masked-key {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-primary);
}

/* 状态标签及微动画 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* 状态：未测试 */
.status-badge.pending {
    background: rgba(107, 114, 128, 0.12);
    color: var(--text-secondary);
}
.status-badge.pending .badge-dot {
    background: var(--text-muted);
}

/* 状态：测试中 */
.status-badge.testing {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}
.status-badge.testing .badge-dot {
    background: #3b82f6;
    animation: breathing 1.2s infinite ease-in-out;
}

/* 状态：有效 */
.status-badge.valid {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}
.status-badge.valid .badge-dot {
    background: var(--color-success);
    box-shadow: 0 0 6px var(--color-success);
}

/* 状态：额度耗尽 */
.status-badge.exhausted {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}
.status-badge.exhausted .badge-dot {
    background: var(--color-warning);
    box-shadow: 0 0 6px var(--color-warning);
    animation: breathing 2s infinite ease-in-out;
}

/* 状态：无效 */
.status-badge.invalid {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}
.status-badge.invalid .badge-dot {
    background: var(--color-danger);
}

/* 状态：服务受限/IP不支持 */
.status-badge.blocked {
    background: rgba(139, 92, 246, 0.12);
    color: #c084fc;
}
.status-badge.blocked .badge-dot {
    background: var(--color-purple);
}

/* 状态：网络错误 */
.status-badge.error {
    background: rgba(75, 85, 99, 0.15);
    color: #9ca3af;
}
.status-badge.error .badge-dot {
    background: #6b7280;
}

/* 延迟标记 */
.delay-badge {
    font-weight: 600;
}
.delay-badge.low { color: #34d399; }
.delay-badge.medium { color: #fbbf24; }
.delay-badge.high { color: #f87171; }

/* 单元格操作按钮 */
.row-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.row-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
}

/* 提示通知 (Toast) */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: #181926;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 13px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    max-width: 350px;
}

.toast.show {
    transform: translateX(0);
}

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-danger); }
.toast.info { border-left: 3px solid var(--color-info); }

/* 关键帧动画 */
@keyframes breathing {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.4); opacity: 1; }
    100% { transform: scale(1); opacity: 0.5; }
}

/* 响应式调整 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}
