/* =========================================================
   CONTRALORÍA DISTRITAL DE MEDELLÍN
   ACUERDOS INSTITUCIONALES · LISTADO SQL
   Capa exclusivamente visual.
   No modifica API, paginación, búsqueda ni descarga.
========================================================= */

:root {
    --ac-list-green-950: #052f25;
    --ac-list-green-900: #073e31;
    --ac-list-green-700: #126c4e;
    --ac-list-lime: #8bd936;
    --ac-list-white: #ffffff;
    --ac-list-ink: #163d31;
    --ac-list-text: #52645d;
    --ac-list-muted: #7a8983;
    --ac-list-line: #dce8e2;
    --ac-list-soft: #f7faf8;
    --ac-list-radius: 18px;
    --ac-list-shadow: 0 10px 30px rgba(5, 47, 37, 0.055);
    --ac-list-shadow-hover: 0 18px 42px rgba(5, 47, 37, 0.10);
    --ac-list-transition: 180ms ease;
}

/* =========================================================
   CABECERA / FILTROS
========================================================= */

.listado-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 22px;
    margin: 0 0 22px;
    padding: 18px 20px;
    border: 1px solid var(--ac-list-line);
    border-radius: var(--ac-list-radius);
    background:
        radial-gradient(
            circle at 92% 12%,
            rgba(139, 217, 54, 0.08),
            transparent 30%
        ),
        linear-gradient(
            135deg,
            #ffffff 0%,
            #fbfdfb 100%
        );
    box-shadow: var(--ac-list-shadow);
}

.listado-header .lh-info {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.listado-header .lh-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: var(--ac-list-white);
    background:
        linear-gradient(
            145deg,
            var(--ac-list-green-700),
            var(--ac-list-green-950)
        );
    box-shadow: 0 10px 20px rgba(5, 47, 37, 0.14);
}

.listado-header .lh-icon svg {
    width: 21px;
    height: 21px;
}

.listado-header .lh-title {
    margin: 0;
    color: var(--ac-list-ink);
    font-family: inherit;
    font-size: 1rem !important;
    font-weight: 780;
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.listado-header .lh-sub {
    margin: 4px 0 0;
    color: var(--ac-list-muted);
    font-size: 0.82rem !important;
    line-height: 1.35;
}

.listado-header .lh-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.listado-header .lh-select-wrap,
.listado-header .lh-search-wrap {
    position: relative;
    min-width: 0;
}

.listado-header .lh-select,
.listado-header .lh-search {
    height: 44px;
    margin: 0;
    border: 1px solid var(--ac-list-line);
    border-radius: 12px;
    color: var(--ac-list-ink);
    background-color: #ffffff;
    box-shadow: 0 4px 14px rgba(5, 47, 37, 0.035);
    font-family: inherit;
    font-size: 0.875rem !important;
    line-height: 1;
    transition:
        border-color var(--ac-list-transition),
        box-shadow var(--ac-list-transition),
        background-color var(--ac-list-transition);
}

.listado-header .lh-select {
    min-width: 154px;
    padding: 0 38px 0 14px;
    appearance: none;
    cursor: pointer;
    background-image:
        linear-gradient(
            45deg,
            transparent 50%,
            var(--ac-list-green-700) 50%
        ),
        linear-gradient(
            135deg,
            var(--ac-list-green-700) 50%,
            transparent 50%
        );
    background-position:
        calc(100% - 17px) 19px,
        calc(100% - 12px) 19px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.listado-header .lh-search {
    width: min(300px, 32vw);
    min-width: 210px;
    padding: 0 42px 0 15px;
}

.listado-header .lh-search-wrap::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 15px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--ac-list-green-700);
    border-radius: 50%;
    transform: translateY(-58%);
    pointer-events: none;
    opacity: 0.72;
}

.listado-header .lh-search-wrap::before {
    content: "";
    position: absolute;
    z-index: 1;
    right: 11px;
    top: calc(50% + 5px);
    width: 7px;
    height: 2px;
    border-radius: 99px;
    background: var(--ac-list-green-700);
    transform: rotate(45deg);
    pointer-events: none;
    opacity: 0.72;
}

.listado-header .lh-search::placeholder {
    color: #8a9993;
    opacity: 1;
}

.listado-header .lh-select:hover,
.listado-header .lh-search:hover {
    border-color: rgba(18, 108, 78, 0.42);
    background-color: #fdfefd;
}

.listado-header .lh-select:focus-visible,
.listado-header .lh-search:focus-visible {
    border-color: var(--ac-list-green-700);
    outline: 3px solid rgba(139, 217, 54, 0.34);
    outline-offset: 2px;
    box-shadow:
        0 0 0 1px rgba(18, 108, 78, 0.10),
        0 8px 20px rgba(5, 47, 37, 0.06);
}

/* =========================================================
   LISTADO
========================================================= */

.acuerdos-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 0;
}

.acuerdos-wrap .acuerdo-card {
    position: relative;
    display: grid;
    grid-template-columns:
        86px
        1px
        minmax(0, 1fr)
        minmax(142px, auto);
    align-items: center;
    gap: 0;
    min-width: 0;
    padding: 18px 20px 18px 22px;
    overflow: hidden;
    border: 1px solid var(--ac-list-line);
    border-radius: var(--ac-list-radius);
    color: var(--ac-list-text);
    background:
        linear-gradient(
            115deg,
            rgba(139, 217, 54, 0.035),
            transparent 22%
        ),
        var(--ac-list-white);
    box-shadow: var(--ac-list-shadow);
    isolation: isolate;
    transition:
        transform var(--ac-list-transition),
        border-color var(--ac-list-transition),
        box-shadow var(--ac-list-transition),
        background-color var(--ac-list-transition);
}

.acuerdos-wrap .acuerdo-card::before {
    content: "";
    position: absolute;
    z-index: 2;
    inset: 13px auto 13px 0;
    width: 4px;
    border-radius: 0 999px 999px 0;
    background:
        linear-gradient(
            180deg,
            var(--ac-list-lime),
            var(--ac-list-green-700)
        );
    opacity: 0.88;
}

@media (hover: hover) {
    .acuerdos-wrap .acuerdo-card:hover {
        transform: translateY(-2px);
        border-color: rgba(18, 108, 78, 0.28);
        box-shadow: var(--ac-list-shadow-hover);
    }
}

.acuerdos-wrap .ac-year {
    min-width: 0;
    padding-right: 18px;
    color: var(--ac-list-green-900);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    text-align: center;
}

.acuerdos-wrap .ac-divider {
    width: 1px;
    height: 100%;
    min-height: 64px;
    margin: 0;
    background:
        linear-gradient(
            to bottom,
            transparent,
            var(--ac-list-line) 18%,
            var(--ac-list-line) 82%,
            transparent
        );
}

.acuerdos-wrap .ac-body {
    min-width: 0;
    padding: 0 24px;
}

.acuerdos-wrap .ac-date {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 5px;
    color: var(--ac-list-green-700);
    font-size: 0.75rem;
    font-weight: 760;
    line-height: 1.35;
    letter-spacing: 0.02em;
}

.acuerdos-wrap .ac-date::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 50%;
    background: var(--ac-list-lime);
    box-shadow: 0 0 0 4px rgba(139, 217, 54, 0.12);
}

.acuerdos-wrap .ac-title {
    max-width: 100%;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--ac-list-ink);
    font-family: inherit;
    font-size: clamp(1rem, 1.1vw, 1.12rem) !important;
    font-weight: 760;
    line-height: 1.28 !important;
    letter-spacing: -0.018em;
}

.acuerdos-wrap .ac-desc {
    max-width: 82ch;
    margin: 7px 0 0;
    overflow-wrap: anywhere;
    color: var(--ac-list-text);
    font-size: 0.86rem !important;
    line-height: 1.55;
}

.acuerdos-wrap .ac-right {
    min-width: 142px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.acuerdos-wrap .ac-pdf-icon {
    position: relative;
    width: 42px;
    height: 46px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(18, 108, 78, 0.20);
    border-radius: 10px;
    color: var(--ac-list-green-900);
    background:
        linear-gradient(
            145deg,
            #ffffff,
            #f4f9f6
        );
}

.acuerdos-wrap .ac-pdf-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 13px;
    height: 13px;
    border-radius: 0 9px 0 5px;
    background:
        linear-gradient(
            135deg,
            var(--ac-list-lime),
            var(--ac-list-green-700)
        );
}

.acuerdos-wrap .ac-pdf-label {
    margin-top: 4px;
    color: var(--ac-list-green-900);
    font-size: 0.62rem;
    font-weight: 850;
    line-height: 1;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.acuerdos-wrap .ac-btn {
    min-height: 42px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid var(--ac-list-green-700);
    border-radius: 999px;
    color: var(--ac-list-white) !important;
    background:
        linear-gradient(
            135deg,
            var(--ac-list-green-700),
            var(--ac-list-green-900)
        );
    box-shadow: 0 8px 18px rgba(5, 47, 37, 0.12);
    font-family: inherit;
    font-size: 0.82rem !important;
    font-weight: 780;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none !important;
    cursor: pointer;
    transition:
        transform var(--ac-list-transition),
        box-shadow var(--ac-list-transition),
        background-color var(--ac-list-transition),
        border-color var(--ac-list-transition);
}

.acuerdos-wrap .ac-btn::before {
    content: "↓";
    font-size: 0.92rem;
    font-weight: 900;
    line-height: 1;
    transition: transform var(--ac-list-transition);
}

@media (hover: hover) {
    .acuerdos-wrap .ac-btn:not(.ac-btn--disabled):hover {
        transform: translateY(-1px);
        border-color: var(--ac-list-green-950);
        color: var(--ac-list-white) !important;
        background:
            linear-gradient(
                135deg,
                var(--ac-list-green-900),
                var(--ac-list-green-950)
            );
        box-shadow: 0 11px 24px rgba(5, 47, 37, 0.17);
    }

    .acuerdos-wrap .ac-btn:not(.ac-btn--disabled):hover::before {
        transform: translateY(2px);
    }
}

.acuerdos-wrap .ac-btn:focus-visible {
    outline: 3px solid var(--ac-list-lime);
    outline-offset: 3px;
}

.acuerdos-wrap .ac-btn--disabled {
    border-color: #d8e0dc;
    color: #718078 !important;
    background: #f1f4f2;
    box-shadow: none;
    cursor: default;
    opacity: 1;
}

.acuerdos-wrap .ac-btn--disabled::before {
    content: "—";
    color: #8d9993;
}

/* =========================================================
   PIE / ESTADOS
========================================================= */

.acuerdos-wrap .ac-footer {
    min-height: 28px;
    padding: 9px 4px 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ac-list-muted);
    font-size: 0.78rem;
    line-height: 1.4;
    text-align: center;
}

.acuerdos-wrap .ac-sql-status {
    margin: 0;
    padding: 24px;
    border: 1px dashed rgba(18, 108, 78, 0.28);
    border-radius: var(--ac-list-radius);
    color: var(--ac-list-text);
    background: var(--ac-list-soft);
    font-size: 0.9rem;
    line-height: 1.55;
    text-align: center;
}

/* =========================================================
   PAGINACIÓN
========================================================= */

.acuerdos-wrap .ac-paginador {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    padding: 13px 0 2px;
}

.acuerdos-wrap .ac-pag-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--ac-list-line);
    border-radius: 11px;
    color: var(--ac-list-text);
    background: #ffffff;
    box-shadow: 0 3px 10px rgba(5, 47, 37, 0.025);
    font-family: inherit;
    font-size: 0.82rem !important;
    font-weight: 720;
    line-height: 1;
    cursor: pointer;
    transition:
        transform var(--ac-list-transition),
        color var(--ac-list-transition),
        border-color var(--ac-list-transition),
        background-color var(--ac-list-transition),
        box-shadow var(--ac-list-transition);
}

@media (hover: hover) {
    .acuerdos-wrap .ac-pag-btn:hover:not(:disabled):not(.active) {
        transform: translateY(-1px);
        border-color: rgba(18, 108, 78, 0.45);
        color: var(--ac-list-green-900);
        background: var(--ac-list-soft);
        box-shadow: 0 7px 16px rgba(5, 47, 37, 0.06);
    }
}

.acuerdos-wrap .ac-pag-btn.active {
    border-color: var(--ac-list-green-900);
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            var(--ac-list-green-700),
            var(--ac-list-green-900)
        );
    box-shadow: 0 8px 18px rgba(5, 47, 37, 0.14);
}

.acuerdos-wrap .ac-pag-btn:disabled {
    color: #a2aca7;
    background: #f5f7f6;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.72;
}

.acuerdos-wrap .ac-pag-btn:focus-visible {
    outline: 3px solid rgba(139, 217, 54, 0.55);
    outline-offset: 2px;
}

.acuerdos-wrap .ac-pag-dots {
    min-width: 22px;
    color: #8d9993;
    font-size: 0.9rem;
    line-height: 40px;
    text-align: center;
}

/* =========================================================
   CARGA
========================================================= */

#paiLoading.pai-loading {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 251, 249, 0.92);
    backdrop-filter: blur(4px);
    opacity: 1;
    visibility: visible;
    transition:
        opacity 220ms ease,
        visibility 220ms ease;
}

#paiLoading.pai-loading.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#paiLoading .pai-loading__content {
    min-width: 190px;
    padding: 24px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ac-list-line);
    border-radius: 18px;
    color: var(--ac-list-ink);
    background: #ffffff;
    box-shadow: 0 22px 60px rgba(5, 47, 37, 0.14);
    text-align: center;
}

#paiLoading .pai-loader {
    width: 38px;
    height: 38px;
    display: inline-block;
    border: 3px solid rgba(18, 108, 78, 0.18);
    border-top-color: var(--ac-list-green-700);
    border-radius: 50%;
    animation: acAgreementSpin 800ms linear infinite;
}

#paiLoading .pai-loader::after {
    content: none;
}

#paiLoading .pai-loading__content strong {
    margin-top: 14px;
    color: var(--ac-list-green-900);
    font-size: 0.88rem;
    font-weight: 760;
}

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

/* =========================================================
   TABLET
========================================================= */

@media (max-width: 980px) {
    .listado-header {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .listado-header .lh-controls {
        justify-content: stretch;
    }

    .listado-header .lh-select-wrap {
        flex: 0 0 auto;
    }

    .listado-header .lh-search-wrap {
        flex: 1 1 auto;
    }

    .listado-header .lh-search {
        width: 100%;
        min-width: 0;
    }

    .acuerdos-wrap .acuerdo-card {
        grid-template-columns:
            76px
            1px
            minmax(0, 1fr);
        padding-right: 18px;
    }

    .acuerdos-wrap .ac-year {
        padding-right: 14px;
        font-size: 1.45rem;
    }

    .acuerdos-wrap .ac-body {
        padding-right: 0;
    }

    .acuerdos-wrap .ac-right {
        grid-column: 3;
        margin: 12px 0 0;
        justify-content: flex-start;
    }
}

/* =========================================================
   MÓVIL
========================================================= */

@media (max-width: 680px) {
    .listado-header {
        margin-bottom: 16px;
        padding: 16px;
    }

    .listado-header .lh-icon {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 12px;
    }

    .listado-header .lh-title {
        font-size: 0.95rem !important;
    }

    .listado-header .lh-sub {
        font-size: 0.78rem !important;
    }

    .listado-header .lh-controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .listado-header .lh-select-wrap,
    .listado-header .lh-search-wrap,
    .listado-header .lh-select,
    .listado-header .lh-search {
        width: 100%;
        min-width: 0;
    }

    .acuerdos-wrap {
        gap: 10px;
    }

    .acuerdos-wrap .acuerdo-card {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 16px 16px 15px 18px;
        border-radius: 15px;
    }

    .acuerdos-wrap .acuerdo-card::before {
        inset: 12px auto 12px 0;
    }

    .acuerdos-wrap .ac-year {
        justify-self: start;
        min-width: auto;
        margin-bottom: 10px;
        padding: 6px 10px;
        border: 1px solid rgba(18, 108, 78, 0.16);
        border-radius: 999px;
        color: var(--ac-list-green-900);
        background: rgba(139, 217, 54, 0.09);
        font-family: inherit;
        font-size: 0.75rem;
        font-weight: 820;
        letter-spacing: 0.05em;
    }

    .acuerdos-wrap .ac-divider {
        display: none;
    }

    .acuerdos-wrap .ac-body {
        padding: 0;
    }

    .acuerdos-wrap .ac-date {
        font-size: 0.72rem;
    }

    .acuerdos-wrap .ac-title {
        font-size: 1rem !important;
        line-height: 1.32 !important;
    }

    .acuerdos-wrap .ac-desc {
        margin-top: 6px;
        font-size: 0.84rem !important;
        line-height: 1.52;
    }

    .acuerdos-wrap .ac-right {
        grid-column: auto;
        width: 100%;
        min-width: 0;
        margin: 14px 0 0;
        padding-top: 12px;
        justify-content: flex-start;
        border-top: 1px solid rgba(220, 232, 226, 0.8);
    }

    .acuerdos-wrap .ac-pdf-icon {
        width: 38px;
        height: 42px;
        flex-basis: 38px;
    }

    .acuerdos-wrap .ac-btn {
        min-height: 44px;
        padding-right: 17px;
        padding-left: 17px;
    }

    .acuerdos-wrap .ac-pag-btn {
        min-width: 42px;
        height: 42px;
    }

    .acuerdos-wrap .ac-footer {
        font-size: 0.75rem;
    }
}

@media (max-width: 420px) {
    .listado-header .lh-info {
        align-items: flex-start;
    }

    .acuerdos-wrap .ac-right {
        align-items: stretch;
    }

    .acuerdos-wrap .ac-btn {
        flex: 1 1 auto;
    }
}

/* =========================================================
   REDUCCIÓN DE MOVIMIENTO
========================================================= */

@media (prefers-reduced-motion: reduce) {
    .listado-header *,
    .acuerdos-wrap *,
    #paiLoading * {
        animation-duration: 0.001ms;
        animation-iteration-count: 1;
        transition-duration: 0.001ms;
        scroll-behavior: auto;
    }

    .acuerdos-wrap .acuerdo-card:hover,
    .acuerdos-wrap .ac-btn:hover,
    .acuerdos-wrap .ac-pag-btn:hover {
        transform: none;
    }
}
