/**
 * Estilos Personalizados
 * Sistema de Reportes Municipales
 */

/* Variables de colores del municipio */
:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --info-color: #36b9cc;

    /* Esquemas de color de fondo oscuro */
    --bg-dark-purple: #5a4a7d;
    --bg-dark-blue: #2c3e50;
    --bg-dark-cyan: #2c5f7d;

    /* Esquema de color claro */
    --bg-light: #f8f9fc;
    --bg-light-card: #ffffff;
    --bg-light-hover: #eaecf4;
    --text-light: #5a5c69;
    --text-light-muted: #858796;

    /* Color de fondo activo (por defecto azul oscuro) */
    --bg-main: var(--bg-dark-blue);
    --bg-card: #34495e;
    --bg-hover: #3d566e;
    --text-main: #ecf0f1;
    --text-muted: #bdc3c7;

    /* Navegación móvil */
    --mobile-nav-height: 70px;
    --mobile-nav-bg: #1a252f;
    --mobile-nav-active: var(--primary-color);
}

/* Ajustes generales */
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-main) !important;
    color: var(--text-main) !important;
}

/* Animación fade-in para campos dinámicos */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Wrapper con fondo oscuro */
#wrapper {
    background-color: var(--bg-main) !important;
}

/* Content wrapper */
#content-wrapper {
    background-color: var(--bg-main) !important;
}

/* Mapa Leaflet - SIMPLIFICADO */
#map {
    height: 100%;
    width: 100%;
}

/* Wrapper del mapa - CONTENCIÓN SIMPLE */
#map-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 0.35rem;
}

/* CRÍTICO: Asegurar que los controles de Leaflet sean visibles */
.leaflet-control-zoom,
.leaflet-control-fullscreen,
.leaflet-bar {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
    z-index: 1000 !important;
}

.leaflet-control-zoom a,
.leaflet-control-fullscreen a,
.leaflet-bar a {
    background-color: #fff !important;
    color: #333 !important;
    border: 2px solid rgba(0, 0, 0, 0.2) !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    text-align: center !important;
    font-size: 18px !important;
    font-weight: bold !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    cursor: pointer !important;
    text-decoration: none !important;
    box-shadow: none !important;
    background-image: none !important;
    background-position: 0 0 !important;
    background-repeat: no-repeat !important;
    background-size: 0 !important;
    text-indent: 0 !important;
    padding: 0 !important;
}

.leaflet-control-zoom a:hover,
.leaflet-control-fullscreen a:hover,
.leaflet-bar a:hover {
    background-color: #f4f4f4 !important;
    color: #000 !important;
}

/* Asegurar que el control de fullscreen tenga el tamaño correcto */
.leaflet-control-fullscreen {
    width: 30px !important;
    height: 30px !important;
}

.leaflet-control-fullscreen a {
    width: 30px !important;
    height: 30px !important;
}

/* Asegurar que el botón de fullscreen sea visible con ícono */
.leaflet-control-fullscreen a {
    background-image: none !important;
    background-size: 0 !important;
    position: relative !important;
}

/* Ícono para el botón de fullscreen - múltiples selectores para compatibilidad */
/* NOTA: El ícono se agrega via JavaScript en MapInitializer.js, NO via CSS */
.leaflet-control-fullscreen a::before,
.leaflet-control-fullscreen-button::before,
.leaflet-control-fullscreen>a::before {
    content: none !important;
    display: none !important;
}

/* Alternativa con Font Awesome si está disponible - DESHABILITADO */
.leaflet-control-fullscreen a.fullscreen-icon::before,
.fullscreen-icon::before {
    content: none !important;
    display: none !important;
}

.leaflet-fullscreen-on .leaflet-control-fullscreen a::before,
.leaflet-fullscreen-on .fullscreen-icon::before {
    content: none !important;
    display: none !important;
}

/* Botón de pantalla completa del mapa - BACKUP si el plugin no funciona */
.map-fullscreen-btn {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 1000 !important;
    background: white !important;
    border: 2px solid rgba(0, 0, 0, 0.2) !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    cursor: pointer !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2) !important;
    transition: background-color 0.2s ease !important;
    font-size: 16px !important;
    line-height: 1 !important;
    color: #333 !important;
}

.map-fullscreen-btn:hover {
    background-color: #f4f4f4 !important;
}

.map-fullscreen-btn:active {
    background-color: #e0e0e0 !important;
}

.map-fullscreen-btn i {
    pointer-events: none !important;
}

/* Corrección para botones de zoom de Leaflet - SIMPLIFICADO */
.leaflet-control-zoom a {
    font-family: "Lucida Console", Monaco, monospace !important;
    text-decoration: none !important;
    line-height: 30px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #333 !important;
    background-color: #fff !important;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    text-shadow: none !important;
    border-bottom: 1px solid #ccc !important;
    box-shadow: none !important;
    text-indent: 0 !important;
    padding: 0 !important;
}

/* CRÍTICO: Forzar visibilidad del contenido de texto */
.leaflet-control-zoom-in::before,
.leaflet-control-zoom-out::before {
    content: none !important;
    display: none !important;
}

/* NO agregar contenido extra - dejar que Leaflet maneje el contenido */
.leaflet-control-zoom a::before,
.leaflet-control-zoom a::after {
    content: none !important;
    display: none !important;
}

.leaflet-control-zoom a:hover {
    background-color: #f4f4f4 !important;
    color: #000 !important;
}

.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

#map-detail {
    height: 300px;
    width: 100%;
    border-radius: 0.35rem;
    transition: none;
}

/* Contenedor del mapa en pantalla completa - SIMPLIFICADO */
.map-is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    overflow: hidden !important;
}

.map-is-fullscreen #map {
    height: 100vh !important;
    width: 100vw !important;
}

/* Leaflet fullscreen mode - asegurar que el mapa ocupe todo el espacio */
.leaflet-container.leaflet-fullscreen-on {
    width: 100% !important;
    height: 100% !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 99999 !important;
}

/* Asegurar que los tiles se carguen correctamente en fullscreen */
.leaflet-fullscreen-on .leaflet-tile-container {
    width: 100% !important;
    height: 100% !important;
}

.leaflet-fullscreen-on .leaflet-tile-pane {
    width: 100% !important;
    height: 100% !important;
}

/* Asegurar que los controles sean visibles en fullscreen */
.leaflet-fullscreen-on .leaflet-control-zoom,
.leaflet-fullscreen-on .leaflet-control-fullscreen {
    z-index: 100000 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Modo oscuro para mapa en pantalla completa */
body.dark-mode .map-is-fullscreen,
body[class*="theme-"] .map-is-fullscreen {
    background: #f0f0f0 !important;
}

/* Tarjetas de reportes */
.report-card {
    transition: transform 0.2s;
}

.report-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.report-card img {
    height: 200px;
    object-fit: cover;
}

/* Badges personalizados */
.badge-en-proceso {
    background-color: var(--warning-color);
}

.badge-completado {
    background-color: var(--success-color);
}

/* Botones */
.btn-municipio {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-municipio:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
    color: white;
}

/* Formularios */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

/* Tablas */
.table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.05);
}

/* Loader */
.loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Responsive Maps */
@media (max-width: 768px) {
    #map {
        height: 350px;
        /* Increased for better mobile viewing */
    }

    #map-detail {
        height: 250px;
    }

    .report-card img {
        height: 150px;
    }

    /* IMPORTANT: Make action buttons horizontal on mobile */
    .d-sm-flex {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .d-sm-flex .btn {
        width: auto !important;
        flex: 1 1 auto;
        min-width: 120px;
        margin-bottom: 0 !important;
    }

    .d-sm-flex h1 {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    /* Make button groups horizontal */
    .btn-group-vertical {
        flex-direction: row !important;
        flex-wrap: wrap;
    }

    .btn-group-vertical .btn {
        width: auto !important;
        flex: 1 1 auto;
        margin-right: 0.5rem;
        margin-bottom: 0.5rem;
    }
}

/* Mobile-specific map improvements */
@media (max-width: 576px) {
    #map {
        height: 300px;
        border-radius: 0.25rem;
    }

    #map-detail {
        height: 200px;
    }

    /* Ensure map controls are touch-friendly */
    .leaflet-control-zoom a {
        width: 36px !important;
        height: 36px !important;
        line-height: 36px !important;
        font-size: 20px !important;
    }

    /* Make map markers more visible on mobile */
    .leaflet-marker-icon {
        transform: scale(1.2);
    }
}

/* Historial de cambios */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--primary-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 2px solid white;
}

/* Estadísticas */
.stat-card {
    border-left: 4px solid var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.info {
    border-left-color: var(--info-color);
}

/* Sidebar personalizado */
.sidebar-brand-text small {
    font-size: 0.7rem;
    display: block;
    margin-top: -5px;
    color: #ffffff !important;
    /* Force white color in all themes */
}

/* Ensure main text is also white */
.sidebar-brand-text {
    color: #ffffff !important;
}

/* CRÍTICO: Forzar SIEMPRE texto blanco en sidebar brand en TODOS los temas */
.sidebar-brand,
.sidebar-brand *,
.sidebar-brand-text,
.sidebar-brand-text *,
.sidebar-brand-text small {
    color: #ffffff !important;
    opacity: 1 !important;
}

/* ========================================
   TOPBAR TOGGLE BUTTON VISIBILITY
   ======================================== */

/* Desktop: Mostrar botón hamburguesa para colapsar sidebar */
@media (min-width: 769px) {
    #sidebarToggleTop {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Mobile: Ocultar botón hamburguesa (se usa navegación inferior) */
@media (max-width: 768px) {
    #sidebarToggleTop {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Topbar personalizado */
.topbar .nav-item .nav-link {
    height: 4.375rem;
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
}

/* Mejoras para móviles */
@media (max-width: 576px) {
    .btn-block {
        margin-bottom: 0.5rem;
    }

    .card-body h5 {
        font-size: 1rem;
    }

    /* Touch-friendly buttons */
    .btn {
        min-height: 44px;
        /* Apple's recommended touch target size */
        padding: 0.5rem 1rem;
    }

    .btn-sm {
        min-height: 38px;
        padding: 0.4rem 0.8rem;
    }

    .btn-lg {
        min-height: 50px;
        padding: 0.75rem 1.5rem;
        font-size: 1.1rem;
    }

    /* Form inputs touch-friendly */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    textarea.form-control {
        min-height: 100px;
    }

    /* Better spacing for form groups */
    .form-group {
        margin-bottom: 1.25rem;
    }

    /* Improve card spacing */
    .card {
        margin-bottom: 1rem;
    }

    /* Better heading sizes */
    h1,
    .h1 {
        font-size: 1.75rem;
    }

    h2,
    .h2 {
        font-size: 1.5rem;
    }

    h3,
    .h3 {
        font-size: 1.25rem;
    }

    /* Improve table responsiveness */
    .table-responsive {
        border: 0;
    }

    /* Stack action buttons vertically */
    .btn-group-vertical {
        width: 100%;
    }

    .btn-group-vertical .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Animaciones suaves */
.card {
    transition: box-shadow 0.3s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Estilos para alertas de SweetAlert2 personalizadas */
.swal2-popup {
    font-family: 'Nunito', sans-serif;
}

/* Mejoras para DataTables */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

/* Estilos específicos para vista de reportes */
#cardsView {
    flex-wrap: wrap;
}

#cardsView .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#cardsView .card-body {
    flex: 1;
}

#cardsView .card-footer {
    background-color: #f8f9fc;
    border-top: 1px solid #e3e6f0;
}

/* Filtros de reportes */
#filterForm .form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #5a5c69;
}

#filterForm .form-control,
#filterForm .form-select {
    font-size: 0.875rem;
}

/* Botones de toggle y export */
#btnToggleView,
#btnExport {
    white-space: nowrap;
}

/* Tabla de reportes */
#reportesTable tbody tr {
    cursor: pointer;
}

#reportesTable tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.05);
}

/* Badges en tabla */
#reportesTable .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* Responsive para filtros */
@media (max-width: 768px) {

    #filterForm .col-md-3,
    #filterForm .col-md-9 {
        margin-bottom: 0.5rem;
    }

    #btnToggleView,
    #btnExport {
        margin-bottom: 0.5rem;
        display: block;
        width: 100%;
    }

    /* Stack filter buttons */
    #btnApplyFilters,
    #btnClearFilters {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Improve filter form layout */
    #filterForm .col-md-3,
    #filterForm .col-md-6,
    #filterForm .col-md-9 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
}

/* Mobile-specific improvements for cards view */
@media (max-width: 768px) {

    #cardsView .col-xl-3,
    #cardsView .col-lg-4,
    #cardsView .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    #cardsView .card {
        margin-bottom: 1.5rem;
    }

    #cardsView .card-img-top {
        height: 200px;
        object-fit: cover;
    }
}

/* DataTables mobile optimization */
@media (max-width: 768px) {

    /* Make DataTables more responsive */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center;
        margin-bottom: 1rem;
    }

    .dataTables_wrapper .dataTables_length select {
        min-height: 44px;
        font-size: 16px;
    }

    .dataTables_wrapper .dataTables_filter input {
        min-height: 44px;
        font-size: 16px;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        margin-top: 1rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.5rem 0.75rem;
        margin: 0.25rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide less important columns on mobile */
    #reportesTable th:nth-child(3),
    #reportesTable td:nth-child(3),
    #reportesTable th:nth-child(4),
    #reportesTable td:nth-child(4) {
        display: none;
    }
}

/* Animación para cambio de vista */
#tableView,
#cardsView {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mejoras para imágenes en tarjetas */
#cardsView .card-img-top {
    border-bottom: 1px solid #e3e6f0;
}

/* Estado de carga */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* ========================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ======================================== */

/* Mobile Navigation Improvements */
@media (max-width: 768px) {

    /* Sidebar improvements */
    .sidebar {
        width: 14rem !important;
    }

    .sidebar.toggled {
        width: 0 !important;
    }

    /* Topbar improvements */
    .topbar {
        height: auto;
        min-height: 4.375rem;
    }

    .topbar .navbar-nav {
        flex-direction: row;
    }

    /* Page heading improvements - HORIZONTAL BUTTONS */
    .d-sm-flex {
        flex-direction: row !important;
        flex-wrap: wrap;
        align-items: center !important;
        gap: 0.5rem;
    }

    .d-sm-flex h1 {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .d-sm-flex .btn,
    .d-sm-flex a.btn {
        width: auto !important;
        flex: 1 1 auto;
        min-width: 120px;
        margin-bottom: 0 !important;
        white-space: nowrap;
    }

    /* Ensure button containers are horizontal */
    .d-sm-flex>div {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
}

/* Mobile Form Improvements */
@media (max-width: 576px) {

    /* Better form layout */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        margin-bottom: 1rem;
    }

    /* File input improvements */
    .form-control-file {
        font-size: 14px;
        padding: 0.5rem 0;
    }

    /* Preview images */
    #preview-container img {
        max-width: 100% !important;
    }

    /* Input groups */
    .input-group {
        flex-wrap: nowrap;
    }

    .input-group .form-control {
        min-width: 0;
        flex: 1;
    }

    .input-group-append .btn {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
    }
}

/* Mobile Card Improvements */
@media (max-width: 576px) {
    .card-header {
        padding: 0.75rem 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-footer {
        padding: 0.75rem 1rem;
    }

    /* Better badge sizing */
    .badge {
        font-size: 0.8rem;
        padding: 0.4em 0.7em;
    }

    .badge-lg {
        font-size: 0.9rem;
        padding: 0.5em 0.8em;
    }
}

/* Mobile Table Improvements */
@media (max-width: 576px) {
    .table {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
        vertical-align: middle;
    }

    /* Action buttons in tables */
    .table .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .table .btn-sm i {
        font-size: 0.85rem;
    }
}

/* Mobile Alert Improvements */
@media (max-width: 576px) {
    .alert {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }

    .alert i {
        font-size: 1rem;
    }
}

/* Mobile Modal Improvements */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.5rem;
    }

    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }
}

/* Touch-friendly SweetAlert2 */
@media (max-width: 576px) {
    .swal2-popup {
        font-size: 0.9rem;
        padding: 1.5rem;
    }

    .swal2-title {
        font-size: 1.5rem;
    }

    .swal2-content {
        font-size: 0.9rem;
    }

    .swal2-actions button {
        min-height: 44px;
        padding: 0.5rem 1.5rem;
        font-size: 1rem;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    #map {
        height: 250px;
    }

    .card-img-top {
        height: 150px;
    }

    /* Reduce vertical spacing in landscape */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .card {
        margin-bottom: 0.75rem;
    }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 576px) {

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Improve touch targets for links */
@media (max-width: 576px) {
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Exception for inline text links */
    p a,
    li a,
    .card-text a {
        min-height: auto;
        display: inline;
    }
}

/* Mobile-specific utility classes */
@media (max-width: 576px) {
    .mobile-full-width {
        width: 100% !important;
        display: block !important;
    }

    .mobile-text-center {
        text-align: center !important;
    }

    .mobile-mb-2 {
        margin-bottom: 0.5rem !important;
    }

    .mobile-mt-2 {
        margin-top: 0.5rem !important;
    }
}

/* Improve image viewing on mobile */
@media (max-width: 576px) {

    .img-fluid,
    .img-thumbnail {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    /* Better image galleries */
    .row .col-md-6 img {
        margin-bottom: 1rem;
    }
}

/* Mobile-friendly statistics dashboard */
@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 1rem;
    }

    .stat-card .card-body {
        padding: 1rem;
    }

    /* Chart containers */
    canvas {
        max-height: 250px !important;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 576px) {

    /* Larger focus indicators */
    *:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }

    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--primary-color);
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 100;
    }

    .skip-to-content:focus {
        top: 0;
    }
}


/* ========================================
   DARK MODE STYLES
   ======================================== */

body.dark-mode {
    background-color: #1a1a1a !important;
    color: #e0e0e0 !important;
}

body.dark-mode #wrapper {
    background-color: #1a1a1a !important;
}

body.dark-mode .sidebar {
    background: linear-gradient(180deg, #2c2c2c 10%, #1a1a1a 100%) !important;
}

body.dark-mode .sidebar .nav-item .nav-link {
    color: #b0b0b0 !important;
}

body.dark-mode .sidebar .nav-item .nav-link:hover {
    color: #ffffff !important;
}

body.dark-mode .sidebar .nav-item .nav-link.active {
    color: #ffffff !important;
}

body.dark-mode .sidebar-brand {
    color: #ffffff !important;
}

body.dark-mode .topbar {
    background-color: #2c2c2c !important;
}

body.dark-mode .card {
    background-color: #2c2c2c !important;
    color: #e0e0e0 !important;
    border-color: #3a3a3a !important;
}

body.dark-mode .card-header {
    background-color: #3a3a3a !important;
    border-bottom: 1px solid #4a4a4a !important;
    color: #e0e0e0 !important;
}

body.dark-mode .text-gray-800 {
    color: #e0e0e0 !important;
}

body.dark-mode .text-muted {
    color: #a0a0a0 !important;
}

body.dark-mode .bg-white {
    background-color: #2c2c2c !important;
}

body.dark-mode .border-left-primary {
    border-left-color: #4e73df !important;
}

body.dark-mode .border-left-success {
    border-left-color: #1cc88a !important;
}

body.dark-mode .border-left-warning {
    border-left-color: #f6c23e !important;
}

body.dark-mode .border-left-info {
    border-left-color: #36b9cc !important;
}

body.dark-mode .table {
    color: #e0e0e0 !important;
}

body.dark-mode .table-bordered {
    border-color: #4a4a4a !important;
}

body.dark-mode .table-bordered td,
body.dark-mode .table-bordered th {
    border-color: #4a4a4a !important;
}

body.dark-mode .table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.15) !important;
}

body.dark-mode .form-control {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #4a4a4a !important;
}

body.dark-mode .form-control:focus {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #4e73df !important;
}

body.dark-mode .btn-secondary {
    background-color: #4a4a4a !important;
    border-color: #5a5a5a !important;
    color: #e0e0e0 !important;
}

body.dark-mode .btn-secondary:hover {
    background-color: #5a5a5a !important;
    border-color: #6a6a6a !important;
}

body.dark-mode .alert-info {
    background-color: #1e3a5f !important;
    border-color: #2e4a6f !important;
    color: #b0d4ff !important;
}

body.dark-mode .alert-warning {
    background-color: #5f4a1e !important;
    border-color: #6f5a2e !important;
    color: #ffd4b0 !important;
}

body.dark-mode .alert-success {
    background-color: #1e5f3a !important;
    border-color: #2e6f4a !important;
    color: #b0ffd4 !important;
}

body.dark-mode .alert-danger {
    background-color: #5f1e1e !important;
    border-color: #6f2e2e !important;
    color: #ffb0b0 !important;
}

body.dark-mode .alert-dark {
    background-color: #2c2c2c !important;
    border-color: #4a4a4a !important;
    color: #e0e0e0 !important;
}

body.dark-mode .dropdown-menu {
    background-color: #2c2c2c !important;
    border-color: #4a4a4a !important;
}

body.dark-mode .dropdown-item {
    color: #e0e0e0 !important;
}

body.dark-mode .dropdown-item:hover {
    background-color: #3a3a3a !important;
    color: #ffffff !important;
}

body.dark-mode .modal-content {
    background-color: #2c2c2c !important;
    color: #e0e0e0 !important;
}

body.dark-mode .modal-header {
    background-color: #3a3a3a !important;
    border-bottom-color: #4a4a4a !important;
}

body.dark-mode .modal-footer {
    background-color: #3a3a3a !important;
    border-top-color: #4a4a4a !important;
}

body.dark-mode .close {
    color: #e0e0e0 !important;
}

body.dark-mode .footer {
    background-color: #2c2c2c !important;
    color: #a0a0a0 !important;
}

body.dark-mode .sticky-footer {
    background-color: #2c2c2c !important;
}

body.dark-mode .badge-secondary {
    background-color: #5a5a5a !important;
}

body.dark-mode .text-gray-600 {
    color: #b0b0b0 !important;
}

body.dark-mode .text-gray-400 {
    color: #808080 !important;
}

body.dark-mode .text-gray-300 {
    color: #707070 !important;
}

body.dark-mode .bg-gradient-primary {
    background: linear-gradient(180deg, #3a5fc9 10%, #2e4fa9 100%) !important;
}

body.dark-mode .shadow {
    box-shadow: 0 0.15rem 1.75rem 0 rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .border {
    border-color: #4a4a4a !important;
}

body.dark-mode hr {
    border-top-color: #4a4a4a !important;
}

body.dark-mode .page-item.disabled .page-link {
    background-color: #3a3a3a !important;
    border-color: #4a4a4a !important;
    color: #808080 !important;
}

body.dark-mode .page-link {
    background-color: #2c2c2c !important;
    border-color: #4a4a4a !important;
    color: #e0e0e0 !important;
}

body.dark-mode .page-link:hover {
    background-color: #3a3a3a !important;
    border-color: #5a5a5a !important;
    color: #ffffff !important;
}

body.dark-mode .page-item.active .page-link {
    background-color: #4e73df !important;
    border-color: #4e73df !important;
}

/* DataTables dark mode */
body.dark-mode .dataTables_wrapper .dataTables_length,
body.dark-mode .dataTables_wrapper .dataTables_filter,
body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_processing,
body.dark-mode .dataTables_wrapper .dataTables_paginate {
    color: #e0e0e0 !important;
}

body.dark-mode .dataTables_wrapper .dataTables_length select,
body.dark-mode .dataTables_wrapper .dataTables_filter input {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #4a4a4a !important;
}

/* Chart.js dark mode */
body.dark-mode canvas {
    filter: brightness(0.9);
}

/* Leaflet map dark mode */
body.dark-mode .leaflet-container {
    background-color: #2c2c2c !important;
}

body.dark-mode .leaflet-popup-content-wrapper {
    background-color: #2c2c2c !important;
    color: #e0e0e0 !important;
}

body.dark-mode .leaflet-popup-tip {
    background-color: #2c2c2c !important;
}

/* Leaflet tiles en modo oscuro - DESHABILITADO para evitar parpadeo */
/* body.dark-mode .leaflet-tile-pane {
    filter: brightness(0.7) contrast(1.1);
} */

/* Leaflet controles en modo oscuro - MEJORADO CON MÁXIMA ESPECIFICIDAD */
body.dark-mode .leaflet-control-zoom a,
body.dark-mode .leaflet-control-fullscreen a,
body.dark-mode .leaflet-bar a,
body.dark-mode .leaflet-control-zoom-in,
body.dark-mode .leaflet-control-zoom-out,
body.dark-mode .leaflet-control-fullscreen-button {
    background-color: #ffffff !important;
    color: #000000 !important;
    /* NEGRO para contraste sobre fondo blanco */
    border-color: rgba(0, 0, 0, 0.2) !important;
    /* CRÍTICO: Agregar propiedades de display y centrado */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-indent: 0 !important;
    text-align: center !important;
    font-size: 18px !important;
    font-weight: bold !important;
    line-height: 30px !important;
    width: 30px !important;
    height: 30px !important;
    /* Evitar inversión de colores */
    filter: none !important;
    -webkit-filter: none !important;
    /* Forzar que el texto sea visible */
    text-shadow: none !important;
    -webkit-text-fill-color: #000000 !important;
}

/* Asegurar que el texto dentro del enlace sea negro */
body.dark-mode .leaflet-control-zoom a *,
body.dark-mode .leaflet-control-fullscreen a * {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
}

body.dark-mode .leaflet-control-zoom a:hover,
body.dark-mode .leaflet-control-fullscreen a:hover,
body.dark-mode .leaflet-bar a:hover {
    background-color: #f4f4f4 !important;
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
}

body.dark-mode .leaflet-control-attribution {
    background-color: rgba(255, 255, 255, 0.8) !important;
    color: #333333 !important;
}

/* Custom control dark mode */
body.dark-mode .custom-control-label {
    color: #e0e0e0 !important;
}

body.dark-mode .custom-control-input:checked~.custom-control-label::before {
    background-color: #4e73df !important;
    border-color: #4e73df !important;
}

/* Input group dark mode */
body.dark-mode .input-group-text {
    background-color: #3a3a3a !important;
    border-color: #4a4a4a !important;
    color: #e0e0e0 !important;
}

/* Select dark mode */
body.dark-mode select.form-control {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #4a4a4a !important;
}

body.dark-mode select.form-control option {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
}

/* Textarea dark mode */
body.dark-mode textarea.form-control {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #4a4a4a !important;
}

/* Badge dark mode adjustments */
body.dark-mode .badge-primary {
    background-color: #4e73df !important;
}

body.dark-mode .badge-success {
    background-color: #1cc88a !important;
}

body.dark-mode .badge-warning {
    background-color: #f6c23e !important;
    color: #1a1a1a !important;
}

body.dark-mode .badge-danger {
    background-color: #e74a3b !important;
}

body.dark-mode .badge-info {
    background-color: #36b9cc !important;
}

/* Scroll to top button dark mode */
body.dark-mode .scroll-to-top {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
}

body.dark-mode .scroll-to-top:hover {
    background-color: #4a4a4a !important;
}


/* ========================================
   MOBILE BOTTOM NAVIGATION
   ======================================== */

.mobile-bottom-nav {
    display: none;
    /* Hidden by default, shown on mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background-color: var(--mobile-nav-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1060;
    padding: 0;
    margin: 0;
}

.mobile-bottom-nav .nav-container {
    display: flex;
    justify-content: stretch;
    align-items: stretch;
    height: 100%;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
}

.mobile-bottom-nav .nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    opacity: 0.7;
    transition: all 0.3s ease;
    padding: 8px 4px;
    position: relative;
    min-height: 44px;
    min-width: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0;
}

.mobile-bottom-nav .nav-item:first-child {
    border-left: none;
}

.mobile-bottom-nav .nav-item:last-child {
    border-right: none;
}

.mobile-bottom-nav .nav-item i {
    font-size: 26px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    display: inline-block !important;
}

/* Asegurar que los íconos se muestren correctamente */
.mobile-bottom-nav .nav-item i.fa-home::before {
    content: "\f015" !important;
}

.mobile-bottom-nav .nav-item i.fa-clipboard-list::before {
    content: "\f46d" !important;
}

.mobile-bottom-nav .nav-item i.fa-plus-square::before {
    content: "\f0fe" !important;
}

.mobile-bottom-nav .nav-item i.fa-chart-line::before {
    content: "\f201" !important;
}

.mobile-bottom-nav .nav-item i.fa-users::before {
    content: "\f0c0" !important;
}

.mobile-bottom-nav .nav-item i.fa-user::before {
    content: "\f007" !important;
}

.mobile-bottom-nav .nav-item span {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.mobile-bottom-nav .nav-item.active {
    color: var(--mobile-nav-active);
    opacity: 1;
    background-color: rgba(78, 115, 223, 0.15);
}

.mobile-bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--mobile-nav-active);
}

.mobile-bottom-nav .nav-item.active i {
    transform: scale(1.15);
}

.mobile-bottom-nav .nav-item:active {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

/* Show mobile nav on small screens */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block;
        animation: slideUp 0.3s ease-out;
    }

    /* Add padding to content to prevent overlap */
    #content-wrapper {
        padding-bottom: calc(var(--mobile-nav-height) + 20px);
    }

    /* Adjust scroll to top button */
    .scroll-to-top {
        bottom: calc(var(--mobile-nav-height) + 10px) !important;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Ripple effect on touch */
.mobile-bottom-nav .nav-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.mobile-bottom-nav .nav-item:active::after {
    width: 60px;
    height: 60px;
}

/* Accessibility */
.mobile-bottom-nav .nav-item:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .mobile-bottom-nav {
        animation: none;
    }

    .mobile-bottom-nav .nav-item,
    .mobile-bottom-nav .nav-item i,
    .mobile-bottom-nav .nav-item::after {
        transition: none;
    }
}


/* ========================================
   MOBILE SIDEBAR IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {

    /* Hide sidebar completely on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 14rem !important;
        height: 100vh;
        z-index: 1050;
        transition: left 0.25s ease-in-out;
        overflow-y: auto;
    }

    .sidebar.show {
        left: 0;
    }

    /* Hide sidebar toggle button (the arrow) - IMPORTANT */
    .sidebar #sidebarToggle,
    .sidebar .text-center.d-none.d-md-inline,
    .sidebar .text-center {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Make content full width on mobile */
    #content-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
    }

    #wrapper {
        display: block !important;
    }

    #content {
        width: 100% !important;
    }

    /* Ensure sidebar doesn't block interaction when hidden */
    .sidebar:not(.show) {
        pointer-events: none;
    }

    .sidebar.show {
        pointer-events: auto;
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        animation: fadeIn 0.2s ease-out;
    }

    .sidebar-overlay.show {
        display: block;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Hamburger button in topbar */
    .mobile-menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        margin-right: 10px;
        background: none;
        border: none;
        color: var(--text-main);
        font-size: 24px;
        cursor: pointer;
    }

    .mobile-menu-toggle:focus {
        outline: 2px solid var(--primary-color);
    }
}

@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}


/* ========================================
   DARK BACKGROUND CARD STYLES
   ======================================== */

.card {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.card-header {
    background-color: rgba(0, 0, 0, 0.2) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-main) !important;
}

.card-footer {
    background-color: rgba(0, 0, 0, 0.2) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.text-gray-800 {
    color: var(--text-main) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Form controls with dark background */
.form-control,
.form-select {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: var(--text-main) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.form-control:focus,
.form-select:focus {
    background-color: rgba(0, 0, 0, 0.4) !important;
    color: var(--text-main) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.6;
}

/* Tables with dark background */
.table {
    color: var(--text-main) !important;
}

.table-bordered {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.table-bordered td,
.table-bordered th {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.15) !important;
}

/* Alerts with dark background */
.alert {
    border-width: 1px;
}

.alert-info {
    background-color: rgba(54, 185, 204, 0.2) !important;
    border-color: rgba(54, 185, 204, 0.4) !important;
    color: #a8e6f0 !important;
}

.alert-warning {
    background-color: rgba(246, 194, 62, 0.2) !important;
    border-color: rgba(246, 194, 62, 0.4) !important;
    color: #fce8b8 !important;
}

.alert-success {
    background-color: rgba(28, 200, 138, 0.2) !important;
    border-color: rgba(28, 200, 138, 0.4) !important;
    color: #a8f0d1 !important;
}

.alert-danger {
    background-color: rgba(231, 74, 59, 0.2) !important;
    border-color: rgba(231, 74, 59, 0.4) !important;
    color: #f5b7b1 !important;
}

/* Modals with dark background */
.modal-content {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.modal-header {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

.modal-footer {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-top-color: rgba(255, 255, 255, 0.1) !important;
}

.close {
    color: var(--text-main) !important;
    opacity: 0.8;
}

.close:hover {
    opacity: 1;
}

/* Dropdown menus */
.dropdown-menu {
    background-color: var(--bg-card) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.dropdown-item {
    color: var(--text-main) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: rgba(78, 115, 223, 0.2) !important;
    color: #ffffff !important;
}

/* Topbar adjustments */
.topbar {
    background-color: rgba(0, 0, 0, 0.3) !important;
}

.topbar .nav-link {
    color: var(--text-main) !important;
}

/* Sidebar adjustments */
.sidebar {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 10%, var(--bg-main) 100%) !important;
}

.sidebar .nav-item .nav-link {
    color: #ffffff !important;
    opacity: 1 !important;
}

.sidebar .nav-item .nav-link:hover,
.sidebar .nav-item .nav-link.active {
    color: #ffffff !important;
    opacity: 1 !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.sidebar .nav-item .nav-link span {
    color: #ffffff !important;
    opacity: 1 !important;
}

.sidebar .nav-item .nav-link i {
    color: #ffffff !important;
    opacity: 1 !important;
}

.sidebar-heading {
    color: #ffffff !important;
    opacity: 0.9 !important;
}

.sidebar-brand {
    background-color: rgba(0, 0, 0, 0.2) !important;
}

/* DataTables dark theme */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-main) !important;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: var(--text-main) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.page-link {
    background-color: var(--bg-card) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: var(--text-main) !important;
}

.page-link:hover {
    background-color: var(--bg-hover) !important;
    color: #ffffff !important;
}

.page-item.active .page-link {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* Badges adjustments */
.badge-secondary {
    background-color: #6c757d !important;
}

/* Border colors */
.border {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

hr {
    border-top-color: rgba(255, 255, 255, 0.1) !important;
}

/* Footer */
.footer,
.sticky-footer {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: var(--text-muted) !important;
}


/* ========================================
   COLOR THEME SELECTOR
   ======================================== */

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 8px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin: 10px 0;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    padding: 8px 16px;
    border: 2px solid transparent;
    border-radius: 6px;
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-btn:hover {
    background-color: rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.mode-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 8px rgba(78, 115, 223, 0.3);
}

.mode-btn i {
    font-size: 1rem;
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 8px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin: 10px 0;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    min-height: 56px;
}

.theme-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.theme-option:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.theme-option.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px var(--primary-color);
    transform: scale(1.1);
}

.theme-option.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* Dropdown menu adjustments for theme selector */
.dropdown-menu {
    min-width: 280px;
}

.dropdown-item-text {
    padding: 0.5rem 1rem;
}

.dropdown-item-text small {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   LIGHT MODE THEMES
   ======================================== */

/* Theme Light (Default for Light Mode) */
body.theme-light {
    --bg-main: #f8f9fc !important;
    --bg-card: #ffffff !important;
    --bg-hover: #eaecf4 !important;
    --text-main: #5a5c69 !important;
    --text-muted: #858796 !important;
    --mobile-nav-bg: #ffffff !important;
    background-color: #f8f9fc !important;
    color: #5a5c69 !important;
}

/* Theme Blue (Light Mode) */
body.theme-blue {
    --bg-main: #e3f2fd !important;
    --bg-card: #ffffff !important;
    --bg-hover: #bbdefb !important;
    --text-main: #1565c0 !important;
    --text-muted: #1976d2 !important;
    --mobile-nav-bg: #ffffff !important;
    background-color: #e3f2fd !important;
    color: #1565c0 !important;
}

/* Theme Cyan (Light Mode) */
body.theme-cyan {
    --bg-main: #e0f7fa !important;
    --bg-card: #ffffff !important;
    --bg-hover: #b2ebf2 !important;
    --text-main: #00838f !important;
    --text-muted: #0097a7 !important;
    --mobile-nav-bg: #ffffff !important;
    background-color: #e0f7fa !important;
    color: #00838f !important;
}

/* ========================================
   DARK MODE THEMES
   ======================================== */

/* Theme Purple Dark (Default for Dark Mode) */
body.theme-purple {
    --bg-main: #5a4a7d !important;
    --bg-card: #6b5a8d !important;
    --bg-hover: #7a6a9d !important;
    --text-main: #f0e6ff !important;
    --text-muted: #d4c5f9 !important;
    --mobile-nav-bg: #4a3a6d !important;
    background-color: #5a4a7d !important;
    color: #f0e6ff !important;
}

/* Theme Blue Dark */
body.theme-blue-dark {
    --bg-main: #2c3e50 !important;
    --bg-card: #34495e !important;
    --bg-hover: #3d566e !important;
    --text-main: #ecf0f1 !important;
    --text-muted: #bdc3c7 !important;
    --mobile-nav-bg: #1a252f !important;
    background-color: #2c3e50 !important;
    color: #ecf0f1 !important;
}

/* Theme Cyan Dark */
body.theme-cyan-dark {
    --bg-main: #2c5f7d !important;
    --bg-card: #3c6f8d !important;
    --bg-hover: #4c7f9d !important;
    --text-main: #e0f7fa !important;
    --text-muted: #b2ebf2 !important;
    --mobile-nav-bg: #1c4f6d !important;
    background-color: #2c5f7d !important;
    color: #e0f7fa !important;
}

/* LIGHT THEME */
body.theme-light {
    --bg-main: var(--bg-light) !important;
    --bg-card: var(--bg-light-card) !important;
    --bg-hover: var(--bg-light-hover) !important;
    --text-main: var(--text-light) !important;
    --text-muted: var(--text-light-muted) !important;
    --mobile-nav-bg: #ffffff !important;
    background-color: var(--bg-light) !important;
    color: var(--text-light) !important;
}

body.theme-light #wrapper {
    background-color: var(--bg-light) !important;
}

body.theme-light #content-wrapper {
    background-color: var(--bg-light) !important;
}

body.theme-light .card {
    background-color: var(--bg-light-card) !important;
    color: var(--text-light) !important;
    border-color: #e3e6f0 !important;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
}

body.theme-light .card-header {
    background-color: #f8f9fc !important;
    border-bottom: 1px solid #e3e6f0 !important;
    color: var(--text-light) !important;
}

body.theme-light .text-gray-800 {
    color: #5a5c69 !important;
}

body.theme-light .text-muted {
    color: #858796 !important;
}

body.theme-light .form-control,
body.theme-light .form-select {
    background-color: #ffffff !important;
    color: var(--text-light) !important;
    border-color: #d1d3e2 !important;
}

body.theme-light .table {
    color: var(--text-light) !important;
}

body.theme-light .table-bordered {
    border-color: #e3e6f0 !important;
}

body.theme-light .table-bordered td,
body.theme-light .table-bordered th {
    border-color: #e3e6f0 !important;
}

body.theme-light .table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.05) !important;
}

body.theme-light .sidebar {
    background: linear-gradient(180deg, #4e73df 10%, #224abe 100%) !important;
}

body.theme-light .sidebar .nav-item .nav-link {
    color: #ffffff !important;
    opacity: 1 !important;
}

body.theme-light .sidebar .nav-item .nav-link:hover,
body.theme-light .sidebar .nav-item .nav-link.active {
    color: #ffffff !important;
    opacity: 1 !important;
    background-color: rgba(255, 255, 255, 0.15) !important;
}

body.theme-light .sidebar .nav-item .nav-link span {
    color: #ffffff !important;
    opacity: 1 !important;
}

body.theme-light .sidebar .nav-item .nav-link i {
    color: #ffffff !important;
    opacity: 1 !important;
}

body.theme-light .sidebar-heading {
    color: #ffffff !important;
    opacity: 0.95 !important;
}

body.theme-light .sidebar-brand-text {
    color: #ffffff !important;
}

body.theme-light .topbar {
    background-color: #ffffff !important;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
}

body.theme-light .topbar .nav-link {
    color: #5a5c69 !important;
}

body.theme-light .dropdown-menu {
    background-color: #ffffff !important;
    border-color: #e3e6f0 !important;
}

body.theme-light .dropdown-item {
    color: #5a5c69 !important;
}

body.theme-light .dropdown-item:hover {
    background-color: #f8f9fc !important;
}

body.theme-light .mobile-bottom-nav {
    background-color: #ffffff !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
}

body.theme-light .mobile-bottom-nav .nav-item {
    color: #858796 !important;
}

body.theme-light .mobile-bottom-nav .nav-item.active {
    color: var(--primary-color) !important;
}

body.theme-light .alert-info {
    background-color: #d1ecf1 !important;
    border-color: #bee5eb !important;
    color: #0c5460 !important;
}

body.theme-light .alert-warning {
    background-color: #fff3cd !important;
    border-color: #ffeaa7 !important;
    color: #856404 !important;
}

body.theme-light .alert-success {
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
    color: #155724 !important;
}

body.theme-light .alert-danger {
    background-color: #f8d7da !important;
    border-color: #f5c6cb !important;
    color: #721c24 !important;
}

body.theme-light .modal-content {
    background-color: #ffffff !important;
    color: var(--text-light) !important;
}

body.theme-light .modal-header {
    background-color: #f8f9fc !important;
    border-bottom-color: #e3e6f0 !important;
}

body.theme-light .footer,
body.theme-light .sticky-footer {
    background-color: #ffffff !important;
    color: #858796 !important;
}

/* CRÍTICO: Asegurar que los controles de Leaflet sean visibles en tema claro */
body.theme-light .leaflet-control-zoom a,
body.theme-light .leaflet-control-fullscreen a,
body.theme-light .leaflet-bar a {
    background-color: #ffffff !important;
    color: #333333 !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

body.theme-light .leaflet-control-zoom a:hover,
body.theme-light .leaflet-control-fullscreen a:hover,
body.theme-light .leaflet-bar a:hover {
    background-color: #f4f4f4 !important;
    color: #000000 !important;
}


/* ========================================
   TOPBAR MOBILE IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {

    /* Simplify topbar on mobile */
    .topbar {
        padding: 0.5rem 1rem;
    }

    /* Hide user name text on small screens */
    .topbar .nav-link .mr-2 {
        display: none !important;
    }

    /* Make user icon larger on mobile */
    .topbar .fa-user-circle {
        font-size: 2rem !important;
    }

    /* Adjust dropdown menu position and size */
    .topbar .dropdown-menu {
        right: 0 !important;
        left: auto !important;
        min-width: 220px;
        max-width: 90vw;
        margin-top: 0.5rem;
    }

    /* Make dropdown items touch-friendly */
    .topbar .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Theme selector in dropdown */
    .topbar .theme-selector {
        padding: 0.75rem;
        margin: 0.5rem 0;
    }

    .topbar .theme-option {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    /* Hide topbar divider on mobile */
    .topbar-divider {
        display: none !important;
    }

    /* Ensure dropdown is clickable */
    .topbar .nav-item.dropdown {
        position: relative;
    }

    .topbar .dropdown-toggle {
        padding: 0.5rem;
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Fix z-index for dropdown */
    .topbar .dropdown-menu {
        z-index: 1070;
    }
}

@media (max-width: 576px) {
    .topbar {
        padding: 0.5rem 0.5rem;
    }

    .mobile-menu-toggle {
        margin-right: 5px;
    }

    /* Make dropdown full width on very small screens */
    .topbar .dropdown-menu {
        min-width: 200px;
        max-width: calc(100vw - 20px);
    }
}


/* ========================================
   FORCE SIDEBAR HIDDEN ON MOBILE - CRITICAL
   ======================================== */

/* CRITICAL: Hide sidebar completely on mobile devices with maximum specificity */
@media (max-width: 768px) {

    /* Force hide sidebar with multiple selectors for maximum specificity */
    .sidebar,
    #accordionSidebar,
    ul.navbar-nav.bg-gradient-primary.sidebar,
    .sidebar.accordion {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        pointer-events: none !important;
        z-index: -1 !important;
    }

    /* Ensure content takes full width when sidebar is hidden */
    #content-wrapper,
    .container-fluid {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    #wrapper {
        display: block !important;
        overflow-x: hidden !important;
    }

    #content {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Hide ALL sidebar toggle buttons on mobile */
    #sidebarToggle,
    #sidebarToggleTop,
    .sidebar-toggle,
    button[data-toggle="sidebar"],
    .btn-link.d-md-none {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Hide sidebar brand */
    .sidebar-brand,
    .sidebar-heading {
        display: none !important;
    }

    /* Prevent any sidebar-related spacing */
    body {
        padding-left: 0 !important;
    }
}

/* Force sidebar to be toggled (collapsed) by default on all devices */
body.sidebar-toggled .sidebar {
    width: 0 !important;
    overflow: hidden !important;
}

body.sidebar-toggled #content-wrapper {
    margin-left: 0 !important;
}

/* Ensure mobile nav is always visible on mobile */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1030 !important;
    }
}

/* ADDITIONAL SAFEGUARD: Force hide sidebar on very small screens */
@media (max-width: 576px) {

    .sidebar,
    #accordionSidebar {
        display: none !important;
        width: 0 !important;
        position: absolute !important;
        left: -9999px !important;
    }
}

/* CLOUDFLARED FIX: Ensure sidebar is hidden even if JavaScript hasn't loaded */
@media (max-width: 768px) {

    /* Override any inline styles that might be set */
    .sidebar[style],
    #accordionSidebar[style] {
        display: none !important;
        width: 0 !important;
        left: -9999px !important;
    }
}

/* Botón CREAR resaltado cuando estamos en la página de creación (estado activo) */
.mobile-bottom-nav .nav-item.create-btn.active {
    color: var(--primary-color, #4e73df) !important;
    font-weight: 700;
}

.mobile-bottom-nav .nav-item.create-btn.active i {
    transform: scale(1.15);
}

/* Estilos para autocomplete de calles */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d3e2;
    border-top: none;
    border-radius: 0 0 0.35rem 0.35rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #333;
}

.suggestion-item:hover {
    background-color: #f8f9fc;
}

.suggestion-item i {
    color: #4e73df;
    margin-right: 8px;
}

/* FIX: Ensure Leaflet controls are always visible (Black on White) regardless of theme */
.leaflet-control-zoom a,
.leaflet-control-fullscreen a,
.leaflet-bar a {
    color: #000000 !important;
    background-color: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}

.leaflet-control-zoom a:hover,
.leaflet-control-fullscreen a:hover,
.leaflet-bar a:hover {
    background-color: #f4f4f4 !important;
    color: #000000 !important;
}