/* --- Estilos para la página de Ubicaciones --- */
.ubicaciones-section {
    padding-top: 3rem;
    padding-bottom: 5rem;
    flex-grow: 1;
}

.ubicaciones-header {
    text-align: center;
    margin-bottom: 2rem;
}

.ubicaciones-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 0.5rem;
}

.ubicaciones-address {
    font-size: 1.1rem;
    color: var(--md-sys-color-on-surface-variant);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ubicaciones-address .material-symbols-outlined {
    font-size: 1.5rem;
    color: var(--md-extended-color-ubicaciones-color);
}

.map-container {
    height: 500px;
    width: 100%;
    border-radius: 1rem;
    z-index: 1;
    background-color: var(--md-sys-color-surface-variant);
}

/* Contenedor para las atribuciones del mapa */
.map-attributions {
    text-align: right;
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    padding: 0.5rem 0.25rem;
}

.map-attributions a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}

.map-attributions a:hover {
    text-decoration: underline;
}

.info-cards-section {
    padding-top: 3.5rem;
}

.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.75rem;
}

/* --- Material 3 Location Card Styles --- */
.location-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 1.25rem;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    /* Elevation via surface tone change, no shadow/transform */
    transition: background-color 0.2s ease;
    border: 1px solid transparent;
}

.location-card:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.location-card-media {
    height: 180px;
    width: 100%;
    background-color: var(--md-sys-color-surface-container-highest);
    position: relative;
}

.location-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Icon Placeholder in Card Media */
.location-card-icon-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-primary);
}

.location-card-icon-placeholder .material-symbols-outlined {
    font-size: 5rem;
}

/* Variant for emergency (SAPU) */
.location-card-icon-placeholder.emergency {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.location-card-content {
    padding: 1.25rem 1.25rem 0.5rem 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.location-card-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

.location-card-body {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1rem;
    line-height: 1.6;
    flex-grow: 1;
}

.location-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* Info row for items without profile (e.g. SAPU) */
.location-info-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--md-sys-color-on-surface);
}

.location-info-row .material-symbols-outlined {
    font-size: 1.25rem;
    color: var(--md-sys-color-primary);
    margin-top: 2px;
}

.location-card-actions {
    padding: 0.5rem 1.25rem 1.25rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    align-items: center;
    margin-top: auto;
}

/* Action Buttons */
.btn-mapa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--md-sys-color-surface-container-highest);
    border: none;
    cursor: pointer;
    color: var(--md-extended-color-ubicaciones-color);
    transition: background-color 0.2s ease, transform 0.2s ease, border-radius 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.btn-mapa:hover {
    background-color: var(--md-sys-color-surface-variant);
    transform: scale(1.05);
}

.btn-mapa:active {
    transform: scale(0.95);
    border-radius: 12px; /* Morph from Circle to Rounded Rect */
}

.btn-detalles {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 50rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--md-sys-color-primary);
    background-color: transparent;
    border: 1px solid var(--md-sys-color-outline);
    transition: all 0.2s ease, border-radius 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.btn-detalles:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: transparent;
}

.btn-detalles:active {
    border-radius: 12px; /* Morph from Pill to Rounded Rect */
    filter: brightness(0.95);
}

.btn-detalles .material-symbols-outlined {
    font-size: 1.1rem;
}

/* --- Estilos de Polígonos de Ubicación --- */
.location-boundary {
    fill-color: var(--md-extended-color-ubicaciones-color);
    fill-opacity: 0;
    stroke-width: 2px;
    stroke: var(--md-extended-color-ubicaciones-color);
    stroke-opacity: 0.6;
    transition: fill-opacity 0.3s ease, stroke-width 0.3s ease, stroke-opacity 0.3s ease;
}

.location-boundary.highlighted {
    fill-opacity: 0;
    stroke-width: 4px;
    stroke-opacity: 1;
}

/* --- Estilos de Leaflet Personalizados --- */
.leaflet-container {
    background-color: var(--md-sys-color-surface-variant) !important;
}

.leaflet-bar {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.leaflet-control-directions {
    margin-bottom: 8px !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.leaflet-control-directions.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.leaflet-control-directions a {
    width: 56px !important;
    height: 56px !important;
    font-size: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: var(--md-sys-color-primary) !important;
    color: var(--md-sys-color-on-primary) !important;
    border: none !important;
    outline: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    -webkit-tap-highlight-color: transparent;
    border-radius: 12px !important;
}

.leaflet-control-directions a:hover {
    background-color: var(--md-sys-color-primary) !important;
    filter: brightness(1.1);
}

.leaflet-control-directions a:active {
    border-radius: 28px !important;
}

.leaflet-control-zoom.leaflet-bar a,
.leaflet-control-zoom.leaflet-bar a:hover {
    width: 56px !important;
    height: 56px !important;
    line-height: 56px !important;
    font-size: 28px !important;
    font-weight: 300 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: var(--md-sys-color-surface-container-high) !important;
    color: var(--md-sys-color-primary) !important;
    border: none !important;
    outline: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    -webkit-tap-highlight-color: transparent;
}

.leaflet-control-zoom.leaflet-bar a:hover {
    background-color: var(--md-sys-color-surface-container-highest) !important;
}

/* Base state: Rounded square (12px) */
.leaflet-control-zoom.leaflet-bar a {
    border-radius: 12px !important;
}

.leaflet-control-zoom-in {
    margin-bottom: 8px !important;
}

/* Active state: Higher specificty to override base state */
.leaflet-control-zoom.leaflet-bar a.leaflet-control-zoom-in:active {
    /* Top corners become fully rounded (28px for 56px height) */
    border-radius: 28px 28px 12px 12px !important;
}

.leaflet-control-zoom.leaflet-bar a.leaflet-control-zoom-out:active {
    /* Bottom corners become fully rounded */
    border-radius: 12px 12px 28px 28px !important;
}

.leaflet-bar a+a {
    border-top: none !important;
}

.leaflet-div-icon {
    background: none;
    border: none;
}

.custom-leaflet-marker {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.custom-leaflet-marker .place-icon {
    font-size: 48px;
    color: var(--md-extended-color-ubicaciones-color);
    font-variation-settings: 'FILL' 1, 'wght' 400;
    position: relative;
    z-index: 1;
}

.custom-leaflet-marker .circle-icon {
    font-size: 14px;
    color: var(--md-extended-color-ubicaciones-on-color);
    font-variation-settings: 'FILL' 1;
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

/* --- Diseño Responsivo --- */
@media (max-width: 768px) {
    .map-container {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .map-container {
        height: 300px;
    }

    .ubicaciones-title {
        font-size: 2rem;
    }

    .ubicaciones-address {
        font-size: 1rem;
    }
}