/**
 * 自定义样式
 * - 开标临期高亮
 * - 统计卡片
 * - 通用UI增强
 */

/* ========== 开标临期高亮 ========== */
/* 列表行浅红色背景高亮 */
.near-expire-row {
    background-color: #fff5f5 !important;
}
.near-expire-row:hover {
    background-color: #ffe8e8 !important;
}

/* 开标日期字段标红加粗 */
.open-date-near {
    color: #dc3545 !important;
    font-weight: 700 !important;
}

/* ========== 过期标讯标灰 ========== */
.expired-row {
    background-color: #f5f5f5 !important;
    color: #999 !important;
    opacity: 0.75;
}
.expired-row:hover {
    background-color: #ececec !important;
}
.expired-row a {
    color: #888 !important;
}
.expired-row .text-muted {
    color: #aaa !important;
}
.expired-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #999;
    background-color: #e0e0e0;
    border-radius: 3px;
    margin-right: 4px;
    white-space: nowrap;
}

/* ========== 标讯类型标签 ========== */
.bid-type-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 3px;
    margin-right: 4px;
    white-space: nowrap;
}
.bid-type-normal { background-color: #e3f2fd; color: #1976d2; }
.bid-type-delayed { background-color: #fff3e0; color: #f57c00; }
.bid-type-failed { background-color: #ffebee; color: #d32f2f; }
.bid-type-won { background-color: #e8f5e9; color: #2e7d32; }

/* ========== 统计卡片 ========== */
.stat-card {
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}
.stat-card h3 {
    font-weight: 700;
    color: #333;
}

/* ========== 导航栏 ========== */
.navbar-brand {
    font-size: 1.1rem;
}
.nav-link {
    font-size: 0.9rem;
    padding: 0.5rem 0.8rem !important;
}
.nav-link.active {
    font-weight: 600;
}

/* ========== 标注选择器 ========== */
.annotate-sel {
    min-width: 80px;
    padding: 0.1rem 0.5rem;
    font-size: 0.78rem;
}

/* ========== 表格增强 ========== */
.table th {
    font-size: 0.85rem;
    white-space: nowrap;
}
.table td {
    font-size: 0.85rem;
    vertical-align: middle;
}
.table a {
    color: #0d6efd;
    text-decoration: none;
}
.table a:hover {
    text-decoration: underline;
}

/* ========== 标签徽章 ========== */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
}

/* ========== 模态框 ========== */
.modal-lg {
    max-width: 800px;
}

/* ========== 分页 ========== */
.pagination {
    font-size: 0.85rem;
}

/* ========== 全量爬取开关 ========== */
.form-check-label.small {
    font-size: 0.85rem;
    font-weight: 600;
}
#fullCrawlSwitch + .form-check-label {
    color: #dc3545;
}
#robotsTxtSwitch + .form-check-label {
    color: #0d6efd;
}

/* ========== 卡片头部 ========== */
.card-header {
    font-weight: 600;
    font-size: 0.9rem;
}

/* ========== 导航栏主标签（首页、标讯数据）更显眼 ========== */
.nav-main-tab {
    font-size: 1rem !important;
    font-weight: 700 !important;
    padding: 6px 16px !important;
    margin: 0 4px;
    border-radius: 6px !important;
    transition: background-color 0.2s, color 0.2s;
}
.nav-main-tab.active {
    background-color: rgba(255,255,255,0.2) !important;
    color: #fff !important;
}
.nav-main-tab:not(.active) {
    color: rgba(255,255,255,0.8) !important;
}
.nav-main-tab:not(.active):hover {
    background-color: rgba(255,255,255,0.12) !important;
    color: #fff !important;
}

/* 下拉菜单项点击切换tab后自动关闭 */
.dropdown-item.active {
    background-color: #0d6efd;
    color: #fff;
}

/* ========== 首页双栏布局 ========== */
.dashboard-row {
    align-items: stretch;
}
.dashboard-row .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.dashboard-row .card-body {
    flex: 1 1 auto;
    padding: 0 !important;
}
.dashboard-row .table {
    margin-bottom: 0;
}

/* 金额排行表 - 全宽竖排布局，自动列宽 */
#topBudgetTableWrap {
    table-layout: auto;
}

/* 金额排行 - 排名徽章 */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}
.rank-gold { background: linear-gradient(135deg, #FFD700, #FFA500); color: #fff; }
.rank-silver { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #fff; }
.rank-bronze { background: linear-gradient(135deg, #CD7F32, #A0522D); color: #fff; }
.rank-normal { background: #f0f0f0; color: #888; }

/* 金额标签 */
.budget-tag {
    display: inline-block;
    padding: 2px 8px;
    background-color: #e3f2fd;
    color: #1565c0;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

/* 金额排行 - 标题单元格完整显示 */
.title-cell {
    word-break: break-all;
    line-height: 1.4;
    min-width: 0;
}
.title-cell a {
    word-break: break-all;
}

/* 近7天开标 - 标题列允许换行，完整展示 */
.title-wrap {
    word-break: break-all;
    line-height: 1.4;
    min-width: 0;
}
.title-wrap a {
    word-break: break-all;
}

.dashboard-row .table td {
    padding-top: 6px;
    padding-bottom: 6px;
}

/* === 大屏（≥992px）：全宽竖排，自动列宽 === */
@media (min-width: 992px) {
    /* 金额排行表列宽 */
    #topBudgetTable th:nth-child(1),
    #topBudgetTable td:nth-child(1) { width: 42px; }
    #topBudgetTable th:nth-child(3),
    #topBudgetTable td:nth-child(3) { width: 120px; }
    #topBudgetTable th:nth-child(4),
    #topBudgetTable td:nth-child(4) { width: 100px; }

    /* 近7天开标表列宽 */
    #nearExpireTable th:nth-child(2),
    #nearExpireTable td:nth-child(2) { width: 100px; }
    #nearExpireTable th:nth-child(3),
    #nearExpireTable td:nth-child(3) { width: 60px; }
    #nearExpireTable th:nth-child(4),
    #nearExpireTable td:nth-child(4) { width: 100px; }
    #nearExpireTable th:nth-child(5),
    #nearExpireTable td:nth-child(5) { width: 100px; }
}

/* === 中小屏（<992px）：上下堆叠，自动列宽 === */
@media (max-width: 991px) {
    /* 金额排行：堆叠后空间充裕，取消截断，允许换行 */
    #topBudgetTableWrap {
        table-layout: auto;
    }
    .title-cell,
    .title-cell a {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        word-break: break-all;
        line-height: 1.4;
    }
    #topBudgetTable tbody tr {
        height: auto;
    }

    /* 近7天开标：堆叠后空间充裕，列宽自动分配 */
    #nearExpireTableWrap {
        table-layout: auto;
    }
}

/* === 手机端（≤576px）：进一步紧凑 === */
@media (max-width: 576px) {
    .dashboard-row .table {
        font-size: 0.78rem;
    }
    .rank-badge {
        width: 20px;
        height: 20px;
        font-size: 0.68rem;
    }
    .budget-tag {
        font-size: 0.72rem;
        padding: 1px 6px;
    }
}

/* ========== 响应式（通用） ========== */
@media (max-width: 768px) {
    .stat-card h3 {
        font-size: 1.2rem;
    }
    .table {
        font-size: 0.78rem;
    }
    .annotate-sel {
        min-width: 60px;
    }
}
