:root {
    --app-bg: #0d1117;
    --panel-bg: #161b22;
    --border-color: #30363d;
    --accent-color: #58a6ff;
    --text-main: #c9d1d9;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--app-bg);
    overflow: hidden; 
}

/* LAYOUT STRUCTURE */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    height: 58px;
    background: var(--panel-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: var(--shadow-soft);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.app-container {
    flex: 1;
    display: flex;
    padding: 18px;
    gap: 0; /* Gap auf 0, da der Resize-Handle dazwischen liegt */
    overflow: hidden;
}

/* PANELS & RESIZER */
.sidebar {
    width: 60%;          /* Default 60% */
    min-width: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 22px;
    box-shadow: var(--shadow-soft);
    overflow-y: auto;
    flex-shrink: 0;      /* darf bleiben */
}

.resize-handle {
    width: 8px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.25s ease;
    margin: 0 4px;
    border-radius: 4px;
    flex-shrink: 0;
}

.resize-handle:hover {
    background: var(--accent-color);
}

.main-panel {
    flex: 1;
    background: var(--panel-bg);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

/* UI ELEMENTS TOPBAR */
.topbar-left {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-left::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
}

.account-display {
    margin-right: 18px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.account-display:hover {
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.account-display::before {
    content: "";
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
}

.logout-btn {
    background: #ef4444;
    border: none;
    padding: 7px 16px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* SEARCH AREA */
.search-panel {
    padding: 15px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
}

.search-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-icon {
    position: relative;
    flex: 1;
}

.input-with-icon input {
    width: 100%;
    padding: 11px 45px 11px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 15px;
    background: #0d1117;
    color: var(--text-main);
    transition: all 0.25s ease;
}

.query-help-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #30363d;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
}

.search-btn {
    padding: 10px 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* OVERLAY SYSTEM */
.overlay-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content-wrapper {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 500px;
    width: 90%;
    position: relative;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* QUERY BUILDER SPECIFICS */
.search-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    font-weight: 600;
}

.switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #30363d; transition: .4s; border-radius: 24px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: #8b949e; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(26px); background-color: white; }

.attr-row {
    display: flex; gap: 12px; margin-bottom: 12px; align-items: center;
}
.attr-row select, .attr-row input {
    padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; flex: 1;
    background: #0d1117; color: var(--text-main);
}

.add-attr-btn {
    width: 100%; padding: 10px; margin-top: 10px;
    background: transparent; border: 2px dashed var(--accent-color);
    color: var(--accent-color); border-radius: 8px; font-weight: bold; cursor: pointer;
}

.apply-btn {
    width: 100%; padding: 12px; background: var(--accent-color);
    color: white; border: none; border-radius: 8px; font-weight: bold; margin-top: 20px;
}

.disabled { opacity: 0.3; pointer-events: none; }
.hidden { display: none !important; }

/* FOOTER */


.query-remove-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: #ef4444;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.query-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.query-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #0d1117;
    font-size: 14px;
    color: var(--text-main);
    transition: all 0.2s ease;
    margin-top: 10px; /* 🔥 Abstand zur Combo Box */
}

.query-input:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.query-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Gezieltes Styling für das ID-Eingabefeld basierend auf deiner Struktur */
.query-builder-container .form-group input#query-id,
.query-builder-container .attr-row input {
    width: 100%;
    height: 40px;
    padding: 10px 12px !important;
    
    /* Deine Variablen */
    background-color: #0d1117 !important; 
    border: 1px solid var(--border-color) !important;
    color: var(--text-main);
    border-radius: 8px !important;
    
    /* Reset von Browser-Defaults */
    font-family: inherit;
    font-size: 14px;
    outline: none;
    box-shadow: none;
    transition: all 0.2s ease;
    
    /* User Select Style */
    user-select: auto;
    box-sizing: border-box;
}

/* Hover & Focus Effekt */
.query-builder-container .form-group input#query-id:focus,
.query-builder-container .attr-row input:focus {
    border-color: var(--accent-color) !important;
    background-color: #0d1117 !important;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15) !important;
}

/* Styling für die Labels über dem ID-Feld */
.query-builder-container .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 14px;
}

/* Falls das Feld deaktiviert ist (ID Modus aus) */
.query-builder-container .query-section.disabled input {
    background-color: #21262d !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Abstand für die gesamte ID-Sektion nach unten */
#section-id {
    margin-bottom: 25px !important; /* Erzeugt Platz vor dem Button oder der nächsten Sektion */
}

/* Abstand für die Attribut-Liste nach unten */
#attribute-list {
    margin-bottom: 15px; /* Abstand zwischen der letzten Zeile und dem "+ Hinzufügen" Button */
}

/* Abstand zwischen dem "+ Attribut hinzufügen" Button und dem finalen "Übernehmen" Button */
#section-attributes {
    margin-bottom: 20px;
}

/* Optional: Damit das Modal nach unten nicht "abgehackt" wirkt */
.modal-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}
.footer {
    height: 40px;
    background: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    color: #8b949e;
    flex-shrink: 0;
}
#node-map-container {
    width: 100%;
    flex-grow: 1; /* Füllt jetzt den gesamten restlichen Platz der Sidebar aus */
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    position: relative;
    
    /* Wichtig für vis.js */
    min-height: 200px; 
}

#node-map-container canvas {
    background-color: #0d1117 !important;
}
/* Verhindert den blauen Rahmen beim Anklicken des Canvas */
#node-map-container canvas {
    outline: none;
}

/* Hauptcontainer für Profil-Header */
.user-profile-header {
    display: flex;
    position: relative;
    transition: all 0.3s ease-in-out;
    overflow: hidden;
    gap: 20px;
    flex-direction: row;
    background-color: #161b22; /* Passend zum dunklen Hintergrund */
    border: 1px solid #30363d; /* Subtiler Rand */
    border-radius: 8px;
    padding: 20px;
    margin: 10px;
}

.user-profile-header.collapsed {
    max-height: 40px; /* Die gewünschte Resthöhe */
    padding-top: 5px;
    padding-bottom: 5px;
    opacity: 0.8;
}

/* Profilbild-Feld */
.profile-avatar-box {
    width: 100px;
    height: 100px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.profile-avatar-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Info-Feld daneben */
.user-info-box {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-info-box h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: #f0f6fc;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.stat-item {
    font-size: 0.9rem;
    color: #8b949e;
}

.stat-item .label {
    font-weight: bold;
    color: #58a6ff; /* Ein schöner Akzent-Blauton */
    margin-right: 5px;
}

/* Datagrid Bereich */
.data-grid-container {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    min-height: 400px;
    padding: 10px;
    margin: 10px;
    flex: auto;
}

/* Header mit Akzentfarben-Vorschau */
.user-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #30363d;
    margin-bottom: 15px;
    padding-bottom: 5px;
}

.accent-pill {
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 10px;
    background: #21262d;
    border: 1px solid #30363d;
    color: #f0f6fc;
    margin: 0 auto; 
    display: inline-block;
    white-space: nowrap;
}

/* Grid Layout */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Zwei Spalten für kompakte Daten */
    gap: 20px;
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    border-bottom: 1px solid #21262d;
    padding-bottom: 2px;
}

.stat-item .label {
    color: #58a6ff; /* Dein Akzent-Blau */
    font-weight: 500;
}

.stat-item span:last-child {
    color: #c9d1d9;
    text-align: right;
}

/* Extra Bereiche (Bio & Attribute) */
.user-extra-info {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-block .label {
    display: block;
    color: #58a6ff;
    font-size: 0.85rem;
    margin-bottom: 4px;
    font-weight: bold;
}

.bio-text {
    background: #0d1117;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #30363d;
    font-size: 0.85rem;
    color: #8b949e;
    margin: 0;
    min-height: 40px;
}

.attribute-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.attr-tag {
    background: #238636; /* Grüner Tag für Attribute */
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.bio-display {
    display: flex;
    align-items: flex-start;
}

.bio-content {
    color: #8b949e; /* Etwas blasserer Text für die Bio */
    font-size: 0.9rem;
    line-height: 1.4;
    font-style: italic; /* Macht es unterscheidbar von harten Fakten */
}

.user-extra-info .label {
    min-width: 80px;
    color: #58a6ff;
    font-weight: bold;
    font-size: 0.85rem;
}

.header-toggle-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #21262d;
    border: 1px solid #30363d;
    color: #8b949e;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.header-toggle-btn:hover {
    background: #30363d;
    color: #f0f6fc;
}

/* Wenn eingeklappt, drehen wir das Icon */
.collapsed #toggleIcon {
    transform: rotate(180deg);
}

.user-profile-header.collapsed {
    /* Die Höhe muss exakt so groß sein, dass nur die 'user-header-row' sichtbar bleibt */
    max-height: 55px; 
    padding-top: 10px;
    padding-bottom: 10;
    opacity: 0.9;
    border-bottom: 2px solid var(--accent-blue); /* Optional: Ein farbiger Strich als optischer Abschluss */
}

.collapsed .profile-avatar-box {
    width: 35px;
    height: 35px;
    transition: all 0.3s ease;
}

.collapsed .stats-grid, 
.collapsed .user-extra-info {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Toolbar Container */
.map-toolbar {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: #161b22;
    border: 1px solid var(--border-color);
    border-bottom: none; /* Verschmilzt mit dem Map-Container */
    border-radius: 8px 8px 0 0;
}

/* Einzelne Buttons */
.tool-btn {
    position: relative;
    width: 32px;
    height: 32px;
    background: #21262d;
    border: 1px solid #30363d;
    color: #c9d1d9;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #30363d;
    border-color: #8b949e;
    color: #f0f6fc;
}

.tool-btn.btn-danger:hover {
    border-color: #f85149;
    color: #f85149;
}

/* --- Tooltip Logik --- */
.tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px; /* Position unter dem Button */
    left: 50%;
    transform: translateX(-50%);
    background: #0d1117;
    color: #f0f6fc;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid #30363d;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    /* Die Verzögerung: erscheint erst nach 0.8s Hover */
    transition: opacity 0.2s ease;
    transition-delay: 0s; 
}

.tool-btn:hover::after {
    opacity: 1;
    transition-delay: 0.8s; /* Erst nach fast einer Sekunde anzeigen */
}

.toolbar-separator {
    width: 1px;
    background: #30363d;
    margin: 4px 4px;
}