/* learning-statistics.css — 學習數據總覽專用樣式 */

.learning-statistics-page .rbt-counterup-area {
    padding: 60px 0;
}

.learning-statistics-page .rbt-counterup {
    width: min(250px, 100%);
    aspect-ratio: 1;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.learning-statistics-page .ha-panel {
    min-width: 0;
}

@media (max-width: 575px) {
    .learning-statistics-page .ha-panel {
        padding: 18px 14px;
    }

    .learning-statistics-page .ha-gender-header,
    .learning-statistics-page .ha-gender-header-right {
        flex-wrap: wrap;
    }
}

.rbt-counterup {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: none;
}

.rbt-counterup .inner {
    background: transparent;
    padding: 10px;
}

.rbt-counterup .content {
    background: transparent;
}

/* ============================================
   Learning Statistics — 進階統計視覺化
   ============================================ */
.ha-section {
    padding: 60px 0;
}
.ha-section .section-title { text-align: center; margin-bottom: 40px; }
.ha-section .section-title h2 { font-size: 2.2rem; font-weight: 800; color: #1a1a2e; }
.ha-section .section-title p { color: #6b7280; font-size: 1.5rem; margin-top: 6px; }

/* Filter bar */
.ha-filter-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.ha-filter-group { display: flex; align-items: center; gap: 8px; }
.ha-filter-group label { font-size: 1.4rem; font-weight: 600; color: #374151; white-space: nowrap; }

/* Panel header with inline filter */
.ha-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.ha-panel-header .ha-panel-title { margin-bottom: 0; }
.ha-inline-filter { display: flex; gap: 6px; align-items: center; }

/* Compact select for inline filters (原生 select 備用，Tom Select 啟用後被隱藏) */
select.ha-select-sm {
    padding: 4px 24px 4px 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 6px center;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
select.ha-select-sm:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); outline: none; }

/* Tom Select 會把 ha-select-sm class 複製到 .ts-wrapper，需清除 */
.ts-wrapper.ha-select-sm {
    padding: 0 !important;
    border: none !important;
    background: none !important;
    min-height: auto !important;
    appearance: unset !important;
}

/* Tom Select compact inside inline filter */
.ha-inline-filter .ts-wrapper.rbt-modern-select-ts { min-width: 100px; }
.ha-inline-filter .ts-wrapper.rbt-modern-select-ts .ts-control {
    min-height: 32px !important;
    padding: 2px 28px 2px 10px !important;
    font-size: 13px !important;
    font-weight: 600;
    border-radius: 8px !important;
}

.ha-select {
    padding: 8px 32px 8px 14px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 1.35rem;
    font-weight: 600;
    color: #374151;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ha-select:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); outline: none; }

/* Grid layouts */
.ha-two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.ha-three-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
@media (max-width: 991px) {
    .ha-two-cols, .ha-three-cols { grid-template-columns: 1fr; }
}

/* Card panels */
.ha-panel {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f5;
}
.ha-panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ha-panel-title i { color: #6366f1; font-size: 1.3rem; }

/* Bubble chart */
#bubble-chart { width: 100%; min-height: 420px; display: flex; justify-content: center; }
#bubble-chart svg { max-width: 100%; }

/* Bubble view tabs (人數 / 開課數) */
.ha-bubble-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 8px;
    width: fit-content;
}
.ha-bubble-tab {
    padding: 5px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}
.ha-bubble-tab:hover { color: #334155; background: rgba(255,255,255,0.6); }
.ha-bubble-tab.active { background: #fff; color: #6366f1; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.ha-bubble-tab i { font-size: 14px; }

/* Panel accent — Bubble */
.ha-bubble-panel { position: relative; overflow: hidden; }
.ha-bubble-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #eab308 0%, #f97316 25%, #6366f1 50%, #06b6d4 75%, #22c55e 100%);
    border-radius: 16px 16px 0 0;
}

/* Panel accent — Trend */
.ha-trend-panel { position: relative; overflow: hidden; }
.ha-trend-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #22c55e, #06b6d4, #6366f1);
    border-radius: 16px 16px 0 0;
}

/* Trend chart */
.ha-trend-wrap { position: relative; }
#trend-chart-canvas { width: 100%; border-radius: 12px; }

/* Tabs — Legacy (fallback) */
.ha-tab-bar { display: flex; gap: 4px; margin-bottom: 16px; }
.ha-tab {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f8f9fc;
    font-size: 1.35rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}
.ha-tab:hover { background: #eef0f6; color: #4b5563; }
.ha-tab.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
}

/* ============================================
   Township Gender Chart — Redesigned UX/UI
   ============================================ */
.ha-gender-panel { position: relative; overflow: hidden; }
.ha-gender-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6 50%, #ec4899 50%);
    border-radius: 16px 16px 0 0;
}

/* Header with summary */
.ha-gender-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 4px;
}
.ha-gender-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Gender summary cards */
.ha-gender-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.ha-gender-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ha-gender-stat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.ha-gender-stat.stat-male {
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(59,130,246,0.04));
    color: #2563eb;
    border: 1px solid rgba(59,130,246,0.15);
}
.ha-gender-stat.stat-female {
    background: linear-gradient(135deg, rgba(236,72,153,0.08), rgba(236,72,153,0.04));
    color: #db2777;
    border: 1px solid rgba(236,72,153,0.15);
}
.ha-gender-stat .stat-icon { font-size: 1.1rem; }
.ha-gender-stat .stat-count { font-size: 1.6rem; letter-spacing: -0.5px; }

/* Gender Tabs */
.ha-gender-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    padding: 4px;
    background: #f3f4f6;
    border-radius: 12px;
    width: fit-content;
}
.ha-gender-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 10px;
    border: none;
    background: transparent;
    font-size: 1.35rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ha-gender-tab:hover { background: rgba(255,255,255,0.7); color: #374151; }
.ha-gender-tab.active {
    background: #fff;
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}
.ha-gender-tab.active[data-view="male"] { color: #2563eb; }
.ha-gender-tab.active[data-view="female"] { color: #db2777; }
.ha-gender-tab.active[data-view="all"] { color: #6366f1; }
.ha-gender-tab i { font-size: 1.1rem; }

/* Gender dot indicator */
.ha-gender-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ha-dot-male { background: #3b82f6; }
.ha-dot-female { background: #ec4899; }

/* Enhanced bar rows for gender view */
.ha-gender-panel .sd-bar-row {
    padding: 4px 0;
    border-radius: 8px;
    transition: background 0.2s;
}
.ha-gender-panel .sd-bar-row:hover {
    background: rgba(99,102,241,0.03);
}
.ha-gender-panel .sd-bar-label {
    width: 80px;
    font-size: 1.35rem;
}
.ha-gender-panel .sd-bar-track {
    height: 26px;
    border-radius: 8px;
    background: #f0f1f5;
}
.ha-gender-panel .sd-bar-fill {
    border-radius: 8px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.ha-gender-panel .sd-bar-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #374151;
    min-width: 60px;
}
/* 隱藏 stacked bar 自動圖例（已有 tab + 統計徽章） */
.ha-gender-panel .sd-pie-summary { display: none; }

/* Legend */
.ha-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.ha-legend-item { display: flex; align-items: center; gap: 5px; font-size: 1.3rem; color: #4b5563; }
.ha-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Bar chart (reuse sd- classes from systemdashboard) */
.ha-section .sd-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.ha-section .sd-bar-label {
    width: 70px;
    font-size: 1.3rem;
    color: #374151;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.ha-section .sd-bar-track {
    flex: 1;
    height: 22px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
}
.ha-section .sd-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 2px;
}
.ha-section .sd-bar-value {
    width: 55px;
    font-size: 1.25rem;
    color: #6b7280;
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
}
.ha-section .sd-empty {
    padding: 30px;
    text-align: center;
    color: #9ca3af;
    font-size: 1.35rem;
}

/* Bar colors */
.ha-section .bar-red { background: linear-gradient(90deg, #ef4444, #f87171); }
.ha-section .bar-orange { background: linear-gradient(90deg, #f97316, #fb923c); }
.ha-section .bar-amber { background: linear-gradient(90deg, #eab308, #facc15); }
.ha-section .bar-green { background: linear-gradient(90deg, #22c55e, #4ade80); }
.ha-section .bar-blue { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.ha-section .bar-purple { background: linear-gradient(90deg, #a855f7, #c084fc); }
.ha-section .bar-teal { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.ha-section .bar-cyan { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.ha-section .bar-rose { background: linear-gradient(90deg, #f43f5e, #fb7185); }

/* SVG Map */
.ha-map-svg { width: 100%; height: auto; }
.ha-map-path {
    cursor: pointer;
    transition: opacity 0.2s, stroke-width 0.2s;
}
.ha-map-label {
    font-size: 9px;
    fill: #374151;
    text-anchor: middle;
    pointer-events: none;
    font-weight: 600;
}
.ha-map-legend { margin-top: 12px; text-align: center; }
.ha-map-legend-title { font-size: 1.25rem; color: #6b7280; font-weight: 600; display: block; margin-bottom: 6px; }
.ha-map-legend-bar { height: 10px; border-radius: 5px; width: 80%; margin: 0 auto; }
.ha-map-legend-labels { display: flex; justify-content: space-between; width: 80%; margin: 4px auto 0; font-size: 1.15rem; color: #9ca3af; }
