/* =========================================================================
   Módulo Afiliación - CONSIVE
   Usa las variables del tema Consive con valores por defecto por si se usa en otro tema.
   ========================================================================= */

.af,
.afa {
    --af-red: var(--cs-red, #d2232a);
    --af-red-dark: var(--cs-red-dark, #a3161c);
    --af-red-soft: var(--cs-red-soft, #fdecec);
    --af-ink: var(--cs-ink, #1d1d21);
    --af-text: var(--cs-text, #3d3e42);
    --af-grey: var(--cs-grey, #6d6e71);
    --af-line: #dcd6d5;
    --af-line-soft: var(--cs-line, #ece7e6);
    --af-bg-soft: var(--cs-bg-soft, #f8f5f4);
    --af-ok: #1f8a4c;
    --af-ok-soft: #e6f4ec;
    --af-warn: #a86400;
    --af-radius: 12px;
    --af-ease: cubic-bezier(.22, .61, .36, 1);
    --af-font-title: var(--cs-font-title, Georgia, serif);
    --af-font-text: var(--cs-font-text, 'Segoe UI', system-ui, sans-serif);

    font-family: var(--af-font-text);
    color: var(--af-text);
}

.af {
    container-type: inline-size;
    scroll-margin-top: 110px;
}

.af *,
.afa * {
    box-sizing: border-box;
}

/* ---------- Barra de administración ---------- */
.af-adminbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    margin-bottom: 26px;
    padding: 12px 16px;
    border-radius: var(--af-radius);
    background: var(--af-bg-soft);
    border: 1px solid var(--af-line-soft);
    font-size: 14px;
}

.af-adminbar__info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.af-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--af-red);
    box-shadow: 0 0 0 4px var(--af-red-soft);
}

.af .af-adminbar__link {
    margin-left: auto;
    font-weight: 700;
    color: var(--af-red);
    text-decoration: none;
}

.af-adminbar__warn {
    flex-basis: 100%;
    font-size: 13px;
    color: var(--af-warn);
}

/* ---------- Cabecera y pasos ---------- */
.af-head {
    margin-bottom: 22px;
}

.af .af-head__title {
    margin: 0 0 6px;
    font-family: var(--af-font-title);
    font-size: 28px;
    font-weight: 400;
    color: var(--af-ink);
}

.af .af-head__sub {
    margin: 0;
    font-size: 14px;
    color: var(--af-grey);
}

.af-req {
    color: var(--af-red);
}

.af-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: none;
}

.af-steps__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--af-grey);
    cursor: default;
    transition: color .3s;
}

.af-steps__item.is-done {
    cursor: pointer;
}

.af-steps__num {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--af-line);
    background: #fff;
    font-size: 14px;
    transition: background-color .3s, border-color .3s, color .3s, transform .3s var(--af-ease);
}

.af-steps__item.is-current {
    color: var(--af-ink);
}

.af-steps__item.is-current .af-steps__num {
    border-color: var(--af-red);
    background: var(--af-red);
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 6px 16px -6px rgba(210, 35, 42, .7);
}

.af-steps__item.is-done .af-steps__num {
    border-color: var(--af-red);
    color: var(--af-red);
}

.af-progress {
    height: 4px;
    margin: 16px 0 26px;
    border-radius: 4px;
    background: var(--af-line-soft);
    overflow: hidden;
}

.af-progress__bar {
    display: block;
    width: 25%;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--af-red-dark), var(--af-red));
    transition: width .5s var(--af-ease);
}

/* ---------- Alertas ---------- */
.af-alert {
    margin-bottom: 22px;
    padding: 14px 18px;
    border-radius: var(--af-radius);
    border-left: 4px solid var(--af-red);
    background: var(--af-red-soft);
    color: var(--af-red-dark);
    font-size: 14px;
}

.af-alert ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

/* ---------- Pasos ---------- */
.af-step {
    display: none;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.af-step.is-active {
    display: block;
    animation: af-in .45s var(--af-ease);
}

@keyframes af-in {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: none; }
}

.af .af-step__title {
    display: block;
    width: 100%;
    margin: 0 0 18px;
    padding: 0;
    border: 0;
    font-family: var(--af-font-title);
    font-size: 21px;
    line-height: 1.3;
    color: var(--af-ink);
}

.af .af-subtitle {
    margin: 8px 0 -2px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--af-red);
}

.af .af-note {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--af-grey);
}

.af .af-note--small {
    margin: 22px 0 0;
    padding: 14px 16px;
    border-radius: var(--af-radius);
    background: var(--af-bg-soft);
    font-size: 12px;
    line-height: 1.55;
}

/* ---------- Rejilla ---------- */
.af-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px 14px;
}

.af-col-12 { grid-column: span 12; }
.af-col-8  { grid-column: span 8; }
.af-col-6  { grid-column: span 6; }
.af-col-5  { grid-column: span 5; }
.af-col-4  { grid-column: span 4; }
.af-col-3  { grid-column: span 3; }
.af-col-2  { grid-column: span 2; }

/* Pantallas estrechas: una columna salvo los campos cortos (Nº, portal, escalera, CP) */
@container (max-width: 420px) {
    .af-col-6, .af-col-5, .af-sm-12 { grid-column: span 12; }
}

/* ---------- Campos con etiqueta flotante ---------- */
.af-field {
    position: relative;
}

.af .af-input {
    display: block;
    width: 100%;
    height: 56px;
    margin: 0;
    padding: 22px 14px 8px;
    border: 1.5px solid var(--af-line);
    border-radius: var(--af-radius);
    background: #fff;
    font-family: var(--af-font-text);
    font-size: 16px;
    color: var(--af-ink);
    box-shadow: none;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.af .af-input:hover {
    border-color: #c4bcbb;
}

.af .af-input:focus {
    border-color: var(--af-red);
    box-shadow: 0 0 0 4px rgba(210, 35, 42, .12);
}

.af-label {
    position: absolute;
    top: 18px;
    left: 15px;
    right: 15px;
    margin: 0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--af-grey);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transform-origin: left top;
    transition: transform .2s var(--af-ease), color .2s;
}

.af-input:focus + .af-label,
.af-input:not(:placeholder-shown) + .af-label {
    transform: translateY(-10px) scale(.78);
    color: var(--af-red);
    font-weight: 700;
}

.af-input:not(:focus):not(:placeholder-shown) + .af-label {
    color: var(--af-grey);
}

.af-upper {
    text-transform: uppercase;
}

.af-mono {
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
}

.af-error {
    display: block;
    min-height: 0;
    margin-top: 4px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--af-red);
}

.af-error:empty {
    display: none;
}

.af-field.is-invalid .af-input {
    border-color: var(--af-red);
    background: #fffafa;
}

.af-field.is-valid .af-input {
    border-color: #9ccfb2;
}

/* ---------- Opciones tipo "chip" ---------- */
.af-group__label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--af-ink);
}

.af-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.af .af-chip {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.af-chip input,
.af-segment__opt input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.af-chip span {
    display: inline-block;
    padding: 10px 18px;
    border: 1.5px solid var(--af-line);
    border-radius: 999px;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    color: var(--af-text);
    transition: background-color .2s, border-color .2s, color .2s, transform .2s var(--af-ease);
}

.af-chip:hover span {
    border-color: var(--af-red);
}

.af-chip input:focus-visible + span,
.af-segment__opt input:focus-visible + span {
    box-shadow: 0 0 0 4px rgba(210, 35, 42, .18);
}

.af-chip input:checked + span {
    border-color: var(--af-red);
    background: var(--af-red);
    color: #fff;
    transform: translateY(-1px);
}

.af-group.is-invalid .af-chip span {
    border-color: #f0b4b6;
}

/* Bloque condicional (centro de trabajo) */
.af-cond {
    overflow: hidden;
}

.af-cond.is-hidden {
    display: none;
}

.af-cond:not(.is-hidden) {
    animation: af-in .4s var(--af-ease);
}

/* ---------- Consentimientos (Acepto / No acepto) ---------- */
.af-consent {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 12px;
    padding: 16px 18px;
    border: 1.5px solid var(--af-line-soft);
    border-radius: var(--af-radius);
    background: #fff;
    transition: border-color .2s;
}

.af-consent.is-invalid {
    border-color: #f0b4b6;
}

.af .af-consent__text {
    flex: 1 1 260px;
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
}

.af-consent .af-error {
    flex-basis: 100%;
    margin-top: 0;
}

.af-segment {
    display: inline-flex;
    padding: 4px;
    border-radius: 999px;
    background: var(--af-bg-soft);
}

.af .af-segment__opt {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.af-segment__opt span {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    color: var(--af-grey);
    transition: background-color .2s, color .2s, box-shadow .2s;
}

.af-segment__opt--yes input:checked + span {
    background: var(--af-ok);
    color: #fff;
    box-shadow: 0 4px 12px -4px rgba(31, 138, 76, .6);
}

.af-segment__opt--no input:checked + span {
    background: #fff;
    color: var(--af-ink);
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, .2);
}

/* ---------- Interruptor "usar mis datos" ---------- */
.af .af-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 18px;
    padding: 14px 16px;
    border-radius: var(--af-radius);
    background: var(--af-bg-soft);
    font-size: 14px;
    font-weight: 700;
    color: var(--af-ink);
    cursor: pointer;
}

.af-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.af-switch__track {
    position: relative;
    flex-shrink: 0;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #cfc8c7;
    transition: background-color .25s;
}

.af-switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .25s var(--af-ease);
}

.af-switch input:checked + .af-switch__track {
    background: var(--af-red);
}

.af-switch input:checked + .af-switch__track .af-switch__thumb {
    transform: translateX(18px);
}

.af-switch input:focus-visible + .af-switch__track {
    box-shadow: 0 0 0 4px rgba(210, 35, 42, .18);
}

/* ---------- Navegación y botones ---------- */
.af-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--af-line-soft);
}

.af-nav__count {
    margin: 0 auto;
    font-size: 13px;
    font-weight: 700;
    color: var(--af-grey);
}

.af-nav [data-prev][hidden] + .af-nav__count {
    margin-left: 0;
}

.af .af-btn,
.afa .af-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    margin: 0;
    padding: 12px 26px;
    border: 2px solid transparent;
    border-radius: 999px;
    font-family: var(--af-font-text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .2s, border-color .2s, color .2s, transform .2s var(--af-ease), box-shadow .2s;
}

.af .af-btn[hidden],
.afa .af-btn[hidden] {
    display: none;
}

.af .af-btn:hover,
.afa .af-btn:hover {
    transform: translateY(-1px);
}

.af .af-btn--primary,
.afa .af-btn--primary {
    background: var(--af-red);
    color: #fff;
    box-shadow: 0 10px 22px -10px rgba(210, 35, 42, .75);
}

.af .af-btn--primary:hover,
.afa .af-btn--primary:hover {
    background: var(--af-red-dark);
    color: #fff;
}

.af .af-btn--ghost,
.afa .af-btn--ghost {
    background: transparent;
    border-color: var(--af-line);
    color: var(--af-ink);
}

.af .af-btn--ghost:hover,
.afa .af-btn--ghost:hover {
    border-color: var(--af-ink);
    color: var(--af-ink);
}

.af-btn--submit.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.af-btn--submit.is-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: af-spin .7s linear infinite;
}

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

@container (max-width: 420px) {
    .af-steps__txt { display: none; }
    .af-nav__count { display: none; }
    .af .af-btn { padding: 12px 20px; }
}

/* ---------- reCAPTCHA: se oculta el distintivo flotante y se muestra el aviso legal ---------- */
.grecaptcha-badge {
    visibility: hidden;
}

.af .af-recaptcha {
    margin: 16px 0 0;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--af-grey);
}

.af .af-recaptcha a {
    color: inherit;
    text-decoration: underline;
}

/* Campo trampa */
.af-hp {
    position: absolute !important;
    left: -10000px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------- Solicitud enviada ---------- */
.af-done {
    padding: 20px 0;
    text-align: center;
    animation: af-in .5s var(--af-ease);
}

.af-done__icon svg {
    width: 84px;
    height: 84px;
    margin-bottom: 16px;
}

.af-done__icon circle {
    fill: none;
    stroke: var(--af-ok);
    stroke-width: 2.5;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: af-draw .7s var(--af-ease) forwards;
}

.af-done__icon path {
    fill: none;
    stroke: var(--af-ok);
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: af-draw .45s .55s var(--af-ease) forwards;
}

@keyframes af-draw {
    to { stroke-dashoffset: 0; }
}

.af .af-done__title {
    margin: 0 0 10px;
    font-family: var(--af-font-title);
    font-size: 28px;
    color: var(--af-ink);
}

.af .af-done__thanks {
    margin: 0;
    font-weight: 700;
    color: var(--af-red);
}

/* =========================================================================
   ADMINISTRACIÓN DE SOLICITUDES
   ========================================================================= */
.afa {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 0 60px;
}

.afa-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}

.afa .afa-head__title {
    margin: 0;
    font-family: var(--af-font-title);
    font-size: 32px;
    font-weight: 400;
    color: var(--af-ink);
}

.afa .afa-back {
    font-size: 14px;
    font-weight: 700;
    color: var(--af-red);
    text-decoration: none;
}

/* Contadores por estado */
.afa-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.afa-stat {
    padding: 16px 18px;
    border-radius: var(--af-radius);
    background: #fff;
    border: 1px solid var(--af-line-soft);
}

.afa-stat__num {
    display: block;
    font-family: var(--af-font-title);
    font-size: 30px;
    line-height: 1;
    color: var(--af-ink);
}

.afa-stat__txt {
    font-size: 13px;
    font-weight: 700;
    color: var(--af-grey);
}

.afa-stat--pend {
    border-color: transparent;
    background: var(--af-red);
}

.afa-stat--pend .afa-stat__num,
.afa-stat--pend .afa-stat__txt {
    color: #fff;
}

/* Barra de filtros */
.afa-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.afa .afa-input,
.afa .afa-select,
.afa .afa-textarea {
    height: 46px;
    margin: 0;
    padding: 0 14px;
    border: 1.5px solid var(--af-line);
    border-radius: 10px;
    background: #fff;
    font-family: var(--af-font-text);
    font-size: 15px;
    color: var(--af-ink);
    box-shadow: none;
}

.afa .afa-input {
    flex: 1 1 260px;
}

.afa .afa-textarea {
    width: 100%;
    height: auto;
    min-height: 110px;
    padding: 12px 14px;
    resize: vertical;
}

.afa .afa-input:focus,
.afa .afa-select:focus,
.afa .afa-textarea:focus {
    outline: none;
    border-color: var(--af-red);
    box-shadow: 0 0 0 4px rgba(210, 35, 42, .12);
}

.afa .af-btn--sm {
    min-height: 46px;
    padding: 10px 20px;
    font-size: 14px;
}

/* Tabla */
.afa-table-wrap {
    overflow-x: auto;
    border-radius: var(--af-radius);
    border: 1px solid var(--af-line-soft);
    background: #fff;
}

.afa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.afa-table th {
    padding: 14px 16px;
    background: var(--af-bg-soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: left;
    color: var(--af-grey);
    white-space: nowrap;
}

.afa-table td {
    padding: 14px 16px;
    border-top: 1px solid var(--af-line-soft);
    vertical-align: middle;
}

.afa-table tbody tr {
    transition: background-color .15s;
}

.afa-table tbody tr:hover {
    background: #fdf9f9;
}

.afa-table .afa-name {
    font-weight: 700;
    color: var(--af-ink);
}

.afa-table .afa-sub {
    display: block;
    font-size: 12.5px;
    color: var(--af-grey);
}

.afa .afa-link {
    font-weight: 700;
    color: var(--af-red);
    text-decoration: none;
    white-space: nowrap;
}

.afa-empty {
    padding: 50px 20px;
    text-align: center;
    color: var(--af-grey);
}

/* Estados */
.afa-badge {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.afa-badge--0 { background: var(--af-red-soft); color: var(--af-red-dark); }
.afa-badge--1 { background: #fff3dc; color: var(--af-warn); }
.afa-badge--2 { background: var(--af-ok-soft); color: var(--af-ok); }
.afa-badge--3 { background: #eeeeef; color: var(--af-grey); }

/* Paginación */
.afa-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 18px;
    font-size: 14px;
    color: var(--af-grey);
}

.afa .afa-pager .aspNetDisabled {
    opacity: .4;
    pointer-events: none;
}

/* Ficha */
.afa-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 22px;
    align-items: start;
}

.afa-card {
    margin-bottom: 18px;
    padding: 22px 24px;
    border-radius: var(--af-radius);
    border: 1px solid var(--af-line-soft);
    background: #fff;
}

.afa .afa-card__title {
    margin: 0 0 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--af-red);
}

.afa-dl {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px 20px;
    margin: 0;
}

.afa-dl div {
    min-width: 0;
}

.afa-dl dt {
    margin: 0 0 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--af-grey);
}

.afa-dl dd {
    margin: 0;
    font-size: 15px;
    color: var(--af-ink);
    overflow-wrap: anywhere;
}

.afa-yes { color: var(--af-ok); font-weight: 700; }
.afa-no { color: var(--af-grey); font-weight: 700; }

.afa-side {
    position: sticky;
    top: 100px;
}

.afa-side .afa-select {
    width: 100%;
    margin-bottom: 14px;
}

.afa-side .afa-label {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--af-ink);
}

.afa-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.afa .afa-delete {
    background: none;
    border: 0;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--af-red);
    cursor: pointer;
    text-decoration: underline;
}

.afa-meta {
    margin: 16px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--af-grey);
}

.afa-msg {
    margin-bottom: 18px;
    padding: 12px 16px;
    border-radius: var(--af-radius);
    background: var(--af-ok-soft);
    color: var(--af-ok);
    font-size: 14px;
    font-weight: 700;
}

@media (max-width: 900px) {
    .afa-detail {
        grid-template-columns: 1fr;
    }

    .afa-side {
        position: static;
    }
}

@media (prefers-reduced-motion: reduce) {
    .af *,
    .afa * {
        animation: none !important;
        transition: none !important;
    }

    .af-done__icon circle,
    .af-done__icon path {
        stroke-dashoffset: 0;
    }
}
