/* =====================================================================
   Indicador de carga global (overlay + botones + inputs de archivo)
   Usado por assets/js/loading.js en el sitio publico y en el panel.
   ===================================================================== */

:root {
    --load-verde: #16A34A;
    --load-selva: #0B6B3A;
}

/* ------------------------- Overlay de pantalla ------------------------ */
.app-loading {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 32, 22, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
}
.app-loading.is-visible {
    opacity: 1;
    visibility: visible;
}
/* Bloquea el scroll de fondo mientras se muestra. */
body.app-loading-open {
    overflow: hidden;
}

.app-loading__box {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    padding: 1.75rem 2rem;
    text-align: center;
    max-width: 22rem;
    width: 100%;
    transform: translateY(8px) scale(.97);
    transition: transform .18s ease;
}
.app-loading.is-visible .app-loading__box {
    transform: none;
}

/* ------------------------------ Spinner ------------------------------- */
.app-loading__spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto .9rem;
    border-radius: 50%;
    border: 4px solid rgba(22, 163, 74, .18);
    border-top-color: var(--load-verde);
    animation: app-spin .8s linear infinite;
}
@keyframes app-spin {
    to { transform: rotate(360deg); }
}

.app-loading__text {
    font-weight: 700;
    color: #1F2937;
    margin: 0;
    line-height: 1.35;
}
.app-loading__sub {
    font-size: .85rem;
    color: #6B7280;
    margin: .35rem 0 0;
    min-height: 1.1em;
}

/* ----------------- Barra indeterminada (progreso vivo) ---------------- */
.app-loading__bar {
    position: relative;
    height: 5px;
    margin-top: 1.1rem;
    border-radius: 999px;
    background: rgba(22, 163, 74, .15);
    overflow: hidden;
}
.app-loading__bar::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--load-verde), var(--load-selva));
    animation: app-slide 1.15s ease-in-out infinite;
}
@keyframes app-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}

/* --------------------- Botones en estado "cargando" -------------------- */
.is-loading {
    position: relative;
    pointer-events: none;
    opacity: .85;
}
.is-loading > .app-btn-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .45em;
    vertical-align: -.125em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: app-spin .7s linear infinite;
}

/* -------------------- Resumen del input de archivos -------------------- */
.app-file-summary {
    margin-top: .5rem;
    font-size: .85rem;
    color: #6B7280;
}
.app-file-summary.is-error {
    color: #B91C1C;
    font-weight: 600;
}
.app-file-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .5rem;
}
.app-file-thumbs img {
    width: 62px;
    height: 62px;
    object-fit: cover;
    border-radius: .45rem;
    border: 1px solid #e3e8e1;
}
.app-file-more {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border-radius: .45rem;
    border: 1px dashed #cbd5cb;
    font-size: .75rem;
    font-weight: 600;
    color: #6B7280;
}

/* ---------------- Contador de caracteres de un campo ------------------ */
.app-counter {
    margin-top: .25rem;
    font-size: .75rem;
    color: #9CA3AF;
    text-align: right;
}
.app-counter.is-near {
    color: #B45309;
    font-weight: 600;
}

/* ------------------------ Spinner sobre un mapa ------------------------ */
.app-map-wrap {
    position: relative;
}
.app-map-loading {
    position: absolute;
    inset: 0;
    z-index: 800; /* sobre las tiles (400) y marcadores (600) de Leaflet */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: rgba(248, 250, 245, .92);
    font-size: .85rem;
    color: #6B7280;
    transition: opacity .25s ease;
}
.app-map-loading.is-hidden {
    opacity: 0;
    pointer-events: none;
}
.app-map-loading .app-loading__spinner {
    width: 34px;
    height: 34px;
    border-width: 3px;
    margin: 0;
}

/* -------------------------- Accesibilidad ----------------------------- */
@media (prefers-reduced-motion: reduce) {
    .app-loading,
    .app-loading__box,
    .app-map-loading { transition: none; }
    .app-loading__spinner,
    .app-loading__bar::after,
    .is-loading > .app-btn-spinner { animation-duration: 2.4s; }
}
