/* ============================================================
   stats.css - 学习统计页面专用样式
   对应文件: stats.html
   ============================================================ */

/* ---------- 头部 ---------- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.header h3 {
    margin: 0;
    color: var(--color-accent);
}
.btn-back {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: bold;
    height: auto;
}

/* ---------- 统计摘要 ---------- */
.stats-summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 12px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}
.stats-summary .item {
    flex: 1;
    text-align: center;
    min-width: 50px;
}
.stats-summary .item .num {
    font-size: 24px;
    font-weight: bold;
    color: var(--color-accent);
}
.stats-summary .item .label {
    font-size: 11px;
    color: var(--text-hint);
}

/* ---------- 过滤栏 ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    align-items: center;
}
.filter-bar select {
    background: var(--bg-input);
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    flex: 1;
    min-width: 100px;
}
.filter-bar .btn-group {
    display: flex;
    flex: 1;
    min-width: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid #555;
    background: var(--bg-card);
}
.filter-bar .btn-group .dim-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 0;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
    flex: 1;
    text-align: center;
    border-right: 1px solid #555;
    font-weight: bold;
}
.filter-bar .btn-group .dim-btn:last-child {
    border-right: none;
}
.filter-bar .btn-group .dim-btn.active {
    background: var(--color-accent);
    color: #000;
}

/* ---------- 图表容器 ---------- */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 20px;
    overflow-x: auto;
}
.chart-title {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}
.chart-title .sub {
    color: var(--text-muted);
    font-size: 12px;
}

/* ---------- 条形图 ---------- */
.bar-chart {
    display: flex;
    align-items: flex-end;
    height: 180px;
    gap: 4px;
    padding-bottom: 28px;
    position: relative;
    min-height: 180px;
}
.bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 8px;
    height: 100%;
    justify-content: flex-end;
}
.bar {
    width: 100%;
    min-width: 6px;
    max-width: 24px;
    background: var(--color-accent);
    border-radius: 3px 3px 0 0;
    transition: height 0.3s;
    position: relative;
    min-height: 2px;
}
.bar-label {
    font-size: 9px;
    color: var(--text-hint);
    margin-top: 4px;
    white-space: nowrap;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bar-value {
    font-size: 10px;
    color: var(--text-primary);
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
    background: rgba(0, 0, 0, 0.5);
    padding: 0 4px;
    border-radius: 3px;
    white-space: nowrap;
}
.empty-chart {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

/* ---------- 日历 ---------- */
.calendar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 20px;
}
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.calendar-header .month {
    color: var(--text-primary);
    font-size: 16px;
}
.calendar-nav {
    background: none;
    border: 1px solid #555;
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.calendar-grid .day-header {
    color: var(--text-hint);
    font-size: 11px;
    text-align: center;
    padding: 4px 0;
}
.calendar-grid .day-cell {
    background: var(--bg-input);
    border-radius: 4px;
    padding: 6px 2px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    min-height: 50px;
    position: relative;
}
.calendar-grid .day-cell:hover {
    background: #1a2a4a;
}
.calendar-grid .day-cell .day-num {
    color: var(--text-secondary);
    font-size: 13px;
}
.calendar-grid .day-cell .day-count {
    font-size: 10px;
    color: var(--color-accent);
    margin-top: 2px;
}
.calendar-grid .day-cell.has-data {
    border-bottom: 2px solid var(--color-accent);
}
.calendar-grid .day-cell.today {
    border: 1px solid var(--color-accent);
}

/* ---------- 日历弹窗 ---------- */
.calendar-grid .day-cell .day-detail-popup {
    display: none;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: 10px;
    z-index: 100;
    width: 200px;
    color: var(--text-primary);
    text-align: left;
    font-size: 12px;
    box-shadow: var(--shadow);
}
.calendar-grid .day-cell .day-detail-popup.popup-visible {
    display: block;
}
.day-detail-popup .lib-item {
    padding: 2px 0;
    border-bottom: 1px solid var(--border-color);
}
.day-detail-popup .lib-item:last-child {
    border-bottom: none;
}
.day-detail-popup .lib-name {
    color: var(--text-primary);
}
.day-detail-popup .lib-stats {
    color: var(--text-secondary);
}

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
    .filter-bar .btn-group .dim-btn {
        font-size: 12px;
        padding: 6px 0;
    }
    .stats-summary .item .num {
        font-size: 20px;
    }
    .stats-summary .item .label {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .filter-bar {
        flex-direction: column;
        gap: 6px;
    }
    .filter-bar select {
        width: 100%;
        font-size: 13px;
        padding: 6px 10px;
    }
    .filter-bar .btn-group {
        width: 100%;
        min-width: unset;
    }
    .filter-bar .btn-group .dim-btn {
        font-size: 12px;
        padding: 8px 0;
    }
    .stats-summary .item .num {
        font-size: 18px;
    }
    .bar-chart {
        height: 150px;
        min-height: 150px;
        padding-bottom: 20px;
        gap: 3px;
    }
    .bar {
        min-width: 4px;
        max-width: 18px;
        min-height: 2px;
    }
    .bar-value {
        font-size: 8px;
        top: -14px;
    }
    .bar-label {
        font-size: 7px;
    }
    .calendar-grid .day-cell {
        min-height: 35px;
        padding: 4px 1px;
    }
    .calendar-grid .day-cell .day-num {
        font-size: 11px;
    }
    .calendar-grid .day-cell .day-count {
        font-size: 8px;
    }
    .chart-container {
        padding: 10px;
    }
    .chart-title {
        font-size: 12px;
    }
    .header h3 {
        font-size: 18px;
    }
    .btn-back {
        padding: 6px 12px;
        font-size: 13px;
    }
    .calendar-grid .day-cell .day-detail-popup {
        left: 0;
        transform: none;
        width: 180px;
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .bar-chart {
        height: 120px;
        min-height: 120px;
        padding-bottom: 16px;
    }
    .bar-value {
        font-size: 7px;
        top: -12px;
    }
    .bar-label {
        font-size: 6px;
    }
    .stats-summary .item .num {
        font-size: 16px;
    }
}