/**
 * Grafos - Network Viewer Styles
 * Bootstrap 5 / Cassiopeia & Atum Compatible
 * Optimizado para pantalla completa
 * Mobile-First Responsive Design
 *
 * @package     Grafos
 * @subpackage  Site
 * @author      Lic. Joel Salazar
 */

/* Main Container - Fullscreen Optimized */
.grafos-network-viewer {
    padding: 0;
    margin: 0;
}

/* Cassiopeia Frontend - Remove default padding */
.com_grafos .grafos-fullscreen {
    margin-left: calc(-1 * var(--cassiopeia-container-padding-x, 1rem));
    margin-right: calc(-1 * var(--cassiopeia-container-padding-x, 1rem));
    width: calc(100% + 2 * var(--cassiopeia-container-padding-x, 1rem));
}

/* Atum Backend - Remove admin padding */
.com_cpanel .grafos-fullscreen,
body.admin .grafos-fullscreen {
    margin: -1rem -1rem 0 -1rem;
}

/* Gephi Container - Fullscreen Height Optimized */
.gephi-network-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 220px);
    /* Ajustado para mejor uso del espacio */
    min-height: 650px;
    /* Reducido para mejor compatibilidad */
    background: var(--bs-light, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0;
    overflow: hidden;
    margin: 0;
    /* Mejora de rendimiento para iframe */
    will-change: transform;
    transform: translateZ(0);
}

.gephi-network-container iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Loading State */
.gephi-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.gephi-network-container.loaded .gephi-loading {
    opacity: 0;
    pointer-events: none;
}

.gephi-loading p {
    font-size: 1rem;
    color: var(--bs-secondary, #6c757d);
    font-weight: 500;
}

/* Help Button - Abajo derecha */
.gephi-help-button-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.gephi-help-button-container .btn {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    background: white;
    border-width: 2px;
}

.gephi-help-button-container .btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* Help Panel - Pantalla completa */
.gephi-help-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gephi-help-fullscreen.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.help-content-wrapper {
    background: white;
    border-radius: 1rem;
    max-width: 1200px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.help-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 1rem 1rem 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-header h2 {
    margin: 0;
    font-size: 2rem;
}

.help-header .btn {
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.75rem 2rem;
}

.help-body {
    padding: 3rem;
}

.help-card {
    background: var(--bs-light, #f8f9fa);
    padding: 1.5rem;
    border-radius: 0.5rem;
    height: 100%;
    border-left: 4px solid var(--bs-primary, #0d6efd);
}

.help-card h4 {
    color: var(--bs-primary, #0d6efd);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.help-card ul {
    list-style: none;
    padding-left: 0;
}

.help-card li {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.help-card li:last-child {
    border-bottom: none;
}

.help-footer {
    background: var(--bs-light, #f8f9fa);
    padding: 2rem;
    border-radius: 0 0 1rem 1rem;
    text-align: center;
    border-top: 2px solid var(--bs-border-color, #dee2e6);
}

.help-footer .form-check-input {
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
}

.help-footer .form-check-label {
    cursor: pointer;
    margin-left: 0.5rem;
}

/* Fullscreen Mode */
.gephi-network-container:fullscreen,
.gephi-network-container:-webkit-full-screen,
.gephi-network-container:-moz-full-screen,
.gephi-network-container:-ms-fullscreen {
    height: 100vh !important;
    background: white;
}

/* Responsive Breakpoints */
@media (max-width: 991.98px) {
    .gephi-network-container {
        height: 700px;
    }

    .gephi-help-panel {
        width: 300px;
    }
}

@media (max-width: 767.98px) {
    .grafos-network-viewer {
        padding: 1rem 0;
    }

    .gephi-network-container {
        height: 600px;
    }

    .help-content-wrapper {
        width: 95%;
        max-height: 95vh;
    }

    .help-header {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1rem;
    }

    .help-header h2 {
        font-size: 1.5rem;
    }

    .help-body {
        padding: 1.5rem;
    }

    .help-card {
        padding: 1rem;
    }

    .help-card h4 {
        font-size: 1.1rem;
    }
}

@media (max-width: 575.98px) {
    .gephi-network-container {
        height: 500px;
    }

    .help-header h2 {
        font-size: 1.25rem;
    }

    .help-body {
        padding: 1rem;
    }

    .help-footer {
        padding: 1rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gephi-network-container {
        background: var(--bs-dark, #212529);
        border-color: var(--bs-border-color-translucent, rgba(255, 255, 255, 0.15));
    }

    .gephi-help-panel {
        background: var(--bs-dark, #212529);
        color: var(--bs-light, #f8f9fa);
    }
}

/* Print Styles */
@media print {

    .gephi-help-overlay,
    .card:has(.btn),
    .alert {
        display: none !important;
    }

    .gephi-network-container {
        height: 600px;
        page-break-inside: avoid;
        border: 1px solid #000;
    }
}

/* Accessibility */
.gephi-help-overlay .btn:focus {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
}

.gephi-network-container iframe:focus {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: -2px;
}

/* ============================================
   Timeline Viewer Styles
   Based on research: temporal network visualization
   ============================================ */

#sigma-container {
    width: 100%;
    height: calc(100vh - 300px);
    min-height: 500px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 8px;
    position: relative;
}

.timeline-controls {
    background: var(--bs-white, #fff);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.timeline-slider-container {
    padding: 0 10px;
}

#timeline-slider {
    width: 100%;
    height: 8px;
    cursor: pointer;
}

#timeline-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    background: var(--bs-primary, #0d6efd);
    border-radius: 50%;
    cursor: grab;
}

#timeline-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
}

.digital-clock {
    min-width: 120px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

.timeline-stats .badge {
    font-size: 0.85rem;
    padding: 0.5em 0.75em;
}

/* ============================================
   GeoNetwork Viewer Styles
   Based on research: geographic network visualization
   ============================================ */

#map-container {
    width: 100%;
    height: calc(100vh - 280px);
    min-height: 500px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Leaflet customizations for better network visibility */
.leaflet-marker-icon {
    transition: transform 0.2s ease;
}

.leaflet-marker-icon:hover {
    transform: scale(1.2);
    z-index: 1000 !important;
}

/* Cluster styling */
.marker-cluster-small {
    background-color: rgba(102, 126, 234, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(102, 126, 234, 0.8);
}

.marker-cluster-medium {
    background-color: rgba(118, 75, 162, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(118, 75, 162, 0.8);
}

.marker-cluster-large {
    background-color: rgba(230, 126, 34, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(230, 126, 34, 0.8);
}

/* ============================================
   Animation utilities
   ============================================ */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}
