/**
 * dashboard.css
 * Webhook 监控中心 - 基础样式
 * 包含：CSS变量/重置、布局、导航栏、按钮、统计卡片、Tab导航、表单元素
 */

/* ==================== CSS Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ==================== 顶部导航栏 ==================== */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #e2e8f0;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.navbar-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: #0366d6;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f6f8fa;
    border-radius: 6px;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== 按钮样式 ==================== */
.btn {
    padding: 0.5rem 1rem;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #334155;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-primary {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* ==================== 主容器 ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.main-content {
    /* 主内容区域样式 */
}

/* ==================== 统计卡片区域 ==================== */
.stats-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #586069;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

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

.stat-card {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.stat-label {
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.025em;
}

.stat-trend {
    font-size: 0.75rem;
    color: #28a745;
    margin-top: 0.5rem;
}

/* ==================== 筛选栏 ==================== */
.filter-section {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #24292e;
}

.filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fafbfc;
    transition: all 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: #0366d6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

/* ==================== Tab 导航 ==================== */
.tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid #e1e4e8;
    margin-bottom: 1rem;
    padding-top: 1rem;
}

.tab {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: #586069;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: #24292e;
}

.tab.active {
    color: #0366d6;
    border-bottom-color: #0366d6;
}

.tab-content {
    display: none;
    padding: 1rem 0;
}

.tab-content.active {
    display: block;
}

/* ==================== 表单元素 ==================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #24292e;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    font-size: 0.875rem;
}

.form-input:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-checkbox input {
    width: auto;
}

/* ==================== 信息网格 ==================== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: #586069;
    font-weight: 500;
}

.info-value {
    font-size: 0.875rem;
    color: #24292e;
    font-family: 'SF Mono', Monaco, monospace;
}

/* ==================== 导航 Tab 样式 ==================== */
.nav-tabs {
    display: flex;
    gap: 4px;
    margin-left: 20px;
    align-items: center;
    flex: 1;
}

.nav-tab {
    padding: 0 1rem;
    height: 64px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-tab:hover {
    color: #0f172a;
    background: rgba(0,0,0,0.02);
}
.nav-tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
}

.nav-tab:hover {
    background-color: #f6f8fa;
    color: #24292e;
}

.nav-tab.active {
    background-color: rgba(3, 102, 214, 0.1);
    color: #0366d6;
}

/* ==================== Tab 内容样式 ==================== */
.tab-content {
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== 功能面板容器样式 ==================== */
.ai-cost-section,
.predictions-section,
.remediation-section,
.topology-section {
    padding: 20px 0;
}

.predictions-container,
.patterns-container,
.runbooks-container,
.remediation-history-container,
.topology-graph-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e1e4e8;
}

.container-header {
    margin-bottom: 15px;
}

.container-header h3,
.predictions-header h3,
.patterns-header h3 {
    margin: 0;
    font-size: 16px;
    color: #24292e;
}

.ai-period-selector {
    display: flex;
    gap: 8px;
}

.predictions-actions,
.topology-actions {
    display: flex;
    gap: 8px;
}

/* ==================== Mobile Responsiveness (Smartphones & Tablets) ==================== */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    /* Navbar tweaks */
    .navbar {
        padding: 0 1rem;
    }
    .navbar-content {
        flex-direction: column;
        height: auto;
        padding: 1rem 0;
        gap: 1rem;
        align-items: stretch;
    }

    /* Make tabs scrollable horizontally */
    .nav-tabs {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        gap: 1rem;
    }
    .nav-tabs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    .nav-tab {
        white-space: nowrap;
        height: 40px;
        padding: 0 0.5rem;
        font-size: 0.85rem;
    }

    /* Nav actions stack */
    .nav-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .nav-status {
        display: none; /* Hide 'Service Running' to save space */
    }
    .nav-actions .btn {
        flex: 1; /* Stretch buttons evenly */
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Stats Grid & Filters */
    .stats-grid {
        grid-template-columns: 1fr; /* Stack vertically on phones */
        gap: 1rem;
    }
    .filter-section {
        padding: 1rem;
    }
    .filter-grid {
        grid-template-columns: 1fr;
    }

    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    .section-header > div, .section-header > button {
        width: 100%;
        flex-wrap: wrap;
    }
    .section-header select {
        flex: 1; /* Stretch dropdowns */
    }

    /* AI Cost Period Selector */
    .ai-period-selector {
        display: flex;
        width: 100%;
    }
    .ai-period-selector .btn {
        flex: 1;
    }
}
