/* Page styles extracted from templates/graphs.html (loaded after styles.css, same cascade order). */
/* Circular loading spinner overlay */
.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 12px;
    z-index: 15;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.chart-loading-overlay.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.chart-spinner-ring {
    width: 44px;
    height: 44px;
    border: 3.5px solid rgba(56, 189, 248, 0.15);
    border-top: 3.5px solid #38bdf8;
    border-right: 3.5px solid #818cf8;
    border-radius: 50%;
    animation: chartSpin 0.85s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}
@keyframes chartSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.chart-spinner-text {
    margin-top: 12px;
    font-size: 0.88rem;
    color: #94a3b8;
    font-weight: 600;
    letter-spacing: 0.02em;
}
/* KPI Skeleton Placeholder */
.kpi-skeleton {
    display: inline-block;
    width: 65px;
    height: 22px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: kpiShimmer 1.5s infinite;
    border-radius: 6px;
    vertical-align: middle;
}
@keyframes kpiShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
/* Granularity Toggle Group Styles */
.granularity-toggle-group {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 3px;
    gap: 4px;
}
.granularity-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    user-select: none;
}
.granularity-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}
.granularity-btn.active {
    background: #38bdf8;
    color: #0b1120;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(56, 189, 248, 0.35);
}

.graphs-tab-pane {
    display: none;
}
.graphs-tab-pane.active {
    display: block;
    animation: tabFadeIn 0.25s ease-out;
}
@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Mode and Scale Toggle Button Group */
.chart-btn-group {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    gap: 3px;
}
.chart-toggle-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}
.chart-toggle-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
}
.chart-toggle-btn.active {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.chart-toggle-btn.active-teal {
    background: rgba(20, 184, 166, 0.2);
    color: #2dd4bf;
    border: 1px solid rgba(20, 184, 166, 0.4);
}
.chart-toggle-btn.active-purple {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.4);
}
.chart-toggle-btn.active-amber {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

/* ==========================================================================
   Analytics v3.11: header, 30-day cards, cards with one chart each, rankings
   ========================================================================== */
.an-head {
    margin: 28px 0 18px;
}
.an-title {
    margin: 0;
    color: #ffffff;
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 800;
}
.an-sub {
    margin: 6px 0 0;
    color: #94a3b8;
}
.an-kpis {
    margin-bottom: 10px;
}
.an-delta {
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
}
.an-delta.up {
    color: #4ade80;
}
.an-delta.down {
    color: #f87171;
}

.an-card {
    padding: 20px 24px !important;
    margin: 0 0 22px !important;
}
.an-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 16px;
}
.an-card-title {
    margin: 0;
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 800;
}
.an-card-desc {
    margin: 4px 0 0;
    color: #94a3b8;
    font-size: 0.88rem;
}
.an-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.an-chart {
    position: relative;
    width: 100%;
}
.an-chart-lg { height: 420px; }
.an-chart-md { height: 340px; }
.an-chart-sm { height: 230px; }

.an-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.an-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}
.an-badge-blue { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.an-badge-indigo { background: rgba(129, 140, 248, 0.15); color: #a5b4fc; border: 1px solid rgba(129, 140, 248, 0.4); }
.an-badge-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.4); }

/* Punchcard */
.an-punch-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0 10px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.an-subtitle {
    color: #e2e8f0;
    font-weight: 700;
}
.an-legend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #8b9bb0;
    font-size: 0.78rem;
}
.an-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}
.an-punch {
    position: relative;
    min-height: 200px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.an-punch-grid {
    display: grid;
    grid-template-columns: 76px repeat(24, minmax(18px, 1fr));
    gap: 4px;
    min-width: 620px;
    align-items: center;
}
.an-punch-hour {
    text-align: left;
    font-size: 0.72rem;
    color: #8b9bb0;
    font-weight: 600;
}
.an-punch-day {
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    text-align: right;
    padding-right: 10px;
}

.an-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}
.an-grid-2 .an-card {
    margin-bottom: 0 !important;
}

/* Compact rankings (top servers / members) */
.an-rank {
    position: relative;
    list-style: none;
    margin: 0;
    padding: 0;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.an-rank-item {
    display: grid;
    grid-template-columns: 26px auto minmax(0, 1fr) minmax(60px, 28%) 78px;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
}
.an-rank-item:not(:has(img)) {
    grid-template-columns: 26px minmax(0, 1fr) minmax(60px, 32%) 78px;
}
.an-rank-pos {
    color: #94a3b8;
    font-weight: 800;
    text-align: center;
}
.podium-1 .an-rank-pos { color: #fbbf24; }
.podium-2 .an-rank-pos { color: #cbd5e1; }
.podium-3 .an-rank-pos { color: #f97316; }
.an-rank-item img {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    object-fit: cover;
}
.an-rank-name {
    color: #f1f5f9;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.an-rank-name:hover {
    color: #38bdf8;
}
.an-rank-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.an-rank-bar i {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
}
.an-rank-value {
    text-align: right;
    color: #cbd5e1;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.an-rank-empty {
    color: #94a3b8;
    padding: 20px;
    text-align: center;
}
.an-more {
    display: inline-block;
    margin-top: 14px;
    color: #38bdf8;
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
}
.an-more:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .an-grid-2 {
        grid-template-columns: minmax(0, 1fr);
    }
    .an-grid-2 .an-card {
        margin-bottom: 0 !important;
    }
}
@media (max-width: 600px) {
    .an-card {
        padding: 16px !important;
    }
    .an-chart-lg { height: 320px; }
    .an-chart-md { height: 280px; }
    .an-controls {
        width: 100%;
    }
    .an-controls .granularity-toggle-group {
        flex: 1 1 auto;
    }
    .an-controls .granularity-btn {
        flex: 1;
        justify-content: center;
        padding: 6px 8px;
    }
    .an-rank-item {
        grid-template-columns: 22px auto minmax(0, 1fr) auto;
    }
    .an-rank-item:not(:has(img)) {
        grid-template-columns: 22px minmax(0, 1fr) auto;
    }
    .an-rank-bar {
        display: none;
    }
}

/* Phones: the four 30-day cards stay in a compact 2x2 grid */
@media (max-width: 600px) {
    .an-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    .an-kpis .dashboard-kpi-card {
        padding: 12px !important;
        min-height: 0;
    }
    .an-kpis .dashboard-kpi-icon {
        display: none;
    }
    .an-kpis .dashboard-kpi-label {
        font-size: 0.68rem;
    }
    .an-kpis .dashboard-kpi-val {
        font-size: 1.4rem !important;
        margin: 6px 0 4px;
    }
    .an-delta {
        font-size: 0.7rem;
    }
    /* Three tabs share the width instead of scrolling */
    .graphs-tabs {
        gap: 6px;
    }
    .graphs-tab-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 6px;
        font-size: 0.85rem;
        gap: 6px;
    }
}
.an-controls .granularity-btn {
    white-space: nowrap;
}
.an-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.92rem;
}
.an-empty[hidden] {
    display: none;
}
