/* ============================================================
   CYBER RANGE - BULLETPROOF FIXED LAYOUT (FINAL SCALED)
   ============================================================ */
.cr-body {
    background-color: #020202;
    background-image: linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Courier New', monospace;
}

/* --- HEADER E FOOTER --- */
.cr-header { background: #000; border-bottom: 1px solid #222; padding: 15px 20px; box-shadow: 0 2px 15px rgba(0,0,0,0.8); z-index: 10; }
.cr-header-content { max-width: 1600px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.back-link { color: #888; text-decoration: none; margin-right: 15px; transition: 0.3s; }
.back-link:hover { color: #00d4ff; }
.user-host { color: #00ff00; }
.current-dir { color: #0088ff; }
.header-center-title h2 { color: #00d4ff; margin: 0; font-size: 1.2rem; text-shadow: 0 0 10px rgba(0, 212, 255, 0.3); }

.cr-footer { background: #000; border-top: 1px solid #222; padding: 15px 20px; margin-top: auto; }
.cr-footer-content { max-width: 1600px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.footer-brand h3 { color: #00ff00; margin: 0; font-size: 1rem; }
.footer-brand p { color: #888; font-size: 0.7rem; margin: 5px 0 0 0; }
.social-icon { color: #00ff00; font-size: 1.2rem; margin-left: 15px; text-decoration: none; transition: 0.3s; }
.social-icon:hover { color: #fff; }

/* --- MAIN LAYOUT --- */
.cr-layout {
    display: flex;
    flex-direction: row;
    gap: 40px;
    padding: 30px;
    max-width: 1700px; /* Leggermente più largo per ospitare il lab ingrandito */
    margin: 0 auto;
    flex: 1; 
    width: 100%;
    box-sizing: border-box;
    align-items: flex-start;
}

/* --- SIDEBAR SINISTRA (FISSA) --- */
.cr-sidebar { width: 350px; flex-shrink: 0; display: flex; flex-direction: column; gap: 30px; }
.intel-brief { background: rgba(10, 10, 10, 0.9); border: 1px solid #222; border-left: 3px solid #00d4ff; padding: 20px; box-shadow: 0 5px 20px rgba(0,0,0,0.5); }
#phil-title { color: #00d4ff; font-size: 1rem; margin-bottom: 5px; }
.phil-sub { color: #777; font-size: 0.75rem; margin-bottom: 15px; }
.phil-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.phil-list li { color: #ccc; font-size: 0.75rem; background: rgba(0,0,0,0.5); padding: 10px; border: 1px solid #111; line-height: 1.4;}
.highlight-blue { color: #00d4ff; font-weight: bold; display: block; margin-bottom: 5px; }
.highlight-red { color: #ff3e3e; font-weight: bold; display: block; margin-bottom: 5px; }
.highlight-green { color: #00ff41; font-weight: bold; display: block; margin-bottom: 5px; }
.highlight-purple { color: #b700ff; font-weight: bold; display: block; margin-bottom: 5px; }

.live-traffic-monitor { background: #020202; border: 1px solid #222; display: flex; flex-direction: column; height: 300px; }
.traffic-header { background: #111; padding: 8px 15px; font-size: 0.7rem; color: #888; border-bottom: 1px solid #222; display: flex; justify-content: space-between; }
.traffic-log { padding: 10px 15px; overflow-y: auto; font-size: 0.7rem; color: #555; display: flex; flex-direction: column; gap: 5px; }
.log-atk { color: #ff3e3e; }
.log-def { color: #00ff41; }
.pulse-dot-cyan { width: 8px; height: 8px; background: #00d4ff; border-radius: 50%; box-shadow: 0 0 8px #00d4ff; animation: pulse-glow-cyan 1.5s infinite; }

/* --- COLONNA DESTRA (RETE E METRICHE) --- */
.cr-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0; 
}

/* CONTENITORE MAPPA */
.topology-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    overflow-x: auto; 
    padding-bottom: 20px;
}

/* FIREWALL */
.fw-node { margin-bottom: 30px; position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.fw-box { display: inline-block; background: rgba(0, 255, 65, 0.05); border: 1px solid #00ff41; border-top: 3px solid #00ff41; padding: 15px 40px; color: #00ff41; box-shadow: 0 0 20px rgba(0, 255, 65, 0.1); cursor: pointer; transition: 0.3s; text-align: center; font-size: 1.1rem;}
.fw-box:hover { transform: translateY(-2px); box-shadow: 0 0 30px rgba(0, 255, 65, 0.3); }
.fw-box span { display: block; font-size: 0.75rem; color: #888; margin-top: 5px; }

/* Cavo dorsale verticale */
.fw-node::after {
    content: ''; position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%);
    width: 2px; height: 30px; background: linear-gradient(180deg, #00ff41, rgba(255,255,255,0.4));
    animation: dataFlowDown 2s infinite linear;
}

/* GRIGLIA MACCHINE SCALATA */
.subnet-grid {
    display: flex;
    flex-direction: row;
    gap: 25px; /* Aumentato lo spazio tra le card */
    padding-top: 30px;
    position: relative;
}

/* Cavo dorsale Orizzontale */
.subnet-grid::before {
    content: ''; position: absolute; top: 0; 
    left: 100px; /* Esattamente la metà della nuova larghezza della card (200px) */
    right: 100px; 
    height: 2px; background: rgba(255,255,255,0.4);
}

.subnet-card {
    width: 200px; /* CARD INGRANDITA: da 160px a 200px */
    flex-shrink: 0; 
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid #222;
    padding: 18px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    box-sizing: border-box;
}

/* Cavo verticale che scende alla card */
.subnet-card::before {
    content: ''; position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
    width: 2px; height: 30px; background: rgba(255,255,255,0.4);
}

.subnet-header { font-size: 0.8rem; font-weight: bold; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px dashed rgba(255,255,255,0.1); text-shadow: 0 0 8px currentColor; }
.subnet-attack { border-top: 3px solid #ff3e3e; box-shadow: 0 -2px 15px rgba(255, 62, 62, 0.1); } .subnet-attack .subnet-header { color: #ff3e3e; }
.subnet-corp { border-top: 3px solid #00d4ff; box-shadow: 0 -2px 15px rgba(0, 212, 255, 0.1); } .subnet-corp .subnet-header { color: #00d4ff; }
.subnet-soc { border-top: 3px solid #00ff41; box-shadow: 0 -2px 15px rgba(0, 255, 65, 0.1); } .subnet-soc .subnet-header { color: #00ff41; }
.subnet-dmz { border-top: 3px solid #ffaa00; box-shadow: 0 -2px 15px rgba(255, 170, 0, 0.1); } .subnet-dmz .subnet-header { color: #ffaa00; }
.subnet-malware { border-top: 3px solid #b700ff; box-shadow: 0 -2px 15px rgba(183, 0, 255, 0.1); } .subnet-malware .subnet-header { color: #b700ff; }

.vm-node { background: rgba(0, 0, 0, 0.8); padding: 12px 15px; margin-bottom: 12px; border: 1px solid #222; border-left: 3px solid #444; cursor: pointer; transition: 0.3s; position: relative; }
.vm-node:hover { background: rgba(20, 20, 20, 0.9); border-color: #555; border-left-color: #fff; transform: translateX(3px); }
.vm-name { font-size: 0.8rem; color: #ddd; display: flex; align-items: center; gap: 8px; font-weight: bold; }
.vm-status { font-size: 0.65rem; color: #00ff41; display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.dot { width: 5px; height: 5px; background: #00ff41; border-radius: 50%; box-shadow: 0 0 5px #00ff41; animation: pulse-glow-green 2s infinite; }

.vm-node.active-attack { border-color: #ff3e3e; background: rgba(255, 62, 62, 0.1); box-shadow: 0 0 20px rgba(255, 62, 62, 0.6); transform: scale(1.05); }
.vm-node.active-target { animation: shake-alert 0.4s both; border-color: #ffaa00; box-shadow: 0 0 15px rgba(255, 170, 0, 0.5); }
.vm-node.active-defense { border-color: #00ff41; background: rgba(0, 255, 65, 0.1); box-shadow: 0 0 25px rgba(0, 255, 65, 0.8); transform: scale(1.05); }
@keyframes shake-alert { 20%, 80% { transform: translate3d(2px, 0, 0); } 40%, 60% { transform: translate3d(-2px, 0, 0); } }
@keyframes pulse-glow-cyan { 0%, 100% { opacity: 1; box-shadow: 0 0 5px #00d4ff; } 50% { opacity: 0.3; box-shadow: 0 0 15px #00d4ff; } }
@keyframes dataFlowDown { 0% { opacity: 0.3; background-position: 0 -30px; } 50% { opacity: 1; } 100% { opacity: 0.3; background-position: 0 30px; } }

/* --- METRICHE HYPERVISOR --- */
.datacenter-metrics { 
    margin-top: 100px; /* SPINTO PIÙ IN BASSO */
    background: rgba(5, 5, 5, 0.8); 
    border: 1px solid #222; 
    border-left: 3px solid #00ff41; 
    padding: 20px 30px; 
    width: 100%; 
    max-width: 1100px; /* ALLARGATO IN PROPORZIONE ALLA RETE */
    box-shadow: 0 5px 20px rgba(0,0,0,0.4); 
    box-sizing: border-box; 
}
.metrics-header { display: flex; justify-content: space-between; color: #888; font-size: 0.8rem; border-bottom: 1px dashed #333; padding-bottom: 10px; margin-bottom: 20px; }
.metric-row { margin-bottom: 15px; }
.metric-info { display: flex; justify-content: space-between; font-size: 0.8rem; color: #ccc; margin-bottom: 5px; }
.metric-bar-bg { width: 100%; height: 5px; background: #111; border-radius: 2px; overflow: hidden; }
.metric-bar-fill { height: 100%; }
.cpu-fill { background: #00d4ff; width: 24%; box-shadow: 0 0 8px #00d4ff; animation: pulse-cpu 4s infinite alternate; }
.ram-fill { background: #ffaa00; width: 68%; box-shadow: 0 0 8px #ffaa00; }
.net-fill { background: #00ff41; width: 45%; box-shadow: 0 0 8px #00ff41; animation: pulse-net 2s infinite alternate; }
@keyframes pulse-cpu { 0% { width: 24%; } 50% { width: 35%; } 100% { width: 18%; } }
@keyframes pulse-net { 0% { width: 45%; } 50% { width: 85%; } 100% { width: 30%; } }

/* --- MODALE --- */
#node-modal { display: none !important; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px); z-index: 999999; justify-content: center; align-items: center; }
#node-modal.show-modal { display: flex !important; }
.node-modal-content { background: #020202; border: 1px solid #333; width: 90%; max-width: 650px; box-shadow: 0 0 50px rgba(0, 212, 255, 0.15), inset 0 0 20px rgba(0, 212, 255, 0.05); font-family: 'Courier New', monospace; position: relative; overflow: hidden; animation: modalBoot 0.3s ease-out; }
@keyframes modalBoot { 0% { opacity: 0; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1); } }
.node-modal-content::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: #00d4ff; box-shadow: 0 0 15px #00d4ff; }
.modal-header { background: rgba(0, 212, 255, 0.05); color: #fff; padding: 15px 25px; border-bottom: 1px solid rgba(0, 212, 255, 0.2); display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 1.2rem; }
.modal-header::before { content: '> TARGET:'; color: #00d4ff; font-size: 0.8rem; margin-right: 10px; }
.close-sim { background: none; border: none; color: #888; font-size: 1.2rem; cursor: pointer; }
.close-sim:hover { color: #ff3e3e; }
.modal-body { padding: 30px 25px; position: relative; }
.tech-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 25px; background: rgba(255, 255, 255, 0.02); padding: 15px; border: 1px solid #111; border-radius: 4px; }
.tech-row { display: flex; flex-direction: column; gap: 5px; }
.tech-label { color: #666; font-size: 0.75rem; }
.tech-value { color: #00d4ff; font-size: 0.95rem; font-weight: bold; }
.tech-desc-box { border-left: 3px solid #ffaa00; padding-left: 15px; background: linear-gradient(90deg, rgba(255, 170, 0, 0.05) 0%, transparent 100%); padding-top: 10px; padding-bottom: 10px; }
.tech-desc-box .tech-label { color: #ffaa00; margin-bottom: 10px; display: block; }
#modal-desc-list { list-style: none; padding: 0; margin: 0; }
#modal-desc-list li { color: #ccc; font-size: 0.85rem; line-height: 1.6; position: relative; padding-left: 20px; margin-bottom: 8px; }
#modal-desc-list li::before { content: '>'; position: absolute; left: 0; color: #555; }

/* ============================================================
   --- RESPONSIVE MOBILE E TABLET (BLINDATO) ---
   ============================================================ */

/* TABLET E SCHERMI MEDI (sotto i 1400px) */
@media (max-width: 1400px) {
    .cr-layout { 
        flex-direction: column; 
        align-items: center; 
        padding: 20px;
    }
    .cr-sidebar { 
        width: 100%; 
        max-width: 100%; 
        flex-direction: column; /* Senza il monitor, la filosofia si prende tutto lo spazio */
    }
    .intel-brief { 
        width: 100%; 
        box-sizing: border-box;
    }
    
    /* NASCONDI IL MONITOR DEL TRAFFICO COME RICHIESTO */
    .live-traffic-monitor { 
        display: none !important; 
    }
    
    .header-center-title { display: none; }
    
    /* FIX TOPOLOGIA: Permette lo swipe orizzontale (scroll) col dito senza rompere la pagina */
    .cr-main-content {
        width: 100%;
        max-width: 100vw;
        overflow: hidden; /* Evita che lo scroll influenzi l'intero body */
    }
    .topology-wrapper { 
        align-items: flex-start; /* Cruciale: fa partire lo scroll da sinistra, non dal centro */
        padding-left: 20px;
        padding-right: 20px;
        box-sizing: border-box;
    }
}

/* SMARTPHONE (sotto gli 850px) */
@media (max-width: 850px) {
    .cr-layout {
        padding: 15px 10px;
        gap: 20px;
    }
    
    /* Adatta il widget dell'hypervisor */
    .datacenter-metrics {
        margin-top: 40px;
        padding: 15px;
    }
    .metrics-header {
        flex-direction: column;
        gap: 8px;
        align-items: center;
        text-align: center;
    }
    
    /* Riorganizza il footer per schermi stretti */
    .cr-footer-content { 
        flex-direction: column; 
        gap: 15px; 
        text-align: center; 
    }
    .social-icon {
        margin: 0 10px;
    }
}