/* 小海豚 API 2.0 管理界面样式 */
:root {
    --primary: #2563eb;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

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

header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

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

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* 标签页导航 */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.tab {
    padding: 10px 20px;
    background: var(--surface);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s;
}

.tab:hover {
    background: var(--surface2);
    color: var(--text);
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* 面板 */
.panel {
    display: none;
}

.panel.active {
    display: block;
}

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

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-card.success { border-color: var(--success); }
.stat-card.warning { border-color: var(--warning); }
.stat-card.info { border-color: var(--primary); }

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 8px;
    /* 数字以外的内容（时间戳等）不允许撑破卡片 */
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 时间戳这类较长文本用小字号，避免溢出或被裁切 */
.stat-value.small {
    font-size: 1.15rem;
    line-height: 2.5rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* 上游更新状态：走本地回退时用黄色提示，避免被误认为故障 */
#update-info {
    word-break: break-word;
}
#update-info.update-warn {
    color: var(--warning);
}

/* 按钮 */
.actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1d4ed8; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #a16207; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* 过滤器 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select, .filter-bar input {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
}

.count {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: auto;
}

/* 表格 */
.table-container {
    overflow-x: auto;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover {
    background: var(--surface2);
}

.blocked-row {
    opacity: 0.6;
}

.key-cell {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-sp { background: #dc2626; color: white; }
.badge-spp { background: #7c3aed; color: white; }
.badge-ag { background: #059669; color: white; }
.badge-sn { background: #d97706; color: white; }
.badge-sf { background: #0891b2; color: white; }

/* 状态标签 */
.status-ok { color: var(--success); }
.status-no_balance { color: var(--warning); }
.status-rate_limit { color: #f59e0b; }
.status-invalid { color: var(--danger); }
.status-plan_expired { color: #f97316; }
.status-blocked { color: var(--danger); }
.status-timeout { color: #ef4444; }
.status-connerror { color: #ef4444; }

/* Provider 摘要 */
.provider-summary {
    background: var(--surface);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.provider-summary h3 {
    margin-bottom: 16px;
}

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

.provider-card {
    background: var(--surface2);
    padding: 16px;
    border-radius: 8px;
}

.provider-name {
    font-weight: bold;
    margin-bottom: 8px;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary));
    transition: width 0.3s;
}

.provider-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* 日志 */
.log-container {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 500px;
    overflow-y: auto;
}

.log-entry {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-family: monospace;
    font-size: 0.85rem;
    display: flex;
    gap: 16px;
    align-items: center;
}

.log-entry:hover {
    background: var(--surface2);
}

.log-time { color: var(--text-muted); }
.log-provider { 
    padding: 2px 8px;
    background: var(--primary);
    border-radius: 4px;
    font-size: 0.75rem;
}
.log-model { color: var(--text-muted); }
.log-status { font-weight: bold; }
.log-duration { color: var(--text-muted); }
.log-error { color: var(--danger); font-size: 0.8rem; }

/* 设置 */
.settings-group {
    background: var(--surface);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.settings-group h3 {
    margin-bottom: 16px;
    color: var(--text);
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.setting-item label {
    min-width: 200px;
    color: var(--text-muted);
}

.setting-item input {
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    width: 100px;
}

.code-block {
    background: var(--bg);
    padding: 16px;
    border-radius: 6px;
    font-family: monospace;
}

.code-block code {
    color: var(--primary);
}

.usage {
    background: var(--bg);
    padding: 16px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* 响应式 */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
