/*
 * App-specific overrides. Loaded by <capstone-head /> after Capstone's stylesheet.
 */

/* ============================================================
   Dashboard
   Ported from the ScholarshipDisbursement dashboard styles.
   Consumed by Views/Dashboard/* and wwwroot/js/dashboard-charts.js.
   ============================================================ */
.dashboard-container {
    width: 95%;
    max-width: 1400px;
    background: var(--bs-tertiary-bg);
    border-radius: 0.75rem;
    /* Brand-green text/icon color, theme-aware. --bs-primary (#006747) is pinned
       across themes, but only gives ~2.22:1 on the dark body bg — fails WCAG AA as
       text. Use a lighter green in dark mode (~6.5:1 on dark body bg). */
    --dashboard-brand-text: var(--bs-primary);
}

[data-bs-theme=dark] .dashboard-container {
    --dashboard-brand-text: #5cbc94;
}

/* --- Summary Stats Horizontal Scroll with Arrow Nav --- */
.summary-stats-nav {
    display: flex;
    align-items: stretch;
    position: relative;
}

.summary-stats-scroll {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.summary-stats-scroll::-webkit-scrollbar {
    display: none;
}

.summary-stat-item {
    flex: 0 0 auto;
    min-width: 140px;
}

.summary-stats-arrow {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    border: none;
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    border-radius: 0.375rem;
    padding: 0;
}

.summary-stats-arrow:hover {
    color: var(--dashboard-brand-text);
    background: color-mix(in srgb, var(--bs-primary) 8%, transparent);
}

.summary-stats-arrow.hidden {
    visibility: hidden;
    pointer-events: none;
}

/* --- Dashboard Tabs --- */
#dashboardTabs {
    border-bottom: none;
}

#dashboardTabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    /* Mix body-color toward tertiary-bg so the muted look survives but contrast
       clears AA (~7:1) in both themes. */
    color: color-mix(in srgb, var(--bs-body-color), var(--bs-tertiary-bg) 30%);
    font-weight: 500;
    padding: 0.625rem 1rem;
    transition: color 0.15s, border-color 0.15s;
}

#dashboardTabs .nav-link:hover {
    color: var(--dashboard-brand-text);
    border-bottom-color: var(--bs-border-color);
}

#dashboardTabs .nav-link.active {
    color: var(--dashboard-brand-text);
    border-bottom-color: var(--bs-primary);
    font-weight: 600;
}

/* --- Dashboard Section --- */
.dashboard-section {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.dashboard-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dashboard-brand-text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.dashboard-section-title i {
    font-size: 1.25rem;
    color: var(--dashboard-brand-text);
}

.dashboard-section-title .dashboard-info-icon {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    cursor: help;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.dashboard-section-title .dashboard-info-icon:hover {
    opacity: 1;
}

/* Scrollable card body: caps long tables so a card stays one screen-height. */
.dashboard-scroll {
    max-height: 21rem;
    overflow-y: auto;
}

.dashboard-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bs-body-bg);
    box-shadow: inset 0 -1px 0 var(--bs-border-color);
}

/* --- Dashboard Stat Card --- */
.dashboard-stat-card {
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    text-align: center;
    background: var(--bs-body-bg);
}

.dashboard-stat-icon {
    font-size: 1.75rem;
    color: var(--dashboard-brand-text);
    margin-bottom: 0.5rem;
}

.dashboard-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin-top: 0.25rem;
}

.dashboard-stat-subtext {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Dashboard Service Card (colored tiles, inline background colors set by JS) --- */
.dashboard-service-card {
    border-radius: 0.5rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    color: #fff;
    overflow: hidden;
    min-width: 0;
}

.dashboard-service-count {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-service-name {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    margin-top: 0.25rem;
    line-height: 1.3;
}

/* --- Dashboard Activity Feed --- */
.dashboard-activity-feed {
    max-height: 600px;
    overflow-y: auto;
}

/* Visible focus ring on scrollable dashboard regions made focusable (tabindex="0"). */
.summary-stats-scroll:focus-visible,
.dashboard-activity-feed:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.dashboard-activity-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    transition: background-color 0.15s;
}

.dashboard-activity-item:last-child {
    margin-bottom: 0;
}

.dashboard-activity-item:hover {
    background-color: var(--bs-tertiary-bg);
}

.activity-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-right: 0.75rem;
    margin-top: 0.125rem;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    margin-bottom: 0.125rem;
}

.activity-time {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

.activity-time i {
    font-size: 0.7rem;
}

/* --- Dashboard Leaderboard --- */
.dashboard-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.dashboard-leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dashboard-leaderboard-rank {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
    min-width: 1.5rem;
    text-align: center;
}

.dashboard-leaderboard-medal {
    font-size: 1.25rem;
    min-width: 1.5rem;
    text-align: center;
}

.dashboard-leaderboard-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.dashboard-leaderboard-name {
    width: 10rem;
    min-width: 8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-leaderboard-bar-bg {
    flex: 1;
    background: var(--bs-secondary-bg);
    border-radius: 0.25rem;
    height: 1rem;
    overflow: hidden;
}

.dashboard-leaderboard-bar {
    height: 100%;
    border-radius: 0.25rem;
    transition: width 0.3s ease;
}

.dashboard-leaderboard-count {
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

/* --- Dashboard Loading --- */
.dashboard-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--bs-secondary-color);
}

/* --- Compact floating select --- */
.floating-select.compact > .form-select {
    height: 3rem;
    min-height: 3rem;
    padding-top: 1.25rem;
    padding-bottom: 0.5rem;
}

.floating-select.compact > label {
    font-size: 0.8rem;
}

/* ============================================================
   Native dashboard charts (no Chart.js)
   Layout: yaxis + plot (row 1); blank + xaxis (row 2).
   Colors are CSS values so theme changes propagate automatically.
   ============================================================ */

.ds-chart {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr auto;
    column-gap: 0.5rem;
    row-gap: 0.25rem;
    width: 100%;
    height: 100%;
    font-size: 0.75rem;
    color: var(--bs-body-color);
    overflow: hidden;
}

.ds-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-secondary-color);
    height: 100%;
    font-size: 0.875rem;
}

.ds-chart-legend {
    grid-column: 1 / -1;
    grid-row: 1;
    align-self: start;
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}

.ds-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--bs-body-color);
}

.ds-chart-legend-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 2px;
}

/* When a legend is present, push the chart body down one row. */
.ds-chart:has(.ds-chart-legend) {
    grid-template-rows: auto 1fr auto;
}

.ds-chart:has(.ds-chart-legend) > .ds-chart-yaxis { grid-row: 2; }
.ds-chart:has(.ds-chart-legend) > .ds-chart-plot { grid-row: 2; }
.ds-chart:has(.ds-chart-legend) > .ds-chart-xaxis,
.ds-chart:has(.ds-chart-legend) > .ds-chart-hbar-xaxis { grid-row: 3; }

.ds-chart-yaxis {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    min-width: 2.5rem;
}

.ds-chart-ytick {
    position: absolute;
    right: 0.25rem;
    transform: translateY(-50%);
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

/* Keep the top and bottom y-axis labels inside the chart bounds. */
.ds-chart-ytick:first-child { transform: translateY(-100%); }
.ds-chart-ytick:last-child  { transform: translateY(0); }

.ds-chart-plot {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    border-left: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    min-height: 0;
}

.ds-chart-gridline {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--bs-border-color);
    opacity: 0.5;
    pointer-events: none;
}

.ds-chart-vgridline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--bs-border-color);
    opacity: 0.5;
    pointer-events: none;
}

.ds-chart-bars {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0 0.4rem;
}

.ds-chart-bar-col {
    flex: 1 1 0;
    height: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.ds-chart-bar {
    width: 100%;
    max-width: 3.5rem;
    background: var(--bs-primary);
    border-radius: 2px 2px 0 0;
    transition: opacity 0.15s;
    cursor: default;
}

.ds-chart-bar:hover {
    opacity: 0.85;
}

.ds-chart-line-svg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

.ds-chart-line-svg circle {
    pointer-events: all;
    cursor: default;
}

.ds-chart-xaxis {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    padding: 0.25rem 0.4rem 0;
    color: var(--bs-secondary-color);
}

.ds-chart-xtick {
    flex: 1 1 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.1rem;
    font-size: 0.7rem;
}

.ds-chart-xaxis.rotated {
    padding-top: 0.5rem;
    height: 3.5rem;
}

.ds-chart-xaxis.rotated .ds-chart-xtick {
    transform: rotate(-35deg);
    transform-origin: top right;
    text-align: right;
    overflow: visible;
    white-space: nowrap;
}

/* Horizontal bar chart */
.ds-chart-hbar {
    grid-template-columns: minmax(6rem, 14rem) 1fr;
}

.ds-chart-hbar > .ds-chart-yaxis {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0;
    gap: 0.25rem;
}

.ds-chart-hbar-ylabel {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    color: var(--bs-body-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ds-chart-hbar-rows {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0;
    gap: 0.25rem;
}

.ds-chart-hbar-row {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    cursor: default;
}

.ds-chart-hbar-fill {
    height: 70%;
    background: var(--bs-primary);
    border-radius: 0 2px 2px 0;
    min-width: 1px;
    transition: opacity 0.15s;
}

.ds-chart-hbar-row:hover .ds-chart-hbar-fill {
    opacity: 0.85;
}

.ds-chart-hbar-xaxis {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    height: 1.5rem;
    color: var(--bs-secondary-color);
}

.ds-chart-hbar-xtick {
    position: absolute;
    transform: translateX(-50%);
    top: 0.15rem;
    font-size: 0.7rem;
    white-space: nowrap;
}

/* --- Dashboard responsive --- */
@media (max-width: 768px) {
    .dashboard-container {
        width: 100%;
        border-radius: 0;
    }

    .dashboard-section {
        padding: 1rem;
    }

    .dashboard-section-title {
        font-size: 1rem;
    }

    .dashboard-stat-value {
        font-size: 1.5rem;
    }

    .dashboard-leaderboard-name {
        width: 6rem;
        min-width: 5rem;
    }

    .dashboard-leaderboard-entry {
        gap: 0.5rem;
    }
}
