/* ************************************
// NAME: style.css
// PROJEKT: LEGOne – Globales Stylesheet
// ************************************ */

/* ============ CSS Variables ============ */
:root {
    --base-font-size: 14px;
    --bg-primary: #f5f5f5; --bg-secondary: #ffffff; --bg-tertiary: #f9f9f9;
    --text-primary: #333333; --text-secondary: #666666; --text-muted: #777777;
    --accent: #9C27B0; --accent-dark: #6A1B9A; --accent-red: #f44336;
    --nav-bg: #1e1e1e; --nav-text: #ffffff; --nav-dropdown-bg: #2d2d2d; --nav-hover: #9C27B0;
    --card-bg: #ffffff; --card-shadow: rgba(0,0,0,0.1);
    --table-bg: #ffffff; --table-header-bg: #9C27B0; --table-header-text: #ffffff;
    --table-row-hover: #f5f5f5; --table-border: #dddddd;
    --input-bg: #ffffff; --input-border: #dddddd; --input-focus: #9C27B0;
    --msg-success-bg: #c8e6c9; --msg-success-text: #2e7d32; --msg-success-border: #2e7d32;
    --msg-error-bg: #ffcdd2; --msg-error-text: #c62828; --msg-error-border: #c62828;
    --msg-info-bg: #e3f2fd; --msg-info-text: #1565c0; --msg-info-border: #2196F3;
    --modal-overlay: rgba(0,0,0,0.5); --modal-bg: #ffffff;
    
    /* Layout Variables */
    --sidebar-width: 240px;
    --sidebar-width-collapsed: 70px;
}
[data-theme="dark"] {
    --bg-primary: #121212; --bg-secondary: #1e1e1e; --bg-tertiary: #2d2d2d;
    --text-primary: #e0e0e0; --text-secondary: #b0b0b0; --text-muted: #888888;
    --nav-bg: #1a1a1a; --nav-dropdown-bg: #2d2d2d;
    --card-bg: #1e1e1e; --card-shadow: rgba(0,0,0,0.3);
    --table-bg: #1e1e1e; --table-row-hover: #2d2d2d; --table-border: #3d3d3d;
    --input-bg: #2d2d2d; --input-border: #3d3d3d;
    --modal-overlay: rgba(0,0,0,0.8); --modal-bg: #1e1e1e;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, sans-serif; font-size: var(--base-font-size);
    margin: 0; padding: 0; 
    height: 100vh; overflow: hidden; /* Verhindert globales Scrollen */
    background: var(--bg-primary); color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
}
input, select, textarea, button { font-family: inherit; font-size: var(--base-font-size); }
a { color: var(--accent); }
h1, h2 { color: var(--text-primary); }
h2 { border-bottom: 2px solid var(--accent); padding-bottom: 10px; }

/* ============ Layout Structure ============ */
.app-wrapper { display: flex; height: 100vh; width: 100vw; }

/* ============ Sidebar ============ */
.sidebar {
    width: var(--sidebar-width); background: var(--nav-bg); color: var(--nav-text);
    display: flex; flex-direction: column; transition: width 0.3s ease;
    position: relative; z-index: 100; box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}
.sidebar-header {
    padding: 15px; height: 65px; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.05); white-space: nowrap; overflow: hidden;
}
.sidebar-header h1 { font-size: 1.2rem; margin: 0; color: #fff; display: flex; align-items: center; gap: 8px; }
.sidebar-header small { font-size: 0.5em; color: var(--text-muted); }
.sidebar-toggle { background: transparent; border: none; color: var(--nav-text); font-size: 1.5rem; cursor: pointer; padding: 0 5px; outline: none; }

/* Sidebar Navigation */
.sidebar-nav { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding-top: 10px; }
.nav-item {
    padding: 12px 15px; display: flex; align-items: center; color: #ccc; text-decoration: none; cursor: pointer;
    transition: background 0.2s, color 0.2s; white-space: nowrap; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.05); color: #fff; border-left-color: var(--accent); }
.nav-item .icon { font-size: 1.2rem; min-width: 30px; text-align: center; }
.nav-item .label { margin-left: 10px; opacity: 1; transition: opacity 0.3s; flex-grow: 1; }

/* Submenüs (Akkordeon) */
.nav-group { position: relative; }
.nav-sub { display: none; background: rgba(0,0,0,0.15); flex-direction: column; padding-left: 45px; }
.nav-group.open .nav-sub { display: flex; }
.nav-sub a { color: #aaa; text-decoration: none; padding: 10px 0; font-size: 0.9em; transition: color 0.2s; display: block; }
.nav-sub a:hover { color: #fff; }

/* ============ Sidebar Footer (Neu & Ausgeklappt) ============ */
.sidebar-footer { padding: 15px; border-top: 1px solid rgba(255,255,255,0.05); position: relative; }

.footer-expanded { display: flex; flex-direction: column; gap: 15px; width: 100%; }

/* Dropdown im ausgeklappten Zustand */
.leg-switcher select {
    width: 100%; padding: 8px 10px; background: #2a2a2a; color: #fff;
    border: 1px solid #444; border-radius: 6px; cursor: pointer; outline: none; font-size: 13px;
}
.leg-switcher select:focus { border-color: var(--accent); }
.leg-switcher-single { color: #ccc; font-size: 13px; padding: 8px 10px; background: #2a2a2a; border-radius: 6px; border: 1px solid #444; }

/* User Row */
/* User Row */
.user-profile-row { display: flex; align-items: center; justify-content: space-between; }
.user-info { display: flex; align-items: center; gap: 10px; flex-grow: 1; padding: 4px 0; }
.user-avatar {
    width: 35px; height: 35px; border-radius: 50%; background: var(--accent);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 13px; flex-shrink: 0;
}
.user-name { color: #ccc; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.theme-icon-btn { background: none; border: none; color: #aaa; cursor: pointer; font-size: 16px; padding: 5px; transition: color 0.2s; border-radius: 50%; }
.theme-icon-btn:hover { color: var(--accent); background: rgba(255,255,255,0.05); }

/* Eingeklappter Avatar Trigger */
.avatar-btn {
    display: none; /* Im ausgeklappten Zustand versteckt */
    width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; border: none;
    font-weight: bold; cursor: pointer; align-items: center; justify-content: center; font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: transform 0.2s; margin: 0 auto;
}
.avatar-btn:hover { transform: scale(1.05); }

/* Avatar Flyout Menu */
.avatar-flyout {
    display: none; position: absolute; bottom: 60px; left: 15px; width: 240px; background: var(--nav-dropdown-bg);
    border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.4); flex-direction: column; padding: 15px; z-index: 200; border: 1px solid rgba(255,255,255,0.05);
}
.avatar-flyout.show { display: flex; animation: fadeIn 0.15s ease-in-out; }
.avatar-flyout-header { border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; margin-bottom: 10px; }
.avatar-flyout select { width: 100%; padding: 8px; margin-bottom: 10px; background: rgba(0,0,0,0.2); color: #fff; border: 1px solid #555; border-radius: 4px; }
.avatar-flyout a, .avatar-flyout button {
    display: block; color: #ccc; text-decoration: none; padding: 8px 0; background: none; border: none; text-align: left; cursor: pointer; width: 100%; font-size: 14px;
}
.avatar-flyout a:hover, .avatar-flyout button:hover { color: #fff; }

/* Flyout Logik: Verstecke redundante Elemente wenn Sidebar offen ist */
html:not([data-sidebar="collapsed"]) .flyout-leg-switcher { display: none; }
html:not([data-sidebar="collapsed"]) .flyout-theme-btn { display: none; }

/* ============ Collapsed Sidebar State ============ */
/* Erlaubt den Flyouts, aus der Sidebar "herauszufliegen" ohne abgeschnitten zu werden */
html[data-sidebar="collapsed"] .sidebar-nav { 
    overflow: visible; 
}
html[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-width-collapsed); }
html[data-sidebar="collapsed"] .sidebar-header h1 span, 
html[data-sidebar="collapsed"] .sidebar-header h1 small { display: none; }
html[data-sidebar="collapsed"] .sidebar-header { justify-content: center; padding: 15px 0; }
html[data-sidebar="collapsed"] .nav-item .label { display: none; }
html[data-sidebar="collapsed"] .nav-item.active { border-left-color: transparent; background: var(--accent); }

/* Footer im Collapsed State */
html[data-sidebar="collapsed"] .footer-expanded { display: none; }
html[data-sidebar="collapsed"] .avatar-btn { display: flex; }
html[data-sidebar="collapsed"] .avatar-flyout { left: calc(var(--sidebar-width-collapsed) + 15px); bottom: 15px; }

/* Flyouts für Menüs im collapsed State */
html[data-sidebar="collapsed"] .nav-group .nav-sub {
    position: absolute; left: var(--sidebar-width-collapsed); top: 0; width: 200px; display: none; background: var(--nav-dropdown-bg);
    box-shadow: 2px 2px 10px rgba(0,0,0,0.3); border-radius: 0 8px 8px 0; padding: 10px 15px; z-index: 200; border-left: 2px solid var(--accent);
}
html[data-sidebar="collapsed"] .nav-group.open .nav-sub { display: flex; }
html[data-sidebar="collapsed"] .nav-group.open .nav-item { background: rgba(255,255,255,0.1); }

/* ============ Main Content Area ============ */
.main-content { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    background: var(--bg-primary); 
    transition: width 0.3s ease; 
}

.content-scrollable { 
    padding: 20px 30px; 
    overflow-y: auto; 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: flex-start; /* <-- HIER GEÄNDERT: Zieht den Inhalt wieder nach links an die Sidebar */
}

/* Die Begrenzung bleibt bestehen, damit es nicht endlos breit wird */
.content-scrollable > * {
    width: 100%;
    max-width: 1600px; 
}


/* ============ Components ============ */
.stats { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; justify-content: flex-start; }
.stat-box {
    background: var(--card-bg); padding: 15px 25px; border-radius: 8px; box-shadow: 0 2px 4px var(--card-shadow); text-align: center; 
    height: 110px; width: 160px; flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: center;
    overflow: hidden; box-sizing: border-box; transition: transform 0.2s;
}
.stat-box:hover { transform: translateY(-2px); }
.stat-unit { font-size: 12px; opacity: 0.8; margin-bottom: 2px; }
.stat-box .number { font-size: 28px; font-weight: bold; color: var(--accent); }
.stat-box .label { color: var(--text-secondary); font-size: 14px; margin-top: 5px; }
.stats .stat-box:first-child { box-shadow: inset 5px 0 0 #FF9800, 0 2px 4px var(--card-shadow); }

/* Modifiers */
.stat-box-muted .number { color: var(--text-muted); }
.stat-box-primary .number { color: #1565C0; }
.stat-box-success .number { color: #2E7D32; }
.stat-box-danger .number { color: #C62828; }
.stat-box-accent .number { color: var(--accent); }
.stat-box-border-accent { border-left: 3px solid var(--accent); }

/* ============ Table (Inner Scrolling Ready) ============ */
.table-container { flex-grow: 1; overflow: auto; border-radius: 8px; box-shadow: 0 2px 4px var(--card-shadow); background: var(--table-bg); }
table { width: 100%; border-collapse: collapse; margin-top: 0; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--table-border); }
th { background: var(--table-header-bg); color: var(--table-header-text); font-weight: bold; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 2px -1px rgba(0,0,0,0.2); }
tr:hover { background: var(--table-row-hover); }

/* ============ Messages / Info ============ */
.message { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: bold; }
.message.success { background: var(--msg-success-bg); color: var(--msg-success-text); box-shadow: inset 5px 0 0 var(--msg-success-border); }
.message.error { background: var(--msg-error-bg); color: var(--msg-error-text); box-shadow: inset 5px 0 0 var(--msg-error-border); }
.info { background: var(--msg-info-bg); color: var(--msg-info-text); padding: 15px; border-radius: 8px; box-shadow: inset 5px 0 0 var(--msg-info-border); margin-bottom: 20px; }

/* ============ Buttons ============ */
.btn-std { height: 38px; padding: 0 15px; border-radius: 4px; border: none; color: white; font-weight: bold; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--accent-red); }
.btn-grey { background: #999; color: white; }
.btn-success { background: #2E7D32; color: white; }
.btn-info { background: #0288D1; color: white; }
.btn-icon { width: 38px; padding: 0; font-size: 18px; }

/* ============ Filter / Forms ============ */
.filter-box { background: var(--card-bg); padding: 15px 15px 15px 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: inset 5px 0 0 #2196F3, 0 2px 4px var(--card-shadow); display: flex; flex-wrap: wrap; gap: 15px; align-items: flex-end; }
.filter-box label { font-size: 12px; font-weight: bold; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.filter-box select, .filter-box input { padding: 8px 10px; border: 1px solid var(--input-border); border-radius: 4px; font-size: 14px; height: 38px; background: var(--input-bg); color: var(--text-primary); }
.filter-box button { padding: 0 16px; height: 38px; background: var(--accent); color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--input-focus) !important; box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.15); }

/* ============ Modal (Standard) ============ */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--modal-overlay); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--modal-bg); color: var(--text-primary); border-radius: 12px; padding: 30px; width: 95%; max-width: 750px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.3); position: relative; }
.modal h3 { margin-top: 0; margin-bottom: 20px; flex-shrink: 0; }
.modal-tabs { flex-shrink: 0; display: flex; border-bottom: 2px solid var(--table-border); margin-bottom: 20px; gap: 20px; flex-wrap: wrap; }
.modal-tab { padding: 10px 0; cursor: pointer; border: none; background: none; font-weight: bold; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.modal-tab:hover, .modal-tab.active { color: var(--accent); }
.modal-tab.active { border-bottom: 2px solid var(--accent); }
.modal-close { position: absolute; top: 15px; right: 15px; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.modal input, .modal select, .modal textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 6px; background: var(--input-bg); color: var(--text-primary); box-sizing: border-box; }
.form-group { margin-bottom: 15px; }
.form-group label { font-size: 12px; font-weight: bold; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.form-row { display: flex; gap: 15px; }
.form-row .form-group { flex: 1; }

.modal:has(.modal-tabs) { height: 650px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal:has(.modal-tabs) form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal-tab-content { display: none; flex: 1; overflow-y: auto; padding-right: 10px; margin-bottom: 15px; }
.modal-tab-content.active { display: block; animation: fadeIn 0.3s ease-in-out; }
/* ============ Globale Tabellen-Einstellungen ============ */

/* 1. Einheitliche Zeilenhöhe & Ausrichtung (gilt für Adressen, Dashboard, etc.) */
th, td {
    padding: 12px 15px; 
    text-align: left;
    border-bottom: 1px solid var(--table-border);
    vertical-align: middle; /* Zentriert Icons und Text perfekt auf einer Linie */
    line-height: 1.4;       /* Stabilisiert die Höhe bei mehrzeiligem Text */
}

/* 2. Sanfter Übergang für ALLE Tabellenzeilen im System */
tbody tr {
    transition: background-color 0.2s ease;
}

/* 3. Der deutliche graue Hintergrund beim Drüberfahren (Light Mode) */
tbody tr:hover {
    background-color: #e0e0e0 !important;
}

/* 4. Der passende Hintergrund beim Drüberfahren im Dark Mode */
[data-theme="dark"] tbody tr:hover {
    background-color: #383838 !important;
}

/* ============ Eigene lokale Menü-Icons ============ */
.custom-menu-icon {
    width: 1.1rem;
    height: 1.1rem;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;      /* Ein bisschen mehr Abstand zum Text tut oft gut */
    
    /* Der Trick für die perfekte Ausrichtung: */
    position: relative;
    top: -1px;               /* Schiebt das Icon 1 Pixel nach unten. Falls das nicht reicht, mach 2px daraus! */
}

/* Magischer Trick für den Dark Mode (bleibt unverändert) */
[data-theme="dark"] .custom-menu-icon {
    filter: invert(1) brightness(2);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }