/* static/css/analytics.css */

/* ---------------------------------------
   Analytics – Layout (Shell)
   ------------------------------------ */

.analytics-layout {
    display: flex;
    gap: 1.05rem;
    height: 100%;
    min-height: 0;
    align-items: stretch;
}

/* Sidebar mit Titel + Navigation */

.analytics-sidebar {
    flex: 0 0 18rem;
    max-width: 20rem;
    display: flex;
    flex-direction: column;
    gap: 0.72rem;
    padding: 0.82rem 0.78rem;
    border-radius: var(--sa-radius-card);
    border: 1px solid rgba(138, 100, 62, 0.24);
    background:
        radial-gradient(circle at top right, rgba(179, 18, 23, 0.12), transparent 52%),
        linear-gradient(180deg, #fffdfa, #fff);
    box-shadow: var(--sa-shadow-soft);
    position: sticky;
    top: 5.3rem;
    height: fit-content;
}

.analytics-title {
    margin: 0 0 0.15rem;
    font-size: 1.12rem;
    font-weight: 640;
    line-height: 1.25;
}

.analytics-text {
    margin: 0;
    font-size: 0.76rem;
    color: #6d5c4b;
    line-height: 1.4;
}

/* Detail-Panel rechts */

.analytics-detail {
    flex: 1 1 auto;
    min-width: 0;
    background:
        radial-gradient(circle at top right, rgba(179, 18, 23, 0.08), transparent 56%),
        #fff;
    border-radius: var(--sa-radius-card);
    border: 1px solid rgba(138, 100, 62, 0.2);
    box-shadow: var(--sa-shadow-soft-strong);
    padding: 0.95rem 1.15rem 1.1rem;
    overflow: auto;
    position: relative;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.analytics-detail-loading {
    opacity: 0.86;
    pointer-events: none;
    user-select: none;
}

.analytics-detail-loading::after {
    content: "";
    position: absolute;
    top: 0.9rem;
    right: 1rem;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    border: 2px solid rgba(179, 18, 23, 0.2);
    border-top-color: rgba(179, 18, 23, 0.85);
    animation: an-spin 0.8s linear infinite;
}

.analytics-detail-loading::before {
    content: "";
    position: absolute;
    inset: 3.35rem 1rem 1rem;
    border-radius: 0.8rem;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 5%,
        rgba(255, 255, 255, 0.62) 45%,
        rgba(255, 255, 255, 0) 85%
    );
    transform: translateX(-120%);
    animation: an-shimmer 1.2s ease-in-out infinite;
    pointer-events: none;
}

.analytics-detail-enter .an-view {
    animation: an-view-fade-up 0.24s ease both;
}

.analytics-detail-head {
    display: grid;
    gap: 0.18rem;
    margin-bottom: 0.72rem;
    padding: 0.06rem 0.05rem 0.62rem;
    border-bottom: 1px dashed rgba(150, 110, 72, 0.26);
}

.analytics-detail-kicker {
    font-size: 0.68rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #8a6a4d;
    font-weight: 600;
}

.analytics-detail-title {
    margin: 0;
    font-size: clamp(1.02rem, 0.96rem + 0.36vw, 1.24rem);
    line-height: 1.25;
}

.analytics-detail-desc {
    margin: 0;
    font-size: 0.77rem;
    color: #6f5d4c;
    line-height: 1.35;
}

.analytics-detail-body {
    position: relative;
    min-height: 10rem;
}

.analytics-placeholder {
    font-size: 0.85rem;
    color: var(--sa-text-muted);
}

.an-error {
    margin: 0;
    padding: 0.7rem 0.9rem;
    border-radius: 0.75rem;
    border: 1px solid #f0b8b8;
    background: #fff4f4;
    color: #7b1f22;
    font-size: 0.82rem;
}


/* ---------------------------------------
   Mobile-Dropdown (unterhalb ~960px)
   ------------------------------------ */

.analytics-mobile-select {
    display: none;
    margin-bottom: 0.6rem;
}

.analytics-nav-search-wrap {
    margin-bottom: 0.15rem;
}

.analytics-select-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sa-text-muted);
    margin-bottom: 0.2rem;
}

.analytics-select {
    width: 100%;
    padding: 0.45rem 0.95rem;
    border-radius: var(--sa-radius-pill);
    border: 1px solid var(--sa-border);
    background: #ffffff;
    font-size: 0.8rem;
    color: var(--sa-text-main);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #666 50%),
        linear-gradient(135deg, #666 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.analytics-select:focus {
    outline: none;
    border-color: var(--sa-red);
    box-shadow: 0 0 0 2px rgba(179, 18, 23, 0.16);
}

.analytics-nav-search {
    width: 100%;
    padding: 0.42rem 0.72rem;
    border-radius: 0.7rem;
    border: 1px solid rgba(146, 107, 69, 0.26);
    background: #fff;
    font-size: 0.78rem;
    color: var(--sa-text-main);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.analytics-nav-search::placeholder {
    color: #9a846d;
}

.analytics-nav-search:focus {
    outline: none;
    border-color: var(--sa-red);
    box-shadow: 0 0 0 2px rgba(179, 18, 23, 0.14);
    background: #fffdfa;
}


/* ---------------------------------------
   Desktop-Kacheln (Navigation)
   ------------------------------------ */

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.5rem;
}

.analytics-card {
    display: block;
    padding: 0.68rem 0.8rem;
    border-radius: 0.8rem;
    background: linear-gradient(180deg, #fff, #fffdfa);
    border: 1px solid rgba(143, 106, 67, 0.23);
    text-decoration: none;
    color: var(--sa-text-main);
    font-size: 0.8rem;
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
    transition:
        background 0.16s ease,
        box-shadow 0.16s ease,
        transform 0.12s ease,
        border-color 0.16s ease;
}

.analytics-card h2 {
    margin: 0 0 0.25rem;
    font-size: 0.92rem;
    font-weight: 620;
    line-height: 1.25;
}

.analytics-card p {
    margin: 0;
    font-size: 0.75rem;
    color: #6f5d4c;
    line-height: 1.3;
}

.analytics-card:hover {
    background: linear-gradient(180deg, #fff8f7, #fff2f0);
    border-color: rgba(179, 18, 23, 0.35);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.analytics-card-active {
    border-color: rgba(179, 18, 23, 0.52);
    box-shadow:
        0 8px 18px rgba(179, 18, 23, 0.22),
        inset 0 0 0 1px rgba(179, 18, 23, 0.11);
    background: linear-gradient(180deg, #fff7f5, #fff2ef);
}

.analytics-card-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0.2rem;
    background: linear-gradient(180deg, #b31217, #e2595c);
}

.analytics-card:focus-visible {
    outline: none;
    border-color: var(--sa-red);
    box-shadow:
        0 0 0 2px rgba(179, 18, 23, 0.18),
        0 6px 18px rgba(179, 18, 23, 0.2);
}

.analytics-card-hidden {
    display: none;
}


/* ---------------------------------------
   Generic view styles
   ------------------------------------ */

.an-view {
    display: flex;
    flex-direction: column;
    gap: 0.62rem;
    margin-bottom: 0.95rem;
}

.an-view:last-of-type {
    margin-bottom: 0;
}

.an-view-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 630;
}

.an-view-text {
    margin: 0;
    font-size: 0.79rem;
    line-height: 1.45;
    color: #6a5949;
}

.an-highlight {
    font-weight: 600;
    color: var(--sa-red);
}


/* ---------------------------------------
   Overview cards
   ------------------------------------ */

.an-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 0.55rem;
    margin-top: 0.45rem;
}

.an-stat-card {
    padding: 0.62rem 0.74rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(149, 111, 72, 0.24);
    background:
        radial-gradient(circle at top right, rgba(179, 18, 23, 0.08), transparent 54%),
        #faf7f2;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.an-stat-label {
    font-size: 0.7rem;
    color: var(--sa-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.an-stat-value {
    margin-top: 0.2rem;
    font-size: 1.08rem;
    font-weight: 640;
    letter-spacing: 0.01em;
}

.an-stat-sub {
    margin-top: 0.1rem;
    font-size: 0.75rem;
    color: var(--sa-text-muted);
}


/* ---------------------------------------
   Bars + tables (race, faces, etc.)
   ------------------------------------ */

.an-subtitle {
    margin: 0.7rem 0 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.an-barlist {
    margin-top: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.an-bar-row {
    display: grid;
    grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) auto;
    gap: 0.45rem;
    align-items: center;
    font-size: 0.78rem;
}

.an-bar-label {
    color: var(--sa-text-muted);
}

.an-bar-track {
    position: relative;
    height: 0.55rem;
    border-radius: var(--sa-radius-pill);
    background: #f1e6d9;
    overflow: hidden;
}

.an-bar-track-inline {
    margin-top: 0.25rem;
}

.an-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: var(--sa-radius-pill);
    background: linear-gradient(
        90deg,
        var(--sa-red) 0%,
        #f37b4b 60%,
        #ffd6a3 100%
    );
    transition: width 0.58s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--an-delay, 0ms);
}

.an-bar-value {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.an-bar-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--sa-text-muted);
}


/* Tabellen – gerahmte SA-Optik */

.an-table-scroll,
.an-table-wrapper {
    margin-top: 0.45rem;
    border-radius: 0.7rem;
    border: 1px solid var(--sa-border);
    overflow: auto;
    background: #fff;
}

.an-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.78rem;
}

.an-table thead {
    background: #faf7f2;
    position: sticky;
    top: 0;
    z-index: 1;
}

.an-table th,
.an-table td {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #efe7dc;
    vertical-align: middle;
}

.an-table tbody tr:nth-child(even) {
    background: rgba(246, 239, 230, 0.4);
}

.an-table tbody tr:hover {
    background: rgba(255, 247, 240, 0.85);
}

.an-table th {
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sa-text-muted);
    white-space: nowrap;
}

.an-col-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.an-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.an-name-main {
    font-weight: 500;
}

.an-footnote {
    margin-top: 0.4rem;
    font-size: 0.73rem;
    line-height: 1.3;
    color: var(--sa-text-muted);
}


/* ---------------------------------------
   Scatter / Heatmap (falls noch genutzt)
   ------------------------------------ */

.an-scatter-chart {
    margin-top: 0.6rem;
    width: 100%;
    min-height: 11rem;
}

.an-scatter-svg {
    width: 100%;
    height: auto;
    display: block;
}

.an-scatter-grid {
    stroke: #efe2d3;
    stroke-width: 0.35;
}

.an-scatter-label-y {
    font-size: 8px;
    text-anchor: end;
    fill: var(--sa-text-muted);
    dominant-baseline: middle;
}

.an-scatter-label-x {
    font-size: 8px;
    text-anchor: middle;
    fill: var(--sa-text-muted);
}

.an-scatter-point {
    fill: rgba(179, 18, 23, 0.9);
    stroke: #ffffff;
    stroke-width: 0.25;
}


/* ---------------------------------------
   Modal (falls verwendet)
   ------------------------------------ */

.an-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
}

.an-modal.is-open {
    display: flex;
}

/* weitere Modal-Styles kannst du bei Bedarf ergänzen */

@keyframes an-view-fade-up {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes an-item-fade-up {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes an-shimmer {
    to {
        transform: translateX(120%);
    }
}


/* ---------------------------------------
   Responsive (nur Analytics)
   ------------------------------------ */

@media (max-width: 960px) {
    .analytics-layout {
        flex-direction: column;
        min-height: auto;
    }

    .analytics-sidebar {
        flex: 0 0 auto;
        max-width: none;
        position: static;
        top: auto;
    }

    /* Desktop-Kacheln ausblenden, Dropdown zeigen */
    .analytics-grid {
        display: none;
    }

    .analytics-mobile-select {
        display: block;
    }

    .analytics-nav-search-wrap {
        display: none;
    }

    .analytics-detail {
        padding: 0.9rem 0.9rem 1rem;
    }

    .analytics-detail-loading::before {
        inset: 3.25rem 0.8rem 0.8rem;
    }
}

@media (max-width: 640px) {
    .analytics-layout {
        gap: 0.8rem;
    }

    .an-table th,
    .an-table td {
        padding: 0.4rem 0.45rem;
    }

    .an-overview-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .analytics-detail,
    .analytics-card,
    .an-bar-fill,
    .an-bar-row {
        transition: none !important;
        animation: none !important;
    }

    .analytics-detail-loading::before {
        animation: none !important;
    }
}
