/* ═══════════════════════════════════════════════════════════
   SAYEP — base.css
   Estilos compartidos por TODOS los blueprints (sayep, sayep2,
   luminarias, veredas, exportador) y por las páginas core
   (home, diagnóstico de fotos, etc).
   No incluye: modal de fotos (ver modal.css), login/home/cambiar
   contraseña (ver auth.css), ni panel admin (ver admin.css).
   ═══════════════════════════════════════════════════════════ */

/* ── VARIABLES ── */
:root {
    --azul:         #005D9D;
    --azul-osc:     #003f6b;
    --azul-suave:   #e8f2fb;
    --verde:        #009640;
    --verde-suave:  #e6f5ec;
    --gris-bg:      #f4f6f9;
    --gris-borde:   #dde3ea;
    --texto:        #1a2332;
    --texto-2:      #4a5568;
    --blanco:       #ffffff;
    --rojo:         #ed0219;
    --naranja:      #fd7e14;
    --radio:        10px;
    --sombra:       0 2px 12px rgba(0,93,157,.10);
    --sombra-hover: 0 6px 24px rgba(0,93,157,.18);
}

/* ── RESET ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--gris-bg);
    color: var(--texto);
    min-height: 100vh;
}

/* ── BANNER DE ENTORNO DE TESTING ── */
.env-banner {
    background: var(--naranja);
    color: white;
    text-align: center;
    padding: 6px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .5px;
}

/* ── HEADER ── */
.header {
    background: var(--azul);
    border-bottom: 4px solid var(--verde);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 68px;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 2px 16px rgba(0,0,0,.18);
}
.header-logo {
    width: 44px; height: 44px;
    background: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 6px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-logo img { width: 100%; height: auto; }
.header-title {
    font-size: 20px;
    font-weight: 700;
    color: white;
    letter-spacing: -.3px;
}
.header-title span, .header-title-sub {
    font-weight: 400;
    opacity: .75;
    font-size: 14px;
    display: block;
    margin-top: 1px;
}
/* Contenedor de acciones a la derecha del header (badge + links) */
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-badge {
    background: rgba(255,255,255,.15);
    color: white;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    white-space: nowrap;
}
.header-back {
    background: rgba(255,255,255,.15);
    color: white;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .2s;
}
.header-back:hover { background: rgba(255,255,255,.28); }

/* ── LAYOUT ── */
.main {
    max-width: 99%;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ── STATS BAR ── */
.stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stat-card {
    background: white;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--sombra);
    flex: 1;
    min-width: 160px;
}
.stat-icon {
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-icon.azul    { background: var(--azul-suave); }
.stat-icon.verde   { background: var(--verde-suave); }
.stat-icon.naranja { background: #fff3e0; }
.stat-icon.rojo    { background: #fdecea; }
.stat-num {
    font-size: 22px;
    font-weight: 700;
    color: var(--azul);
    font-family: 'DM Mono', monospace;
    line-height: 1;
}
.stat-num.rojo  { color: var(--rojo); }
.stat-num.verde { color: var(--verde); }
.stat-label {
    font-size: 12px;
    color: var(--texto-2);
    margin-top: 2px;
}

/* ── MAPA ── */
.mapa-section {
    background: white;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    overflow: hidden;
    box-shadow: var(--sombra);
    margin-bottom: 20px;
}
.mapa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gris-borde);
    background: var(--azul-suave);
}
.mapa-header.rojo { background: #fdecea; }
.mapa-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--azul);
    font-size: 15px;
}
.mapa-header.rojo .mapa-header-left { color: var(--rojo); }
.mapa-header-left span { font-weight: 400; font-size: 13px; opacity: .75; }
.btn-toggle-mapa {
    background: var(--azul);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: background .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-toggle-mapa:hover { background: var(--azul-osc); }
.mapa-wrap {
    height: 620px;
    display: none;
}
.mapa-wrap.visible { display: block; }
#mapa { width: 100%; height: 100%; }
#mapa.mapa-fija { height: 440px; }

/* ── FILTROS ── */
.filtros-section {
    background: white;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: var(--sombra);
}
.filtros-titulo {
    font-size: 13px;
    font-weight: 600;
    color: var(--texto-2);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 14px;
}
.filtros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}
.filtro-item label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--azul);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.filtro-item input,
.filtro-item select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gris-borde);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    color: var(--texto);
    background: var(--gris-bg);
    transition: border-color .2s, box-shadow .2s;
}
.filtro-item input:focus,
.filtro-item select:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(0,93,157,.1);
    background: white;
}
/* Item de filtro alineado al final de la fila (ej: botón limpiar) */
.filtro-item.align-end { display: flex; align-items: flex-end; }
/* Item de filtro que no crece dentro del grid (checks) */
.filtro-item.no-grow { flex: none; }
/* Conteo en header del mapa */
.mapa-conteo {
    font-weight: 400;
    font-size: 13px;
    opacity: .75;
}
/* Metadato de card (ID, fecha) generado por JS */
.card-id-meta {
    font-size: 11px;
    color: var(--texto-2);
    margin-top: 6px;
}
.card-fecha-meta {
    font-size: 11px;
    color: var(--texto-2);
    margin-top: 2px;
}
/* Wrapper de interv-chips dentro del modal */
.interv-chips-wrap { margin-top: 6px; }

/* btn-export: no rompe línea */
.btn-export { white-space: nowrap; }

/* Separador entre secciones de filtros */
.filtros-divisor {
    border: none;
    border-top: 1px solid var(--gris-borde);
    margin: 16px 0 14px;
}
/* Fila de checkboxes de filtro */
.filtros-checks-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}
.btn-limpiar {
    background: var(--rojo);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: background .2s;
    white-space: nowrap;
}
.btn-limpiar:hover { background: #b02a37; }

/* ── TAGS FILTROS ACTIVOS ── */
.filtros-activos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.tag-filtro {
    background: var(--azul-suave);
    color: var(--azul);
    border: 1px solid #b8d4ee;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tag-filtro button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--azul);
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

/* ── BARRA RESULTADOS ── */
.resultados-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.resultados-bar.con-margen { margin-top: 20px; }
.resultados-texto {
    font-size: 14px;
    color: var(--texto-2);
}
.resultados-texto strong { color: var(--azul); }
.paginacion {
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-pag {
    background: white;
    border: 1px solid var(--gris-borde);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--azul);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all .2s;
}
.btn-pag:hover:not(:disabled) {
    background: var(--azul);
    color: white;
    border-color: var(--azul);
}
.btn-pag:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.pag-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--texto-2);
    font-family: 'DM Mono', monospace;
    min-width: 110px;
    text-align: center;
}

/* ── GALERÍA GRID ── */
.galeria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    min-height: 200px;
}

/* ── CARD ── */
.card {
    background: white;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--sombra);
    transition: transform .22s ease, box-shadow .22s ease;
    animation: fadeUp .35s ease both;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--sombra-hover);
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.card-img-wrap {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--gris-bg);
    position: relative;
}
.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-orientation: from-image;
    transition: transform .3s ease;
}
.card:hover .card-img { transform: scale(1.04); }
.card-no-foto {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 13px;
    gap: 6px;
}
.card-no-foto-icon { font-size: 36px; opacity: .4; }
.card-body { padding: 12px 14px 14px; }
.card-tipo {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--azul);
    margin-bottom: 5px;
}
.card-ubicacion {
    font-size: 12px;
    color: var(--texto-2);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-verde    { background: var(--verde-suave); color: var(--verde); }
.badge-rojo     { background: #fdecea; color: #c0392b; }
.badge-azul     { background: var(--azul-suave); color: var(--azul); }
.badge-naranja  { background: #fff3e0; color: #e65100; }
.badge-gris     { background: #f0f0f0; color: #555; }
.badge-pintura  { background: var(--azul-suave); color: var(--azul); border: 1px solid #b3d4f0; }
.badge-limpieza { background: var(--verde-suave); color: var(--verde); border: 1px solid #99dbb0; }
.badge-reposicion { background: #fff3e0; color: #c45100; border: 1px solid #ffc87a; }
.badge-recambio { background: #fdecea; color: #c0392b; border: 1px solid #f5aaaa; }

/* ── CHECKBOXES EN FILTROS ── */
.filtro-checks-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--azul);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.check-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.check-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid var(--gris-borde);
    background: var(--gris-bg);
    transition: border-color .15s, background .15s;
    user-select: none;
}
.check-item:hover { border-color: var(--azul); background: var(--azul-suave); }
.check-item input[type="checkbox"] {
    width: 14px; height: 14px;
    accent-color: var(--azul);
    cursor: pointer;
    flex-shrink: 0;
}
.check-item.necesita {
    border-color: #f5aaaa;
    color: #c0392b;
    background: #fdecea;
}
.check-item.necesita:hover { border-color: #c0392b; background: #f8d7da; }
.check-item.necesita input { accent-color: #c0392b; }

/* ── LOADING ── */
.loading-overlay {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--azul);
}
.loading-overlay.visible { display: block; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--gris-borde);
    border-top-color: var(--azul);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ── */
.empty-state {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--texto-2);
}
.empty-state.visible { display: block; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── CAJA DE ERROR (carga de datos) ── */
.error-box {
    padding: 40px;
    color: var(--rojo);
}

/* ── LEAFLET CUSTOM ── */
.custom-marker-dot {
    background: var(--azul);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.custom-marker-dot.intervencion { background: var(--rojo); }
.marker-faltante {
    background: var(--rojo);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* ── TABLA (diagnóstico de fotos / export) ── */
.tabla-section {
    background: white;
    border: 1px solid var(--gris-borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    overflow: hidden;
}
.tabla-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gris-borde);
    background: var(--azul-suave);
}
.tabla-header-left {
    font-weight: 600;
    color: var(--azul);
    font-size: 15px;
}
.btn-export {
    background: var(--verde);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: background .2s;
}
.btn-export:hover { background: #007a34; }
.tabla-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    background: var(--gris-bg);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--texto-2);
    border-bottom: 1px solid var(--gris-borde);
    white-space: nowrap;
}
tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid #f4f4f4;
    vertical-align: top;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
tbody tr:hover { background: var(--gris-bg); }
.foto-path {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--rojo);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.sin-coords {
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

/* ── ALERTA ── */
.alerta-info {
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: var(--radio);
    padding: 14px 18px;
    font-size: 13px;
    color: #7a5200;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── ALERTS / FORM-GROUP genéricos (login, cambiar contraseña, admin) ── */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
}
.alert-danger  { background: #fdecea; color: #c0392b; border: 1px solid #f5aaaa; }
.alert-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffd54f; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--azul);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--gris-borde);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    color: var(--texto);
    background: var(--gris-bg);
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(0,93,157,.1);
    background: white;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .header-badge { display: none; }
    .header-title span, .header-title-sub { display: none; }
    .galeria-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .filtros-checks-row {
        flex-direction: column !important;
        gap: 12px !important;
    }
}

@media (max-width: 480px) {
    .galeria-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .filtros-grid { grid-template-columns: 1fr; }
    .check-items { flex-wrap: wrap; }
}
