/* CheckGuard Custom Styles */

/* Primary Colors Override */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
}

/* Sidebar Profile Enhancement */
.sidebar-user-profile {
    text-align: center;
    padding: 1.5rem;
}

.sidebar-user-profile .icon-box {
    width: 70px;
    height: 70px;
    margin: 0 auto;
}

/* Card Enhancements */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

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

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Stats Cards */
.stats-card {
    border-radius: 0.75rem;
    overflow: hidden;
}

.stats-card .icon-box {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

/* Data Tables Enhancement */
.table-container {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
}

.table thead th {
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Action Buttons */
.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
}

.btn-action-group {
    display: flex;
    gap: 0.5rem;
}

/* Status Badges */
.badge-status {
    padding: 0.375rem 0.75rem;
    font-weight: 500;
    font-size: 0.75rem;
    border-radius: 9999px;
}

.badge-active {
    background-color: #dcfce7;
    color: #166534;
}

.badge-inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-pending {
    background-color: #fef3c7;
    color: #92400e;
}

/* Modal Enhancements */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 1rem 1.5rem;
}

/* Form Enhancements */
.form-control, .form-select {
    border-radius: 0.5rem;
    border-color: #e2e8f0;
    padding: 0.625rem 1rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-label {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.page-subtitle {
    color: #64748b;
    margin: 0.25rem 0 0;
}

/* Breadcrumb */
.breadcrumb-custom {
    background: transparent;
    padding: 0;
    margin: 0;
}

.breadcrumb-custom .breadcrumb-item a {
    color: #64748b;
    text-decoration: none;
}

.breadcrumb-custom .breadcrumb-item.active {
    color: #1e293b;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    font-size: 4rem;
    color: #e2e8f0;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Dashboard Widgets */
.widget-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 1rem;
    color: white;
    padding: 1.5rem;
}

.widget-card .widget-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-card .widget-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.widget-card .widget-label {
    opacity: 0.9;
    font-size: 0.875rem;
}

/* Quick Stats */
.quick-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 0.75rem;
    border: 1px solid #f1f5f9;
}

.quick-stat .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.quick-stat .stat-label {
    color: #64748b;
    font-size: 0.875rem;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .page-title {
        font-size: 1.25rem;
    }

    .widget-card .widget-value {
        font-size: 1.5rem;
    }

    .quick-stat .stat-value {
        font-size: 1.25rem;
    }
}

/* Print Styles */
@media print {
    .sidebar-wrapper,
    .app-header,
    .app-footer,
    .btn,
    .no-print {
        display: none !important;
    }

    .app-container {
        margin: 0 !important;
        padding: 0 !important;
    }

    .app-body {
        padding: 0 !important;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Tooltip Custom */
.tooltip-custom {
    position: relative;
}

.tooltip-custom::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #1e293b;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.tooltip-custom:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   CHECKGUARD MAPS - Leaflet Custom Styles
   ============================================================================ */

/* Contenedor del mapa */
.map-container {
    height: 500px;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
}

.map-container-lg {
    height: 600px;
}

.map-container-sm {
    height: 400px;
}

/* Split Panel para Zonas */
.map-split-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    min-height: 500px;
}

@media (max-width: 992px) {
    .map-split-panel {
        grid-template-columns: 1fr;
    }
}

/* Marcador personalizado de Zona */
.custom-zone-marker {
    background: transparent !important;
    border: none !important;
}

.custom-zone-marker .marker-pin {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -20px 0 0 -20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    animation: bounce 2s infinite;
}

.custom-zone-marker .marker-pin i {
    transform: rotate(45deg);
    color: white;
    font-size: 20px;
}

.custom-zone-marker .marker-pulse {
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    position: absolute;
    left: 0;
    top: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: rotate(-45deg) translateY(0);
    }
    50% {
        transform: rotate(-45deg) translateY(-10px);
    }
}

/* Marcador personalizado de Checkpoint */
.custom-checkpoint-marker {
    background: transparent !important;
    border: none !important;
}

.custom-checkpoint-marker .checkpoint-pin {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -20px 0 0 -20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
}

.custom-checkpoint-marker .checkpoint-pin i {
    transform: rotate(45deg);
    color: white;
    font-size: 18px;
}

.custom-checkpoint-marker .checkpoint-pulse {
    width: 40px;
    height: 40px;
    background: rgba(245, 158, 11, 0.3);
    border-radius: 50%;
    position: absolute;
    left: 0;
    top: 0;
    animation: pulse 2s infinite;
}

/* Marcador de referencia de zona */
.zone-reference-marker {
    background: transparent !important;
    border: none !important;
}

.zone-reference-marker .zone-ref-pin {
    width: 30px;
    height: 30px;
    background: rgba(102, 126, 234, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.zone-reference-marker .zone-ref-pin i {
    color: white;
    font-size: 14px;
}

/* Marcadores de Patrullaje */
.patrol-checkpoint-marker {
    background: transparent !important;
    border: none !important;
}

.patrol-checkpoint-marker .patrol-marker-pin {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    border: 3px solid white;
    position: relative;
    z-index: 10;
}

.patrol-checkpoint-marker .marker-number {
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.patrol-checkpoint-marker .patrol-marker-shadow {
    width: 40px;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    position: absolute;
    bottom: -5px;
    left: 0;
    filter: blur(4px);
}

/* Ruta de patrullaje animada */
.patrol-route-animated {
    animation: dash 20s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -100;
    }
}

/* Marcador de animación */
.animation-marker {
    background: transparent !important;
    border: none !important;
}

.animation-marker .anim-pin {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.5);
    border: 3px solid white;
    animation: moveMarker 1s ease-in-out infinite;
}

.animation-marker .anim-pin i {
    color: white;
    font-size: 16px;
}

@keyframes moveMarker {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Popup personalizado de checkpoint */
.custom-patrol-popup .leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 0;
    overflow: hidden;
}

.custom-patrol-popup .leaflet-popup-content {
    margin: 0;
    width: 280px !important;
}

.patrol-checkpoint-popup .popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 1rem;
    font-weight: 600;
}

.patrol-checkpoint-popup .popup-body {
    padding: 1rem;
}

.patrol-checkpoint-popup .popup-body p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.patrol-checkpoint-popup .popup-body i {
    color: #667eea;
    flex-shrink: 0;
}

.patrol-checkpoint-popup .checkpoint-photo {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-top: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.patrol-checkpoint-popup .checkpoint-photo:hover {
    transform: scale(1.05);
}

.patrol-checkpoint-popup .popup-footer {
    background: #f8fafc;
    padding: 0.5rem 1rem;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.patrol-checkpoint-popup .popup-footer small {
    color: #64748b;
    font-size: 0.75rem;
}

/* Controles del mapa mejorados */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
    border-radius: 0.5rem !important;
    font-size: 18px !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    border: none !important;
}

.leaflet-control-zoom a:first-child {
    border-bottom: 1px solid #e2e8f0 !important;
}

.leaflet-control-zoom a:hover {
    background: #667eea !important;
    color: white !important;
}

/* Timeline de patrullaje (para fase 3) */
.patrol-timeline {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.patrol-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.patrol-timeline-controls {
    display: flex;
    gap: 0.5rem;
}

.timeline-slider {
    width: 100%;
    height: 60px;
    position: relative;
}

.timeline-track {
    position: absolute;
    top: 30px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #10b981 100%);
    border-radius: 2px;
}

.timeline-point {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid #667eea;
    border-radius: 50%;
    top: 22px;
    transform: translateX(-50%);
    cursor: pointer;
    transition: all 0.2s;
}

.timeline-point:hover {
    transform: translateX(-50%) scale(1.3);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.timeline-point.active {
    background: #667eea;
    transform: translateX(-50%) scale(1.5);
}

/* Métricas de patrullaje */
.patrol-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.patrol-metric-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    text-align: center;
}

.patrol-metric-card .metric-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
}

.patrol-metric-card .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.patrol-metric-card .metric-label {
    color: #64748b;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Botones de control de animación */
.animation-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.animation-controls .btn-play {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.animation-controls .btn-play:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.animation-controls .speed-selector {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Marcador para reportes de checkpoints (simple, solo lectura) */
.report-checkpoint-marker {
    background: transparent !important;
    border: none !important;
}

.report-checkpoint-marker .report-marker-pin {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -20px 0 0 -20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
}

.report-checkpoint-marker .report-marker-pin i {
    transform: rotate(45deg);
    color: white;
    font-size: 20px;
}

/* Responsive para mapas */
@media (max-width: 768px) {
    .map-container {
        height: 400px;
    }

    .map-container-lg {
        height: 450px;
    }

    .patrol-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .custom-patrol-popup .leaflet-popup-content {
        width: 240px !important;
    }
}
