/* ==========================================================
   ASVT Statistikarkiv 2.0
   Smarta beroende filter utan tomma resultatsidor
========================================================== */
.asvt-stats-archive {
    --asvt-black: #111111;
    --asvt-soft: #1d1d1b;
    --asvt-gold: #b9954b;
    --asvt-gold-dark: #80632e;
    --asvt-gold-light: #d4bd7d;
    --asvt-ivory: #f7f4ec;
    --asvt-sand: #eee8dc;
    --asvt-border: #d8d2c4;
    --asvt-white: #ffffff;

    position: relative;
    color: var(--asvt-black);
    font-family: Inter, "DM Sans", Arial, sans-serif;
}

.asvt-stats-main-title {
    margin: 0 0 28px;
    color: var(--asvt-black);
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: clamp(36px, 5vw, 58px);
    line-height: 1.1;
}

/* Filter */
.asvt-stats-filters {
    display: grid;
    grid-template-columns: minmax(230px, 1.4fr) repeat(4, minmax(145px, 1fr));
    gap: 14px;
    padding: 22px;
    background: var(--asvt-ivory);
    border: 1px solid var(--asvt-border);
    border-radius: 22px;
    box-shadow: 0 14px 38px rgba(17, 17, 17, 0.07);
}

.asvt-filter-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.asvt-filter-field label {
    color: var(--asvt-black);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.asvt-filter-field input,
.asvt-filter-field select {
    width: 100%;
    height: 50px;
    padding: 0 14px;
    color: var(--asvt-black);
    background: var(--asvt-white);
    border: 1px solid var(--asvt-border);
    border-radius: 12px;
    outline: none;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.asvt-filter-field input:focus,
.asvt-filter-field select:focus {
    border-color: var(--asvt-gold);
    box-shadow: 0 0 0 3px rgba(185, 149, 75, 0.16);
}

.asvt-filter-field input:disabled,
.asvt-filter-field select:disabled {
    opacity: 0.72;
    cursor: wait;
}

.asvt-filter-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.asvt-filter-submit,
.asvt-filter-reset {
    min-height: 46px;
    padding: 12px 22px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    transition: transform 0.22s ease, box-shadow 0.22s ease, color 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.asvt-filter-submit {
    color: var(--asvt-black);
    background: linear-gradient(135deg, var(--asvt-gold), var(--asvt-gold-light));
    border: 0;
    box-shadow: 0 8px 20px rgba(185, 149, 75, 0.24);
}

.asvt-filter-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(185, 149, 75, 0.32);
}

.asvt-filter-reset {
    color: var(--asvt-black);
    background: var(--asvt-white);
    border: 1px solid var(--asvt-border);
}

.asvt-filter-reset:hover:not(:disabled) {
    color: var(--asvt-gold-dark);
    border-color: var(--asvt-gold);
}

.asvt-filter-submit:disabled,
.asvt-filter-reset:disabled {
    cursor: wait;
    opacity: 0.7;
    transform: none;
}

/* Statusrad – automatisk justering visas diskret, aldrig som tom felsida */
.asvt-stats-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 24px;
    margin: 24px 2px 15px;
}

.asvt-stats-count {
    color: #615a4d;
    font-size: 14px;
    font-weight: 800;
}

.asvt-stats-note {
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    color: #5b4a28;
    background: rgba(185, 149, 75, 0.12);
    border: 1px solid rgba(185, 149, 75, 0.28);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.asvt-stats-note[hidden] {
    display: none !important;
}

/* Dokumentkort */
.asvt-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.asvt-stat-card {
    display: flex;
    flex-direction: column;
    min-height: 310px;
    padding: 24px;
    background: var(--asvt-white);
    border: 1px solid var(--asvt-border);
    border-radius: 22px;
    box-shadow: 0 12px 34px rgba(17, 17, 17, 0.07);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.asvt-stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--asvt-gold);
    box-shadow: 0 22px 52px rgba(17, 17, 17, 0.12);
}

.asvt-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    margin-bottom: 18px;
    color: var(--asvt-gold);
    background: var(--asvt-ivory);
    border-radius: 14px;
}

.asvt-stat-icon svg {
    width: 27px;
    height: 27px;
    fill: currentColor;
}

.asvt-stat-meta,
.asvt-single-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 13px;
}

.asvt-stat-meta span,
.asvt-single-facts span {
    display: inline-flex;
    padding: 6px 9px;
    color: #5d5547;
    background: var(--asvt-ivory);
    border: 1px solid var(--asvt-border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.asvt-stat-card h3 {
    margin: 0 0 12px;
    color: var(--asvt-black);
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 26px;
    line-height: 1.18;
}

.asvt-stat-card h3 a {
    color: var(--asvt-black);
    text-decoration: none;
}

.asvt-stat-card h3 a:hover {
    color: var(--asvt-gold-dark);
}

.asvt-stat-detail {
    margin: 0 0 20px;
    color: #5b5b55;
    font-size: 14px;
    line-height: 1.6;
}

.asvt-stat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.asvt-stat-actions a,
.asvt-primary-pdf-button,
.asvt-secondary-pdf-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none !important;
    transition: transform 0.22s ease, color 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.asvt-stat-view,
.asvt-primary-pdf-button {
    color: var(--asvt-white) !important;
    background: var(--asvt-black);
}

.asvt-stat-view:hover,
.asvt-primary-pdf-button:hover {
    color: var(--asvt-white) !important;
    background: #000000;
    transform: translateY(-2px);
}

.asvt-stat-pdf,
.asvt-secondary-pdf-button {
    color: var(--asvt-gold-dark) !important;
    background: transparent;
    border: 1px solid var(--asvt-gold);
}

.asvt-stat-pdf:hover,
.asvt-secondary-pdf-button:hover {
    color: var(--asvt-black) !important;
    background: var(--asvt-gold);
    transform: translateY(-2px);
}

/* Sidnumrering */
.asvt-stats-pagination nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 34px;
}

.asvt-stats-pagination button {
    min-width: 42px;
    height: 42px;
    color: var(--asvt-black);
    background: var(--asvt-white);
    border: 1px solid var(--asvt-border);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
}

.asvt-stats-pagination button:hover,
.asvt-stats-pagination button.is-current {
    color: var(--asvt-white);
    background: var(--asvt-black);
    border-color: var(--asvt-black);
}

/* Endast synlig för inloggad redaktör när importen inte är körd */
.asvt-stats-setup-note {
    padding: 22px;
    color: var(--asvt-black);
    background: var(--asvt-ivory);
    border: 1px solid var(--asvt-border);
    border-radius: 16px;
}

/* Laddning – befintliga dokument ligger kvar i stället för att ersättas */
.asvt-stats-archive.is-loading .asvt-stats-results,
.asvt-stats-archive.is-loading .asvt-stats-pagination {
    opacity: 0.45;
    pointer-events: none;
}

.asvt-stats-archive.is-loading::after {
    content: "";
    position: absolute;
    z-index: 4;
    top: 300px;
    left: 50%;
    width: 38px;
    height: 38px;
    margin-left: -19px;
    border: 3px solid rgba(185, 149, 75, 0.25);
    border-top-color: var(--asvt-gold);
    border-radius: 50%;
    animation: asvtSpin 0.8s linear infinite;
}

/* Enskilt statistikdokument */
.asvt-single-document {
    margin: 30px 0;
}

.asvt-single-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.asvt-pdf-embed {
    height: min(75vh, 900px);
    min-height: 560px;
    overflow: hidden;
    background: var(--asvt-ivory);
    border: 1px solid var(--asvt-border);
    border-radius: 18px;
    box-shadow: 0 14px 38px rgba(17, 17, 17, 0.08);
}

.asvt-pdf-embed iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

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

@media (max-width: 1100px) {
    .asvt-stats-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .asvt-filter-search {
        grid-column: 1 / -1;
    }

    .asvt-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .asvt-stats-filters,
    .asvt-stats-grid {
        grid-template-columns: 1fr;
    }

    .asvt-filter-search,
    .asvt-filter-actions {
        grid-column: auto;
    }

    .asvt-filter-actions {
        justify-content: stretch;
    }

    .asvt-filter-actions button {
        flex: 1;
    }

    .asvt-stats-status {
        align-items: flex-start;
        flex-direction: column;
    }

    .asvt-stats-note {
        border-radius: 12px;
    }

    .asvt-stat-card {
        min-height: auto;
    }

    .asvt-pdf-embed {
        min-height: 460px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .asvt-stats-archive *,
    .asvt-stats-archive *::before,
    .asvt-stats-archive *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
