/* ========== 全局样式 ========== */
:root {
    --pf-primary: #2c8c5a;
    --pf-primary-dark: #1f6b43;
    --pf-bg: #eef1f6;
    --pf-card-border: #dce1e8;
    --pf-card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

body {
    background-color: var(--pf-bg);
    font-family: -apple-system, "Microsoft YaHei", "微软雅黑", sans-serif;
}

/* 访客模式：隐藏需要登录的操作按钮 */
body.guest-mode .req-login {
    display: none !important;
}

/* 主内容容器增强 */
.container-fluid {
    background: transparent;
}

/* ========== 导航栏 ========== */
.navbar-pf {
    background: linear-gradient(135deg, #2c8c5a 0%, #1f6b43 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.navbar-pf .navbar-brand {
    font-weight: 700;
    color: #fff !important;
    font-size: 1.25rem;
}
.navbar-pf .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-size: 0.92rem;
    padding: 0.5rem 0.8rem !important;
    border-radius: 6px;
    transition: all 0.2s;
}
.navbar-pf .nav-link:hover,
.navbar-pf .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.15);
}
.navbar-pf .nav-link i {
    margin-right: 4px;
}
.navbar-pf .brand-short { display: none; }

/* 登录后：顶部菜单直接展开显示，不收进汉堡按钮 */
.navbar-logged .navbar-toggler {
    display: none !important;
}
.navbar-logged .navbar-collapse {
    display: flex !important;
    flex-basis: 100%;
    flex-grow: 1;
    align-items: flex-start;
}
.navbar-logged .nav-menu-open {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px;
    width: 100%;
}
.navbar-logged .navbar-nav .nav-link {
    padding: 0.35rem 0.55rem !important;
    font-size: 0.82rem;
    white-space: nowrap;
}
.navbar-logged .navbar-nav .nav-link i {
    margin-right: 2px;
}
@media (max-width: 768px) {
    .navbar-logged .navbar-brand {
        font-size: 1rem;
        margin-right: 0.5rem;
    }
    .navbar-logged .brand-full { display: none; }
    .navbar-logged .brand-short { display: inline; }
    .navbar-logged .navbar-collapse {
        margin-top: 0.35rem;
    }
    .navbar-logged .nav-menu-open {
        gap: 1px;
    }
    .navbar-logged .navbar-nav .nav-link {
        padding: 0.3rem 0.45rem !important;
        font-size: 0.78rem;
    }
    .navbar-logged .navbar-nav .badge {
        font-size: 0.65rem;
    }
}

/* ========== 卡片 ========== */
.card {
    border: 1px solid var(--pf-card-border);
    box-shadow: var(--pf-card-shadow);
    border-radius: 10px;
    background: #fff;
}
.card-header {
    background: #f8f9fc;
    border-bottom: 2px solid #e4e8ef;
    font-weight: 600;
    border-radius: 10px 10px 0 0 !important;
    color: #3a4654;
}
.card-body {
    background: #fff;
}

/* ========== 统计卡片 ========== */
.stat-card {
    border: 1px solid var(--pf-card-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--pf-card-shadow);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.stat-card .stat-body {
    padding: 1.2rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 4px;
}
.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}
.stat-squab    { background: linear-gradient(135deg, #ffd43b, #fab005); }
.stat-juvenile { background: linear-gradient(135deg, #3bc9db, #0dcaf0); }
.stat-adult    { background: linear-gradient(135deg, #868e96, #495057); }
.stat-breeder  { background: linear-gradient(135deg, #ff6b6b, #e03131); }
.stat-info     { background: linear-gradient(135deg, #51cf66, #2c8c5a); }

/* ========== 鸽巢网格布局 ========== */
.nest-grid {
    display: grid;
    gap: 10px;
    padding: 10px;
    background: #f0f2f6;
    border-radius: 8px;
    border: 1px solid #dde2ea;
}
.nest-cell {
    background: #fff;
    border: 2px solid #d0d6e0;
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    position: relative;
    min-height: 80px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    box-sizing: border-box;
}
.nest-body {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.nest-cell:hover {
    border-color: var(--pf-primary);
    box-shadow: 0 2px 8px rgba(44,140,90,0.2);
    transform: translateY(-1px);
}
.nest-cell.occupied {
    background: #e8f5e9;
    border-color: #66bb6a;
}
.nest-cell.occupied::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
}
.nest-cell.empty {
    background: #fafbfc;
    border-color: #c5cad3;
    border-style: dashed;
}
.nest-cell.has-eggs {
    background: #fff8e1;
    border-color: #ffb74d;
    border-style: solid;
}
.nest-cell.has-eggs::after {
    content: '🥚';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 11px;
    opacity: 0.7;
}
.nest-cell.has-eggs-occupied {
    background: #fff0e5;
    border-color: #ff8a65;
    border-style: solid;
}
.nest-cell.has-eggs-occupied::after {
    content: '🐣';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 11px;
    opacity: 0.8;
}
.nest-cell-wrapper {
    position: relative;
    height: 100%;
    min-width: 0;
}
.nest-cell-empty {
    min-height: 80px;
    border: 2px dashed #f1f3f5;
    border-radius: 8px;
    background: transparent;
}
.nest-number {
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
}
.nest-info {
    font-size: 0.72rem;
    color: #6c757d;
    margin-top: 2px;
    max-width: 100%;
    word-break: break-word;
    white-space: normal;
    line-height: 1.3;
}
.nest-info.fw-bold {
    font-size: 0.70rem;
}
.nest-todo {
    font-weight: 700;
    margin-top: 3px;
}
.nest-todo-ring {
    color: #c0392b !important;
}
.nest-todo-leave {
    color: #b7791f !important;
}
.nest-young-label {
    color: #0d6efd !important;
    font-weight: 700;
    margin-top: 3px;
}

/* ========== 鸽子卡片 ========== */
.pigeon-card {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--pf-card-border);
    margin-bottom: 8px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.pigeon-card:hover {
    border-color: var(--pf-primary);
    background: #f0f7f4;
    box-shadow: 0 2px 6px rgba(44,140,90,0.15);
}
.pigeon-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 12px;
    flex-shrink: 0;
}

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

/* ========== 按钮 ========== */
.btn-pf {
    background: var(--pf-primary);
    border-color: var(--pf-primary);
    color: #fff;
}
.btn-pf:hover {
    background: var(--pf-primary-dark);
    border-color: var(--pf-primary-dark);
    color: #fff;
}

/* ========== 表格 ========== */
.table > :not(caption) > * > * {
    padding: 0.6rem 0.75rem;
}
.table {
    background: #fff;
}
.table thead th {
    background: #f0f2f6;
    border-bottom: 2px solid #dce1e8;
    color: #3a4654;
    font-weight: 600;
}
.table-hover tbody tr:hover {
    background-color: #f0f7f4;
}
.table-group-divider {
    border-top: 2px solid #dce1e8;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #adb5bd;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px dashed #dce1e8;
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

/* ========== 时间线 ========== */
.timeline {
    list-style: none;
    padding-left: 0;
}
.timeline-item {
    position: relative;
    padding-left: 24px;
    padding-bottom: 16px;
    border-left: 2px solid #dce1e8;
}
.timeline-item:last-child {
    border-left-color: transparent;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--pf-primary);
}

/* ========== 日历视图 ========== */
.calendar-day {
    min-height: 80px;
    border: 1px solid #dce1e8;
    padding: 4px;
    font-size: 0.8rem;
    background: #fff;
}
.calendar-day.has-plan {
    background: #e8f5e9;
    border-color: #66bb6a;
}
.calendar-day .day-number {
    font-weight: 600;
    color: #495057;
}
.calendar-day .day-plans {
    font-size: 0.7rem;
    color: #2c8c5a;
    margin-top: 2px;
}

/* ========== 表单增强 ========== */
.form-control:focus,
.form-select:focus {
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 0.2rem rgba(44,140,90,0.15);
}
.form-control,
.form-select {
    border-color: #cdd3dd;
}

/* ========== 小型统计卡（仪表盘顶部） ========== */
.card .card-body.py-2 {
    border-radius: 10px;
}

/* ========== 面包屑 ========== */
.breadcrumb {
    margin-bottom: 0;
    background: transparent;
    padding: 0;
}
.breadcrumb a {
    color: var(--pf-primary);
    text-decoration: none;
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    .navbar-pf .nav-link {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem !important;
    }
    .stat-card .stat-number {
        font-size: 1.5rem;
    }
    .stat-card .stat-icon {
        font-size: 1.8rem;
    }
    /* 手机端：固定每行4个，卡片可随内容拉高，并由脚本统一高度 */
    .nest-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 5px;
        padding: 6px;
        align-items: stretch;
    }
    .nest-cell-wrapper {
        height: auto;
        min-height: 100%;
    }
    .nest-cell {
        min-height: 88px;
        height: 100%;
        padding: 6px 3px;
        justify-content: flex-start;
        display: flex !important;
    }
    .nest-cell-empty {
        min-height: 88px;
        height: 100%;
    }
    .nest-number {
        font-size: 0.72rem;
        flex-shrink: 0;
        line-height: 1.2;
        margin-bottom: 2px;
    }
    .nest-info {
        font-size: 0.62rem;
        line-height: 1.35;
        margin-top: 1px;
        white-space: normal;
    }
    .table {
        font-size: 0.85rem;
    }
    .table > :not(caption) > * > * {
        padding: 0.4rem 0.5rem;
    }
    .finance-chart {
        height: 160px;
    }
    .chart-bar-wrap {
        width: 16px;
    }
    .chart-bar-label {
        font-size: 0.55rem;
    }
    .chart-month-label {
        font-size: 0.7rem;
    }
    .chart-month-profit {
        font-size: 0.6rem;
    }
}


/* ========== 仪表盘Tab ========== */
/* 强制隐藏未激活 Tab，避免 fade 只透明仍占位造成大片空白 */
.tab-content > .tab-pane {
    display: none;
}
.tab-content > .tab-pane.active.show {
    display: block;
}
.tab-pane.fade:not(.show) {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.nav-tabs .nav-link {
    color: #6c757d;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-tabs .nav-link:hover {
    color: var(--pf-primary);
    border-bottom-color: rgba(44,140,90,0.3);
}
.nav-tabs .nav-link.active {
    color: var(--pf-primary);
    background: transparent;
    border-bottom-color: var(--pf-primary);
    font-weight: 600;
}
.nav-tabs {
    border-bottom: 2px solid #dce1e8;
    margin-bottom: 1rem;
    background: #fff;
    border-radius: 10px 10px 0 0;
    border: 1px solid var(--pf-card-border);
    border-bottom: 2px solid #dce1e8;
    padding: 0 0.5rem;
}

/* ========== 模态框 ========== */
.modal-header {
    background: var(--pf-primary);
    color: #fff;
}
.modal-header .btn-close {
    filter: invert(1);
}
.modal-content {
    border: 1px solid var(--pf-card-border);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* ========== 列表组 ========== */
.list-group-item {
    border-color: #e4e8ef;
    background: #fff;
    transition: background 0.15s;
}
.list-group-item:hover {
    background: #f8f9fc;
}

/* ========== 提示框 ========== */
.alert {
    border-radius: 8px;
    border-width: 1px;
}

/* ========== 面包屑容器 ========== */
.breadcrumb-container {
    background: #fff;
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--pf-card-shadow);
}

/* ========== 分隔标题 ========== */
.section-title {
    color: #3a4654;
    font-weight: 600;
    font-size: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e4e8ef;
    margin-bottom: 0.75rem;
}

/* ========== 过滤器 ========== */
.filter-bar {
    background: #fff;
    border: 1px solid var(--pf-card-border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--pf-card-shadow);
}

/* ========== 财务图表 ========== */
.finance-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 220px;
    padding: 10px 0 0;
    border-bottom: 2px solid #dce1e8;
}
.chart-month {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
}
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    flex: 1;
    width: 100%;
    justify-content: center;
    padding-bottom: 2px;
}
.chart-bar-wrap {
    width: 24px;
    height: 100%;
    display: flex;
    align-items: flex-end;
}
.chart-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: height 0.4s ease;
    min-height: 2px;
    cursor: pointer;
}
.chart-bar:hover {
    opacity: 0.8;
}
.chart-bar-income {
    background: linear-gradient(180deg, #51cf66, #2c8c5a);
}
.chart-bar-expense {
    background: linear-gradient(180deg, #ff8787, #e03131);
}
.chart-bar-label {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    color: #495057;
    font-weight: 600;
}
.chart-month-label {
    font-size: 0.8rem;
    color: #495057;
    font-weight: 600;
    margin-top: 6px;
}
.chart-month-profit {
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 2px;
}

/* ========== 进度条增强 ========== */
.progress {
    border-radius: 4px;
    background: #e9ecef;
    overflow: hidden;
}
.progress-bar {
    transition: width 0.5s ease;
}

/* ========== 数据看板优化 ========== */
.dash-top-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.dash-stat {
    background: #fff;
    border: 1px solid var(--pf-card-border);
    border-radius: 8px;
    text-align: center;
    padding: 8px 4px;
    box-shadow: var(--pf-card-shadow);
}
.dash-stat .n {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    color: #212529;
}
.dash-stat .l {
    font-size: 0.68rem;
    color: #6c757d;
    margin-top: 2px;
}
.dash-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    overflow: visible;
    border-bottom: 2px solid #dce1e8;
}
.dash-tabs .nav-item {
    flex: 0 0 auto;
}
.dash-tabs .nav-link {
    white-space: nowrap;
    font-size: 0.82rem;
    padding: 0.45rem 0.55rem !important;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.dash-tabs .nav-link .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
}
.dash-tabs .dash-tab-text {
    margin-left: 0.15rem;
}
@media (max-width: 576px) {
    .dash-tabs .nav-link {
        font-size: 0.78rem;
        padding: 0.4rem 0.45rem !important;
    }
}
.dash-todo-panel {
    border: 1px solid #f0d78c !important;
    background: #fffdf5;
    box-shadow: var(--pf-card-shadow);
}
.dash-todo-head {
    background: #fff3cd;
    color: #664d03;
    font-weight: 600;
    padding: 0.55rem 0.85rem;
}
.dash-todo-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.dash-todo-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
}
.dash-todo-chip.chip-ring { background: #fde8e8; color: #c0392b; }
.dash-todo-chip.chip-leave { background: #fff3cd; color: #856404; }
.dash-todo-chip.chip-hatch { background: #cff4fc; color: #055160; }
.dash-todo-block + .dash-todo-block { margin-top: 10px; }
.dash-todo-title {
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 4px;
    padding: 0 2px;
}
.dash-todo-list .dash-todo-item {
    padding: 0.65rem 0.5rem;
    border-left: 3px solid transparent;
}
.dash-todo-list .item-ring { border-left-color: #dc3545; }
.dash-todo-list .item-leave { border-left-color: #ffc107; }
.dash-todo-list .item-hatch { border-left-color: #0dcaf0; }
.dash-room-card {
    border: 1px solid var(--pf-card-border);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-room-card:hover {
    border-color: var(--pf-primary);
}
.dash-room-todo {
    border-color: #f0ad4e;
    background: #fffdf8;
}
.dash-room-name {
    font-size: 0.9rem;
    line-height: 1.25;
    word-break: break-word;
}
.dash-room-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 6px;
}
.dash-room-metrics .num {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
}
.dash-room-metrics .lbl {
    display: block;
    font-size: 0.65rem;
    color: #6c757d;
}
.dash-room-todos {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
@media (min-width: 768px) {
    .dash-room-metrics {
        grid-template-columns: repeat(3, 1fr);
    }
    .dash-stat .n { font-size: 1.35rem; }
    .dash-stat .l { font-size: 0.75rem; }
}
@media (max-width: 768px) {
    .dash-top-stats { gap: 4px; }
    .dash-stat { padding: 6px 2px; border-radius: 6px; }
    .dash-stat .n { font-size: 1rem; }
    .dash-todo-item .btn { font-size: 0.75rem; padding: 0.15rem 0.45rem; }
}
