/* Jolixo — Admin Analytics page: KPI cards, performance chart, engagement gauge and top games. */

.an-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin: 4px 0 22px;
}

.an-head h1 {
    font-size: clamp(24px, 2.2vw, 30px);
    margin: 0 0 4px;
}

.an-head p {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.an-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.an-controls form {
    margin: 0;
}

.an-export svg {
    width: 16px;
    height: 16px;
}

/* KPI cards */
.an-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.an-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.an-kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.an-kpi-top i {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-style: normal;
    background: var(--vi-soft);
    color: var(--vi);
}

.an-kpi-top svg {
    width: 18px;
    height: 18px;
}

.an-kpi-val {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.an-kpi-val strong {
    font-size: clamp(28px, 2.6vw, 38px);
    font-weight: 600;
    letter-spacing: -.03em;
    line-height: 1;
}

.an-kpi small {
    font-size: 12px;
    color: var(--muted);
}

.an-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.an-badge.up {
    background: rgba(34, 197, 139, .14);
    color: #18a874;
}

.an-badge.down {
    background: rgba(255, 106, 61, .14);
    color: #e5532a;
}

.an-badge.flat {
    background: var(--soft);
    color: var(--muted);
}

[data-theme=dark] .an-badge.up {
    color: #5fe0b5;
}

[data-theme=dark] .an-badge.down {
    color: #ff8a66;
}

/* First card is the highlighted one */
.an-kpi.an-hl {
    border: 0;
    color: #fff;
    background: radial-gradient(circle at 90% 0%, rgba(255, 255, 255, .28), transparent 45%), linear-gradient(140deg, #9d8cff, #6c4fe0);
    box-shadow: 0 18px 40px -18px rgba(108, 79, 224, .8);
}

.an-hl .an-kpi-top,
.an-hl small {
    color: rgba(255, 255, 255, .8);
}

.an-hl .an-kpi-top i {
    background: #fff;
    color: #6c4fe0;
}

.an-hl .an-badge,
[data-theme] .an-hl .an-badge {
    background: rgba(255, 255, 255, .22);
    color: #fff;
}

/* Cards */
.an-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.an-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px;
    min-width: 0;
}

.an-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.an-card-head h2 {
    font-size: 17px;
    margin: 0;
    font-weight: 650;
}

.an-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--muted);
}

.an-legend span,
.an-tip span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lg-views,
.lg-starts {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.lg-views {
    background: color-mix(in srgb, var(--vi) 35%, var(--soft));
}

.lg-starts {
    background: var(--vi);
}

/* Performance chart */
.an-chart {
    display: grid;
    grid-template-columns: 40px 1fr;
    height: 300px;
}

.an-y {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-bottom: 24px;
    font-size: 11px;
    color: var(--muted);
    transform: translateY(-6px);
}

.an-plot {
    position: relative;
}

/* Grid lines sit in the plot area only (above the 24px day labels). */
.an-grids {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 24px;
}

.an-grid {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1px dashed var(--border);
}

.an-bars {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.an-bars.an-nmany {
    gap: 4px;
}

.an-bar {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    outline: none;
}

.an-track {
    flex: 1;
    display: flex;
    align-items: flex-end;
    border-radius: 12px;
    background: color-mix(in srgb, var(--soft) 70%, transparent);
}

.an-nmany .an-track {
    border-radius: 6px;
}

.an-views {
    width: 100%;
    min-height: 3px;
    display: flex;
    align-items: flex-end;
    border-radius: inherit;
    background: color-mix(in srgb, var(--vi) 35%, var(--soft));
    transition: background .15s;
}

.an-starts {
    width: 100%;
    border-radius: inherit;
    background: repeating-linear-gradient(135deg, var(--vi) 0 6px, color-mix(in srgb, var(--vi) 80%, #fff) 6px 12px);
}

.an-bar:hover .an-views,
.an-bar:focus-visible .an-views {
    background: color-mix(in srgb, var(--vi) 60%, var(--soft));
}

.an-bar:focus-visible .an-track {
    box-shadow: 0 0 0 2px var(--vi);
}

.an-x {
    height: 24px;
    padding-top: 6px;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
}

.an-nmany .an-bar:nth-child(odd) .an-x {
    visibility: hidden;
}

/* Hover / focus tooltip, no JavaScript needed */
.an-tip {
    display: none;
    position: absolute;
    z-index: 5;
    bottom: calc(100% - 30px);
    left: 50%;
    transform: translate(-50%, -8px);
    min-width: 170px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .25);
    font-size: 12px;
    color: var(--muted);
    pointer-events: none;
}

.an-tip b {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--ink);
}

.an-tip span + span {
    margin-top: 4px;
}

.an-tip em {
    margin-left: auto;
    padding-left: 12px;
    font-style: normal;
    font-weight: 700;
    color: var(--ink);
}

.an-bar:hover .an-tip,
.an-bar:focus-visible .an-tip {
    display: block;
}

.an-bar:first-child .an-tip {
    left: 0;
    transform: translate(0, -8px);
}

.an-bar:last-child .an-tip {
    left: auto;
    right: 0;
    transform: translate(0, -8px);
}

/* Engagement */
.an-eng {
    display: flex;
    flex-direction: column;
}

.an-gauge {
    margin: 0 auto;
    max-width: 300px;
    width: 100%;
}

.an-note {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0 16px;
}

.an-minis {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.an-minis div {
    padding: 14px;
    border-radius: 14px;
    background: var(--soft);
    border: 1px solid var(--border);
    display: grid;
    gap: 6px;
}

.an-minis span {
    font-size: 12px;
    color: var(--muted);
}

.an-minis strong {
    font-size: 22px;
    font-weight: 600;
}

/* Top games table */
.an-tools {
    display: flex;
    gap: 10px;
    margin: 0;
}

.an-search {
    display: flex !important;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--soft);
}

.an-search svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.an-search input {
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    width: 180px;
}

.an-table td {
    font-size: 13px;
}

.an-game {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink) !important;
    font-weight: 600 !important;
}

.an-game img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    flex: none;
}

.an-rate {
    display: inline-block;
    vertical-align: middle;
    width: 70px;
    height: 6px;
    margin-right: 8px;
    border-radius: 999px;
    background: var(--soft);
    overflow: hidden;
}

.an-rate i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--vi);
}

@media (max-width: 1200px) {
    .an-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .an-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .an-kpis {
        grid-template-columns: 1fr;
    }

    .an-chart {
        height: 240px;
    }

    .an-tools {
        width: 100%;
    }

    .an-search {
        flex: 1;
    }

    .an-search input {
        width: 100%;
    }
}
