/* =============================================================
   Statistics Dashboard - AGE
   Pagina publică de statistici a produselor digitale AGE.
   Design "wow": gradient hero, KPI cards animate, charts moderne,
   filtre cu chip-uri, grid responsive.
   ============================================================= */

:root {
    --stats-bg: #f6f6f7;
    --stats-surface: #ffffff;
    --stats-surface-2: #f8fafc;
    --stats-border: #e2e8f0;
    --stats-text: #0f172a;
    --stats-text-soft: #475569;
    --stats-text-mute: #94a3b8;

    --stats-primary: #0058d2;
    --stats-primary-600: #1d4ed8;
    --stats-primary-50: #eef4ff;
    --stats-accent: #2563eb;

    --stats-gold: #c08d00;
    --stats-green: #059669;
    --stats-violet: #7c3aed;
    --stats-rose: #e11d48;
    --stats-orange: #d97706;
    --stats-teal: #0d9488;

    --stats-radius: 16px;
    --stats-radius-lg: 22px;
    --stats-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --stats-shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
    --stats-shadow-lg: 0 24px 60px -20px rgba(0, 88, 210, .35);
}

body { background: var(--stats-bg); }

.stats-hero,
.stats-band {
    font-family: 'Onest', 'Inter', 'Roboto', system-ui, -apple-system, sans-serif;
}

/* ================ HERO ================ */
.stats-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 100%);
    color: var(--stats-text);
    padding: 64px 0 80px;
    isolation: isolate;
}

.stats-hero__bg {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
}

.stats-hero__blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .4;
    animation: stats-blob 18s ease-in-out infinite;
}

.stats-hero__blob--1 {
    width: 480px; height: 480px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.22) 0%, transparent 70%);
    top: -120px; left: -100px;
}

.stats-hero__blob--2 {
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(0, 88, 210, 0.16) 0%, transparent 70%);
    top: 30%; right: -80px;
    animation-delay: -6s;
}

.stats-hero__blob--3 {
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(125, 211, 252, 0.25) 0%, transparent 70%);
    bottom: -80px; left: 35%;
    animation-delay: -12s;
}

@keyframes stats-blob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(40px, -30px) scale(1.1); }
    66% { transform: translate(-30px, 25px) scale(.95); }
}

.stats-hero__container {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 32px;
}

.stats-hero__content { max-width: 880px; }

.stats-hero__eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--stats-primary);
    background: var(--stats-primary-50);
    border: 1px solid rgba(0, 88, 210, .14);
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 18px;
}

.stats-hero__title {
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.025em;
    margin: 0 0 18px;
    color: var(--stats-text);
}

.stats-hero__lead {
    font-size: 18px;
    line-height: 1.6;
    color: var(--stats-text-soft);
    max-width: 760px;
    margin: 0 0 22px;
}

.stats-hero__lead strong { color: var(--stats-text); font-weight: 600; }

.stats-hero__meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stats-hero__meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--stats-text-soft);
    background: var(--stats-surface);
    border: 1px solid var(--stats-border);
    padding: 6px 12px;
    border-radius: 999px;
}

.stats-hero__meta-pill svg { fill: currentColor; }

/* ================ BAND ================ */
.stats-band {
    padding: 48px 0 80px;
}

.stats-band--white { background: var(--stats-bg); }

.stats-band__container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 32px;
}

/* lifting card-row off the hero */
.stats-band > .stats-band__container > .stats-filters:first-child {
    margin-top: -56px;
    position: relative;
    z-index: 5;
}

/* ================ FILTRE ================ */
/* Layout pe 2 rânduri ca să nu se înghesuie când sunt multe categorii:
 *   Rândul 1:  [ AN ]  ─────────  [ CĂUTARE ]  [ RESETEAZĂ ]
 *   Rândul 2:  [ CATEGORIE PRODUS ────────────────────────── ]
 */
.stats-filters {
    background: var(--stats-surface);
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-lg);
    padding: 22px 24px;
    box-shadow: var(--stats-shadow-md);
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "year   search  actions"
        "category category category";
    column-gap: 24px;
    row-gap: 18px;
    align-items: start;
    margin-bottom: 36px;
}

.stats-filters__group { min-width: 0; }
.stats-filters__group--year     { grid-area: year; }
.stats-filters__group--category { grid-area: category; }
.stats-filters__group--search   { grid-area: search; min-width: 260px; align-self: end; }
.stats-filters__group--actions  { grid-area: actions; align-self: end; }

.stats-filters__label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--stats-text-mute);
    margin-bottom: 8px;
}

.stats-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stats-chip {
    appearance: none;
    background: var(--stats-surface-2);
    border: 1px solid transparent;
    color: var(--stats-text-soft);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stats-chip:hover {
    background: var(--stats-primary-50);
    color: var(--stats-primary);
}

.stats-chip.is-active {
    background: var(--stats-primary);
    color: #fff;
    border-color: var(--stats-primary);
    box-shadow: 0 6px 14px -4px rgba(0, 88, 210, .55);
}

.stats-chip__sub {
    font-size: 10px;
    font-weight: 700;
    opacity: .8;
    background: rgba(255, 255, 255, .25);
    padding: 2px 6px;
    border-radius: 4px;
}

.stats-chip.is-active .stats-chip__sub {
    background: rgba(255, 255, 255, .28);
}

.stats-search {
    position: relative;
    width: 100%;
}

.stats-search__icon {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    color: var(--stats-text-mute);
    fill: currentColor;
    pointer-events: none;
}

.stats-search__input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--stats-border);
    border-radius: 12px;
    padding: 0 14px 0 38px;
    font-size: 14px;
    color: var(--stats-text);
    background: var(--stats-surface);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.stats-search__input:focus {
    outline: none;
    border-color: var(--stats-primary);
    box-shadow: 0 0 0 3px rgba(0, 88, 210, .15);
}

.stats-btn {
    appearance: none;
    background: var(--stats-surface);
    color: var(--stats-text-soft);
    border: 1px solid var(--stats-border);
    border-radius: 12px;
    padding: 0 16px;
    height: 40px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}

.stats-btn--ghost:hover {
    background: var(--stats-primary-50);
    color: var(--stats-primary);
    border-color: var(--stats-primary-50);
}

.stats-btn svg { fill: currentColor; }

/* ================ SECTION TITLE ================ */
.stats-section-title {
    display: flex;
    align-items: baseline;
    gap: 14px;
    font-size: 22px;
    font-weight: 700;
    color: var(--stats-text);
    margin: 48px 0 18px;
    letter-spacing: -.01em;
}

.stats-section-title__num {
    font-size: 13px;
    font-weight: 700;
    color: var(--stats-primary);
    background: var(--stats-primary-50);
    padding: 4px 10px;
    border-radius: 8px;
    letter-spacing: .08em;
}

.stats-section-title__hint {
    margin-left: auto;
    font-size: 13px;
    font-weight: 500;
    color: var(--stats-text-mute);
}

/* ================ KPI CARDS ================ */
.stats-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

@media (min-width: 1280px) {
    .stats-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.stats-kpi {
    position: relative;
    background: var(--stats-surface);
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius);
    padding: 22px 22px 20px;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.stats-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--stats-shadow-md);
    border-color: var(--stats-primary-50);
}

.stats-kpi__icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--stats-primary-50);
    color: var(--stats-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.stats-kpi[data-tone="green"] .stats-kpi__icon { background: #d1fae5; color: var(--stats-green); }
.stats-kpi[data-tone="violet"] .stats-kpi__icon { background: #ede9fe; color: var(--stats-violet); }
.stats-kpi[data-tone="orange"] .stats-kpi__icon { background: #fef3c7; color: var(--stats-orange); }
.stats-kpi[data-tone="rose"] .stats-kpi__icon { background: #ffe4e6; color: var(--stats-rose); }
.stats-kpi[data-tone="teal"] .stats-kpi__icon { background: #ccfbf1; color: var(--stats-teal); }

.stats-kpi__icon svg { fill: currentColor; }

.stats-kpi__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--stats-text-mute);
    margin: 0 0 8px;
}

.stats-kpi__value {
    font-size: 30px;
    font-weight: 700;
    color: var(--stats-text);
    letter-spacing: -.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stats-kpi__unit {
    font-size: 14px;
    color: var(--stats-text-soft);
    font-weight: 600;
    margin-left: 4px;
}

.stats-kpi__delta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 999px;
    line-height: 1.2;
    max-width: 100%;
}

.stats-kpi__delta-sub {
    font-weight: 500;
    opacity: .85;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.stats-kpi__delta--up   { background: #d1fae5; color: #047857; }
.stats-kpi__delta--down { background: #ffe4e6; color: #be123c; }
.stats-kpi__delta--flat { background: var(--stats-surface-2); color: var(--stats-text-mute); font-weight: 500; }

.stats-kpi__sub {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--stats-text-mute);
    line-height: 1.4;
}

/* ================ EVOLUTION ================ */
.stats-evolution {
    background: var(--stats-surface);
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius);
    padding: 26px;
    box-shadow: var(--stats-shadow-sm);
}

.stats-evolution__controls {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

/* All controls share a 40px input/button height so they line up cleanly */
.stats-evolution__controls .stats-evolution__toggle,
.stats-evolution__controls .stats-btn,
.stats-evolution__controls .stats-select { height: 40px; }
.stats-evolution__controls .stats-evolution__toggle { display: inline-flex; align-items: center; }
.stats-evolution__controls .stats-btn { white-space: nowrap; }

.stats-evolution__select-wrap { flex: 1 1 320px; min-width: 0; }

.stats-select {
    width: 100%;
    height: 40px;
    border: 1px solid var(--stats-border);
    border-radius: 12px;
    background: var(--stats-surface);
    padding: 0 36px 0 14px;
    font-size: 14px;
    color: var(--stats-text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'%3E%3Cpath fill='%2364748b' d='M3.2 5.6 8 10.4l4.8-4.8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

.stats-select:focus {
    outline: none;
    border-color: var(--stats-primary);
    box-shadow: 0 0 0 3px rgba(0, 88, 210, .15);
}

.stats-evolution__toggle {
    display: inline-flex;
    background: var(--stats-surface-2);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.stats-toggle {
    appearance: none;
    background: transparent;
    color: var(--stats-text-soft);
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.stats-toggle.is-active {
    background: var(--stats-surface);
    color: var(--stats-primary);
    box-shadow: var(--stats-shadow-sm);
}

.stats-toggle svg { fill: currentColor; }

.stats-evolution__summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stats-evosum {
    padding: 12px 14px;
    background: var(--stats-surface-2);
    border-radius: 12px;
}

.stats-evosum__label {
    font-size: 11px;
    color: var(--stats-text-mute);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 0 0 4px;
    font-weight: 600;
}

.stats-evosum__value {
    font-size: 20px;
    font-weight: 700;
    color: var(--stats-text);
    letter-spacing: -.01em;
}

.stats-evosum__delta {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 700;
}

.stats-evosum__delta--up { color: var(--stats-green); }
.stats-evosum__delta--down { color: var(--stats-rose); }

.stats-evolution__canvas-wrap {
    position: relative;
    height: 340px;
}

/* ================ GRID ================ */
.stats-grid {
    display: grid;
    gap: 16px;
}

.stats-grid--two {
    grid-template-columns: 1.5fr 1fr;
}

.stats-card {
    background: var(--stats-surface);
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius);
    padding: 22px;
    box-shadow: var(--stats-shadow-sm);
}

.stats-card__head { margin-bottom: 14px; }

.stats-card__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--stats-text);
}

.stats-card__sub {
    font-size: 13px;
    color: var(--stats-text-mute);
    margin: 0;
}

.stats-card--chart .stats-card__body {
    position: relative;
    height: 380px;
}

.stats-card__empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    color: var(--stats-text-mute);
    font-size: 14px;
    line-height: 1.55;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.6), rgba(248, 250, 252, 0));
    border-radius: var(--stats-radius);
}

/* ================ PRODUCT CARDS ================ */
.stats-products {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stats-product {
    background: var(--stats-surface);
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius);
    padding: 20px;
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stats-product:hover {
    transform: translateY(-3px);
    box-shadow: var(--stats-shadow-md);
    border-color: var(--stats-primary-50);
}

.stats-product__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.stats-product__icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: var(--stats-primary-50);
    color: var(--stats-primary);
}

/* Brand logo lockup — when product has its own SVG logo, show it instead of the icon square */
.stats-product__brand {
    flex: 0 0 auto;
    height: 36px;
    max-width: 130px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
}
.stats-product__brand img {
    height: 28px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.stats-product[data-category="plati"] .stats-product__icon { background: #fef3c7; color: #b45309; }
.stats-product[data-category="adoptie"] .stats-product__icon { background: #dbeafe; color: var(--stats-primary); }
.stats-product[data-category="identitate"] .stats-product__icon { background: #ede9fe; color: var(--stats-violet); }
.stats-product[data-category="servicii"] .stats-product__icon { background: #d1fae5; color: var(--stats-green); }
.stats-product[data-category="infrastructura"] .stats-product__icon { background: #ccfbf1; color: var(--stats-teal); }
.stats-product[data-category="apl"] .stats-product__icon { background: #ffe4e6; color: var(--stats-rose); }
.stats-product[data-category="comunicare"] .stats-product__icon { background: #fef3c7; color: var(--stats-orange); }

.stats-product__icon svg { fill: currentColor; }

.stats-product__name {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--stats-text);
    min-width: 0;
    word-wrap: break-word;
    flex: 1 1 auto;
}

.stats-product__cat {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: var(--stats-text-mute);
    margin-top: 2px;
    display: block;
}

.stats-product__primary {
    margin-top: 4px;
    padding: 14px;
    border-radius: 12px;
    background: var(--stats-surface-2);
}

.stats-product__primary-label {
    font-size: 11px;
    color: var(--stats-text-mute);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
    margin: 0 0 4px;
}

.stats-product__primary-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--stats-text);
    letter-spacing: -.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stats-product__primary-delta {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 6px;
}

.stats-product__primary-delta--up { background: #d1fae5; color: #047857; }
.stats-product__primary-delta--down { background: #ffe4e6; color: #be123c; }
.stats-product__primary-delta--flat { background: var(--stats-surface-2); color: var(--stats-text-mute); }

.stats-product__spark {
    margin-top: 14px;
    height: 56px;
}

.stats-product__indicators {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--stats-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-product__indicator {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}

.stats-product__indicator-name {
    color: var(--stats-text-soft);
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-product__indicator-value {
    color: var(--stats-text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}

.stats-product__more {
    margin-top: auto;
    padding-top: 14px;
    font-size: 12px;
    color: var(--stats-text-mute);
    font-weight: 600;
}

/* ================ EMPTY ================ */
.stats-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--stats-surface);
    border: 1px dashed var(--stats-border);
    border-radius: var(--stats-radius);
    color: var(--stats-text-mute);
}

.stats-empty svg {
    fill: currentColor;
    opacity: .5;
    margin-bottom: 12px;
}

.stats-empty h3 {
    font-size: 16px;
    margin: 0 0 6px;
    color: var(--stats-text);
}

.stats-empty p { margin: 0; font-size: 14px; }

/* ================ RESPONSIVE ================ */
@media (max-width: 1100px) {
    .stats-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats-grid--two { grid-template-columns: 1fr; }
    .stats-products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats-filters {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "year      actions"
            "search    search"
            "category  category";
    }
    .stats-filters__group--search { align-self: stretch; }
    .stats-evolution__summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .stats-hero { padding: 48px 0 64px; }
    .stats-band__container,
    .stats-hero__container { padding: 0 18px; }
    .stats-kpis { grid-template-columns: 1fr; }
    .stats-products { grid-template-columns: 1fr; }
    .stats-filters { grid-template-columns: 1fr; padding: 18px; }
    .stats-section-title { font-size: 18px; flex-wrap: wrap; }
    .stats-section-title__hint { margin-left: 0; flex-basis: 100%; }
    .stats-evolution { padding: 18px; }
    .stats-evolution__canvas-wrap { height: 280px; }
    .stats-evolution__summary { grid-template-columns: 1fr 1fr; }
}

/* ================ ANIMAȚII GENERICE ================ */
.stats-fade-in { animation: stats-fade .3s ease both; }
@keyframes stats-fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
