/* ==== STILI SPECIFICI PER IL GRAFO ==== */

/* Layout del Container Grafo */
.container {
    display: flex;
    gap: 1.5rem;
    min-height: calc(100vh - 200px);
    align-items: flex-start;
}

/* ==== SIDEBAR SINISTRA GRAFO ==== */
.grafo-sidebar {
    width: 310px;
    opacity: 1;
    pointer-events: all;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 1rem;
}

/* Sezioni della Sidebar */
.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-section h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-family: var(--font-medium);
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==== RICERCA E NAVIGAZIONE ==== */
.search-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-field {
    flex: 1;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    font-family: var(--font-book);
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #ffffff;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.search-field:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.search-field::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-family: var(--font-medium);
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.search-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Navigazione e Breadcrumb */
.navigation-history {
    font-size: 0.85rem;
}

.nav-breadcrumb {
    margin-bottom: 0.8rem;
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.8);
    min-height: 1.5rem;
}

.recent-nodes {
    margin-top: 0.5rem;
}

.section-label {
    display: block;
    font-family: var(--font-medium);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.recent-node {
    padding: 0.2rem 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.recent-node:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* ==== CONTROLLI VISUALIZZAZIONE ==== */
.controls-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.control-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font-medium);
    min-width: fit-content;
}

/* Controlli Zoom */
.zoom-controls {
    display: flex;
    gap: 0.3rem;
}

.control-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-family: var(--font-medium);
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-width: 2rem;
    text-align: center;
}

.control-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
}

.toggle-btn.active {
    background-color: rgba(255, 107, 53, 0.8);
    border-color: rgba(255, 107, 53, 1);
    color: #ffffff;
}

/* Slider Controls */
.slider-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: 2px solid rgba(26, 66, 69, 0.8);
}

.slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: 2px solid rgba(26, 66, 69, 0.8);
}

.slider-value {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    min-width: 30px;
    text-align: center;
    font-family: var(--font-medium);
}

/* Select Control */
.select-control {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-family: var(--font-book);
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
}

.select-control:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.select-control option {
    background-color: rgba(26, 66, 69, 0.95);
    color: #ffffff;
}

/* ==== STATISTICHE GRAFO ==== */
.graph-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
}

.stat-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-book);
}

.stat-value {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.95);
    font-family: var(--font-medium);
}

/* ==== AREA CENTRALE GRAFO ==== */
.colonna-centrale {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px);
}

.grafo-canvas-area {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
}

/* Header del Grafo */
.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.graph-title h3 {
    margin: 0;
    font-size: 1.3rem;
    font-family: var(--font-heavy);
    color: #ffffff;
}

.graph-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-book);
}

.graph-toolbar {
    display: flex;
    gap: 0.5rem;
}

.toolbar-btn {
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Canvas del Grafo */
.graph-canvas {
    flex: 1;
    background-color: #ffffff;
    position: relative;
    min-height: 500px;
}

/* ==== SIDEBAR DESTRA DETTAGLI ==== */
.grafo-details-sidebar {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 1rem;
}

/* Pannelli Dettagli */
.details-panel {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.panel-header h4 {
    margin: 0;
    font-size: 1rem;
    font-family: var(--font-medium);
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-close {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.panel-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.panel-content {
    padding: 0.8rem;
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

/* Dettagli Nodo */
.node-info-section {
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.node-info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.node-info-title {
    font-family: var(--font-medium);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.node-info-item {
    margin: 0.3rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.node-info-label {
    font-family: var(--font-medium);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
}

.node-info-value {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.8rem;
}

/* Lista Nodi Collegati */
.neighbor-item {
    padding: 0.6rem;
    margin: 0.3rem 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.neighbor-item:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.neighbor-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.neighbor-label {
    flex-grow: 1;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.3;
}

.neighbor-degree {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-medium);
}

/* ==== RESPONSIVE DESIGN ==== */

/* Ottimizzazioni per schermi molto grandi - grafo dominante */
@media (min-width: 1600px) {
    .grafo-sidebar {
        width: 310px;
    }
    
    .grafo-details-sidebar {
        width: 200px;
    }
    
    .container {
        gap: 1.2rem;
    }
    
    .sidebar-section {
        margin-bottom: 1.2rem;
        padding-bottom: 0.8rem;
    }
    
    .panel-content {
        padding: 0.7rem;
        font-size: 0.8rem;
    }
    
    .neighbor-item {
        padding: 0.5rem;
        gap: 0.6rem;
    }
}

@media (max-width: 1400px) {
    .grafo-sidebar {
        width: 310px;
    }
    
    .grafo-details-sidebar {
        width: 220px;
    }
}

@media (max-width: 1200px) {
    .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .grafo-sidebar {
        width: 100%;
        max-height: none;
        position: static;
        order: 2;
    }
    
    .colonna-centrale {
        order: 1;
        min-height: 60vh;
    }
    
    .grafo-details-sidebar {
        width: 100%;
        order: 3;
        position: static;
        max-height: none;
        flex-direction: row;
        gap: 1rem;
    }
    
    .details-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .graph-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .grafo-details-sidebar {
        flex-direction: column;
    }
    
    .sidebar-section {
        margin-bottom: 1rem;
    }
    
    .control-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .zoom-controls {
        justify-content: center;
    }
}

/* ==== ANIMAZIONI E TRANSIZIONI ==== */
.grafo-details-sidebar {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.grafo-details-sidebar.hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

.neighbor-item {
    transition: all 0.2s ease;
}

.control-btn, .toolbar-btn {
    transition: all 0.2s ease;
}

/* Scroll personalizzato per le sidebar */
.grafo-sidebar::-webkit-scrollbar,
.grafo-details-sidebar::-webkit-scrollbar {
    width: 6px;
}

.grafo-sidebar::-webkit-scrollbar-track,
.grafo-details-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.grafo-sidebar::-webkit-scrollbar-thumb,
.grafo-details-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.grafo-sidebar::-webkit-scrollbar-thumb:hover,
.grafo-details-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ==== LOADING OVERLAY ==== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(26, 66, 69, 0.95), rgba(26, 66, 69, 0.98));
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    max-width: 500px;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.loading-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.4rem;
    font-family: var(--font-heavy);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.loading-header p {
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font-book);
}

/* Progress Bar */
.loading-progress-container {
    margin-bottom: 1.5rem;
}

.loading-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    position: relative;
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4A9EFF, #FF6B35);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.loading-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent
    );
    animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.loading-percentage {
    text-align: center;
}

.loading-percentage span {
    font-size: 1.1rem;
    color: #ffffff;
    font-family: var(--font-medium);
}

/* Loading Details */
.loading-details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.loading-detail-label {
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-book);
}

.loading-detail-item span:last-child {
    color: rgba(255, 255, 255, 0.95);
    font-family: var(--font-medium);
    max-width: 60%;
    text-align: right;
    word-break: break-word;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #4A9EFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive design for loading overlay */
@media (max-width: 768px) {
    .loading-content {
        max-width: 90%;
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .loading-header h3 {
        font-size: 1.2rem;
    }
    
    .loading-details {
        padding: 0.8rem;
    }
    
    .loading-detail-item {
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
    
    .loading-detail-item span:last-child {
        max-width: 100%;
        text-align: left;
    }
}

@media (max-width: 480px) {
    .loading-content {
        padding: 1rem;
    }
    
    .loading-header h3 {
        font-size: 1.1rem;
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .loading-header p {
        font-size: 0.9rem;
    }
}
