/* Estilos generales */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
    font-size: 16px;
}

/* Mejoras para móviles */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .h3 {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .card-header h5 {
        font-size: 1rem;
    }
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem;
}

.card-body {
    padding: 1.25rem;
}

/* Botones */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn i {
    margin-right: 0.25rem;
}

/* Formularios */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.625rem 0.875rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Switches personalizados */
.form-check-input:checked {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* DataTables responsive */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
    margin-left: 0.5rem;
}

.dataTables_length select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    margin: 0 0.5rem;
}

/* Tabla responsive */
.table-responsive {
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0;
    width: 100% !important;
}

table.dataTable thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    padding: 0.75rem;
    white-space: nowrap;
}

table.dataTable tbody td {
    padding: 0.75rem;
    vertical-align: middle;
}

/* Responsive para dispositivos móviles */
@media (max-width: 768px) {
    table.dataTable thead th {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    table.dataTable tbody td {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .card-body {
        padding: 0.875rem;
    }
    
    .form-control,
    .form-select {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

/* Badges */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
    border-radius: 6px;
}

/* Mapa */
#mapa {
    width: 100%;
    height: 300px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    z-index: 1;
}

@media (max-width: 576px) {
    #mapa {
        height: 250px;
    }
}

/* Leaflet popup personalizado */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

/* Alertas */
.alert {
    border-radius: 8px;
    border: none;
    padding: 1rem 1.25rem;
}

.alert i {
    margin-right: 0.5rem;
}

/* Modal */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-radius: 12px 12px 0 0;
    border-bottom: none;
    padding: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: none;
    padding: 1rem 1.5rem 1.25rem;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease-in-out;
}

/* Mejoras touch para móviles */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .form-check-label,
    a {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* DataTables búsqueda y paginación en móviles */
@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: center;
        margin-bottom: 1rem;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        max-width: 300px;
        margin: 0.5rem 0;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        margin-top: 1rem;
    }
}

/* Mejoras para controles de DataTable en móvil */
@media (max-width: 576px) {
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_paginate {
        text-align: center;
    }
    
    .dataTables_length label,
    .dataTables_filter label {
        display: block;
        margin-bottom: 0.5rem;
    }
}

/* Espaciado responsive */
.mb-responsive {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .mb-responsive {
        margin-bottom: 0.5rem;
    }
}

/* Grid responsive para características */
@media (max-width: 576px) {
    .row > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Iconos en tablas */
.table i {
    font-size: 0.9rem;
}

/* Loader para mapa */
#mapa:empty:before {
    content: "Cargando mapa...";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
}

/* Texto truncado en móvil */
@media (max-width: 576px) {
    .text-truncate-mobile {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
