/*//////////////////////////////////////////////////////////////////////////////
//
//  DIAGRAM.CSS - MERGED EDITION
//  1. Sidebar & Layout & Background: Deep Dark / Emerald (from V4)
//  2. Hardware Elements: Original Colors (Preserved)
//
//////////////////////////////////////////////////////////////////////////////*/

:root {
    /* --- V4 NEW THEME COLORS (Deep Dark / Emerald) --- */
    --void-black: #050505;
    --deep-navy: #0a0f14;
    --charcoal: #151a21;
    --steel-gray: #334155;
    --ghost-white: #f1f5f9;
    --slate-text: #94a3b8;
    --white: #ffffff;

    /* --- UI ACCENT COLORS --- */
    --emerald-glow: #10b981;     /* Primary UI Accent */
    --violet-pulse: #8b5cf6;     
    --amber-spark: #f59e0b;      
    --crimson-alert: #ef4444;    
    
    /* --- ORIGINAL HARDWARE COLORS (PRESERVED) --- */
    --neon-blue: #00e5ff;
    --hot-magenta: #ff00f0;
    --electric-lime: #aeff00;
    --solar-orange: #ff8c00;
    --warning-yellow: #ffc107;
    --storm-gray: #717790;
    --vulcan: #1f223d;
    --cyberspace: #16182a;

    /* --- GRADIENTS & PATTERNS (V4) --- */
    --main-gradient: linear-gradient(135deg, var(--emerald-glow) 0%, var(--violet-pulse) 100%);
    --card-gradient: linear-gradient(145deg, rgba(21, 26, 33, 0.9), rgba(10, 15, 20, 0.95));
    
    /* Scanlines Background */
    --scanline-color: rgba(0, 229, 255, 0.03);
    --striped-pattern: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        var(--scanline-color) 3px,
        var(--scanline-color) 4px
    );
    
    /* --- UI CONSTANTS --- */
    --font-primary: 'Inter', 'Noto Sans', sans-serif;
    --font-display: 'Space Grotesk', 'Audiowide', sans-serif;
    --font-code: 'JetBrains Mono', 'Fira Code', monospace;
    
    --header-height: 80px;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --border-style: 1px solid rgba(148, 163, 184, 0.15);
    
    --glow-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
    --hard-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

/*//////////////////////////////////////////////////////////////////////////////
//  PAGE SETUP & BACKGROUND (V4 STYLE)
//////////////////////////////////////////////////////////////////////////////*/

body.diagram-page {
    font-family: var(--font-primary);
    margin: 0;
    background-color: var(--void-black);
    /* Csíkozott scanline háttér */
    background-image: var(--striped-pattern), linear-gradient(180deg, var(--deep-navy) 0%, var(--void-black) 100%);
    color: var(--ghost-white);
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden; 
}

/*//////////////////////////////////////////////////////////////////////////////
//  LAYOUT STRUCTURE (V4 STYLE)
//////////////////////////////////////////////////////////////////////////////*/

.diagram-layout-container {
    display: flex;
    position: relative;
    height: calc(100vh - var(--header-height));
    padding: var(--spacing-md);
    padding-top: 0;
    margin-top: var(--header-height); /* Ha a header fixed */
    gap: var(--spacing-md);
}

.main-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
    gap: var(--spacing-md);
}

/*//////////////////////////////////////////////////////////////////////////////
//  DIAGRAM CANVAS (V4 STYLE)
//////////////////////////////////////////////////////////////////////////////*/

#diagram-container {
    flex-grow: 1;
    position: relative;
    cursor: grab;
    overflow: hidden;
    background-color: var(--deep-navy);
    /* Enyhe csíkozás + vignette effekt */
    background-image: 
        radial-gradient(circle at center, transparent 0%, var(--void-black) 90%),
        var(--striped-pattern);
    border: var(--border-style);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--hard-shadow);
    transition: border-color var(--transition);
}

#diagram-container:active { cursor: grabbing; }
#diagram-container:hover { border-color: rgba(16, 185, 129, 0.3); }

#diagram-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

/*//////////////////////////////////////////////////////////////////////////////
//  SIDEBAR - VEZÉRLŐPULT (V4 DEEP DARK / EMERALD DESIGN)
//////////////////////////////////////////////////////////////////////////////*/

#sidebar {
    width: 380px;
    flex-shrink: 0;
    /* Glassmorphism kártya */
    background: rgba(21, 26, 33, 0.85); 
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--border-style);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--hard-shadow);
    position: relative;
    overflow: hidden;
}

/* Felső dekor csík */
#sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 2px;
    background: var(--main-gradient);
    z-index: 10;
    box-shadow: 0 0 10px var(--emerald-glow);
}

#sidebar-content {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

#sidebar h3 {
    margin: 0 0 var(--spacing-lg) 0;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ghost-white);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    flex-shrink: 0;
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

/* Keresőmező */
#search-input {
    width: 100%;
    padding: 0.8rem 1rem;
    margin-bottom: var(--spacing-md);
    background: rgba(5, 5, 5, 0.3);
    border: 1px solid var(--steel-gray);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-primary);
    color: var(--ghost-white);
    transition: var(--transition);
    outline: none;
    flex-shrink: 0;
}

#search-input:focus {
    border-color: var(--emerald-glow);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
    background: rgba(5, 5, 5, 0.5);
}

#search-input::placeholder { color: var(--slate-text); font-style: italic; opacity: 0.7; }

/* Gombok konténere */
#sidebar-controls {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    flex-shrink: 0;
}

#sidebar-controls button {
    flex-grow: 1;
    padding: 0.6rem;
    font-size: 0.75rem;
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--steel-gray);
    border-radius: var(--border-radius-sm);
    color: var(--slate-text);
    cursor: pointer;
    transition: var(--transition);
}

#sidebar-controls button:hover {
    border-color: var(--emerald-glow);
    color: var(--emerald-glow);
    background: rgba(16, 185, 129, 0.08);
}

/* Lista konténer */
#node-list-container {
    flex: 1;
    min-height: 100px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    background: rgba(0, 0, 0, 0.2);
    margin: 0;
    padding: 0.5rem;
}

#node-list-container::-webkit-scrollbar { width: 6px; }
#node-list-container::-webkit-scrollbar-track { background: transparent; }
#node-list-container::-webkit-scrollbar-thumb {
    background: var(--steel-gray);
    border-radius: 3px;
}
#node-list-container::-webkit-scrollbar-thumb:hover { background: var(--emerald-glow); }

/* Details / Summary (Lenyíló elemek) */
#node-list-container details { margin-bottom: 4px; }

#node-list-container summary {
    font-weight: 500;
    cursor: pointer;
    padding: 0.7rem 0.8rem;
    background: transparent;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    color: var(--ghost-white);
    transition: var(--transition);
    border-radius: 4px;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid transparent;
}

#node-list-container summary::-webkit-details-marker { display: none; }

#node-list-container summary::after {
    content: '+';
    font-family: var(--font-code);
    color: var(--emerald-glow);
    font-weight: bold;
    font-size: 1.1em;
}

#node-list-container details[open] summary::after { content: '-'; }

#node-list-container summary:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Belső lista (ul) */
#node-list-container ul {
    list-style-type: none;
    padding-left: 0.5rem;
    margin: 0.2rem 0 0.5rem 0;
}

/* Lista elemek (li) */
#node-list-container li {
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-code);
    color: var(--slate-text);
    transition: var(--transition);
    border-radius: 4px;
    margin-bottom: 1px;
    border-left: 2px solid transparent;
}

#node-list-container li:hover {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.05), transparent);
    color: var(--emerald-glow);
    border-left-color: var(--emerald-glow);
    padding-left: 1rem;
}

#node-list-container li.selected {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent);
    border-left-color: var(--emerald-glow);
    color: var(--white);
    font-weight: 700;
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
}

/* Alsó Infó Panel */
#node-info {
    flex-shrink: 0;
    height: 180px;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--steel-gray);
    overflow-y: auto;
}

#node-info::-webkit-scrollbar { width: 4px; }
#node-info::-webkit-scrollbar-thumb { background: var(--steel-gray); }

#node-info h4 {
    margin: 0 0 var(--spacing-sm) 0;
    color: var(--violet-pulse);
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

#node-info p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--slate-text);
    margin: 0;
}

/*//////////////////////////////////////////////////////////////////////////////
//  DIAGRAM ELEMENTS & HARDWARE STYLING (ORIGINAL COLORS PRESERVED)
//////////////////////////////////////////////////////////////////////////////*/

/* Base Edge Styling */
.edge-path {
    fill: none;
    stroke: var(--steel-gray);
    stroke-width: 1.5px;
    transition: all var(--transition);
    opacity: 0.6;
}

.edge-path.dashed {
    stroke-dasharray: 6, 4;
    animation: dash-flow 3s linear infinite;
    stroke: var(--slate-text);
}

@keyframes dash-flow {
    to { stroke-dashoffset: -20; }
}

/* Base Node Styling */
.node-group .shape {
    fill: var(--charcoal);
    stroke: var(--steel-gray);
    stroke-width: 2px;
    transition: all var(--transition);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.node-group .label {
    font-size: 11px;
    font-family: var(--font-code);
    font-weight: 500;
    fill: var(--ghost-white);
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* --- INTERACTIVITY & HIGHLIGHTS --- */

.node-group.highlight .shape {
    stroke: var(--white);
    stroke-width: 4px;
    fill: var(--cyberspace);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.7));
    transform: scale(1.05);
}

.node-group.highlight .label {
    fill: var(--white);
    font-weight: 700;
}

.node-group.highlight-neighbor .shape {
    stroke: var(--electric-lime);
    stroke-width: 3px;
    fill: var(--vulcan);
    filter: drop-shadow(0 0 10px rgba(174, 255, 0, 0.5));
    transform: scale(1.02);
}

.node-group.highlight-neighbor .label {
    fill: var(--electric-lime);
    font-weight: 500;
}

.edge-path.highlight-edge {
    stroke: var(--neon-blue);
    stroke-width: 3px;
    filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.8));
    animation: pulse-glow 2s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from { stroke-width: 3px; opacity: 1; }
    to { stroke-width: 4px; opacity: 0.8; }
}

.unfocused {
    opacity: 0.2;
    transition: opacity var(--transition);
}

.node-group {
    cursor: pointer;
    transition: all var(--transition);
}

.node-group:hover .shape {
    stroke: var(--white);
    stroke-width: 3px;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
    transform: scale(1.03);
}

.node-group:hover .label {
    fill: var(--white);
    font-weight: 600;
}

/* --- CONTROLS --- */

.zoom-controls {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 10;
}

.zoom-btn {
    width: 45px;
    height: 45px;
    background: rgba(21, 26, 33, 0.8);
    backdrop-filter: blur(10px);
    border: var(--border-style);
    border-radius: 50%;
    color: var(--emerald-glow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    transition: all var(--transition);
    box-shadow: var(--hard-shadow);
}

.zoom-btn:hover {
    border-color: var(--emerald-glow);
    box-shadow: var(--glow-shadow);
    transform: scale(1.1);
    color: var(--white);
    background: rgba(16, 185, 129, 0.1);
}

.zoom-btn:active {
    transform: scale(0.95);
}

@keyframes loading-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: loading-pulse 1.5s ease-in-out infinite;
}

/* --- RESPONSIVE / MOBILE --- */

.mobile-toggle {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-md));
    left: var(--spacing-md);
    z-index: 1001;
    background: var(--card-gradient);
    border: var(--border-style);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: var(--emerald-glow);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
}

@media (max-width: 992px) {
    .diagram-layout-container {
        flex-direction: column;
        height: auto;
    }

    #diagram-container {
        height: 65vh;
        min-height: 450px;
    }

    #sidebar {
        width: 100%;
        height: 40vh;
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    #sidebar {
        width: 90%;
        max-width: 400px;
        position: fixed;
        right: -100%;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: right var(--transition);
        margin: 0;
    }

    #sidebar.open {
        right: 0;
    }

    .mobile-toggle {
        display: flex;
    }
}

@media (min-width: 769px) {
    .mobile-toggle {
        display: none !important;
    }
}
