/* Sparkline chart sizing */
.sparkline-container {
    width: 80px;
    height: 32px;
}

.sparkline-canvas {
    width: 80px !important;
    height: 32px !important;
}

/* Chart containers */
.chart-container {
    position: relative;
    width: 100%;
}

/* Retention heatmap cells */
.retention-cell {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Tab active state */
.tab-btn {
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn:focus {
    outline: none;
}

/* Loading spinner */
.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(148, 163, 184, 0.2);
    border-top-color: #94a3b8;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast notifications */
.toast {
    animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Time range selector */
.time-range-btn {
    cursor: pointer;
}

/* Scrollbar styling for dark theme */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0f172a;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Tabular numbers for consistent digit widths */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Table row hover */
tbody tr:hover {
    background-color: rgba(51, 65, 85, 0.3);
}

/* Modal backdrop blur */
#add-app-modal > div:first-child,
#invite-user-modal > div:first-child {
    backdrop-filter: blur(4px);
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}
th.sortable:hover {
    color: #e2e8f0;
}
th.sortable::after {
    content: '⇅';
    margin-left: 4px;
    opacity: 0.3;
    font-size: 0.7rem;
}
th.sortable.sort-asc::after {
    content: '↑';
    opacity: 0.8;
}
th.sortable.sort-desc::after {
    content: '↓';
    opacity: 0.8;
}

/* Alpine — keep x-cloak'd subtrees invisible until Alpine evaluates x-show.
   Without this rule, every page using Alpine briefly flashes the raw HTML
   (e.g. a closed dropdown appears open) before init. */
[x-cloak] {
    display: none !important;
}

/* Reconciliation status colors. Applied to displayed numbers via the
   `recon-{status}` class. Designed to be subtle — `verified` is the
   normal white (no override) so the eye isn't drawn to confirmed-good
   numbers. Single-source and lag-skipped read as "fine but unverified"
   in a muted slate. Disagreements use desaturated amber and rose so
   they read as caution/error WITHOUT screaming for attention.

   Legend uses the same swatches via `.recon-swatch` so the key is
   visually grounded in what users see in cells. */
.recon-verified           { /* unchanged — normal white */ }
.recon-single_source      { color: #cbd5e1; } /* slate-300 — slightly muted */
.recon-no_data            { color: #64748b; } /* slate-500 — clearly absent */
.recon-lag_skipped        { color: #cbd5e1; } /* same as single — verifier pending */
.recon-disagreement_minor { color: #fcd34d; } /* amber-300 — caution */
.recon-disagreement_major { color: #fda4af; } /* rose-300 — needs eyes, not alarming */

.recon-swatch {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 0.125rem;
    vertical-align: middle;
}
.recon-swatch.recon-verified           { background-color: #ffffff; }
.recon-swatch.recon-single_source      { background-color: #cbd5e1; }
.recon-swatch.recon-no_data            { background-color: #64748b; }
.recon-swatch.recon-lag_skipped        { background-color: #cbd5e1; }
.recon-swatch.recon-disagreement_minor { background-color: #fcd34d; }
.recon-swatch.recon-disagreement_major { background-color: #fda4af; }

/* Recon tooltip — shows source-by-source breakdown after 3s of hover.
   Positioning is `absolute` relative to the cell wrapper (which sets
   position:relative via .recon-tip-anchor). */
.recon-tip-anchor { position: relative; }
.recon-tip {
    position: absolute;
    z-index: 50;
    bottom: calc(100% + 4px);
    right: 0;
    min-width: 220px;
    max-width: 320px;
    background-color: rgba(15, 23, 42, 0.98);
    border: 1px solid rgb(51, 65, 85);
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    font-size: 11px;
    line-height: 1.4;
    color: rgb(226, 232, 240);
    pointer-events: none;
    white-space: normal;
}
.recon-tip table { width: 100%; border-collapse: collapse; }
.recon-tip td { padding: 2px 0; }
.recon-tip td.recon-tip-src {
    color: rgb(148, 163, 184);
    font-size: 11px;
    padding-right: 12px;
}
.recon-tip td.recon-tip-val { text-align: right; font-variant-numeric: tabular-nums; }
.recon-tip td.recon-tip-skipped { color: rgb(100, 116, 139); font-style: italic; }
.recon-tip td.recon-tip-cov {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 10px;
    padding-left: 10px;
}
.recon-tip-cov-full    { color: rgb(100, 116, 139); }  /* muted slate — silent confirmation */
.recon-tip-cov-partial { color: rgb(252, 211, 77); }   /* amber — coverage gap */
.recon-tip .recon-tip-note {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgb(51, 65, 85);
    color: rgb(148, 163, 184);
}

/* HTMX loading indicators */
.htmx-indicator {
    display: none;
}
.htmx-indicator.htmx-request {
    display: flex;
}
.htmx-request .loading-spinner {
    display: inline-block;
}

/* Smooth transitions for HTMX swaps */
.htmx-swapping {
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 0.15s ease-in;
}
