/* --- Ultra-Fix: Footer nur unter Content, niemals unter Sidebar --- */
body.chat-page .chat-footer,
body .chat-footer,
body .main-layout > .chat-footer,
body .main-layout > .footer {
    grid-column: 1 / 2 !important;
}
/* Footer im Grid nur unter Content anzeigen, nicht unter Sidebar */
body .main-layout > .chat-footer,
body .main-layout > .footer {
    grid-area: footer !important;
    grid-column: 1 / 2 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    z-index: 10 !important;
}
/* ========================================
   OVERRIDE ALTE STYLES - Höhere Spezifität
   ======================================== */

/* Alle Sidebar-Styles und -Verweise entfernt! Sidebar wird jetzt ausschließlich in sidebar.css gepflegt. */
    .mobile-sidebar-toggle:hover {
        background: rgba(6, 74, 247, 1) !important;
        transform: scale(1.1) !important;
    }
    
/* Alle Sidebar-relevanten Styles und Selektoren entfernt! Sidebar wird jetzt ausschließlich in sidebar.css gepflegt. */

.btn-sidebar-preset {
    flex: 1;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 80px;
}

.btn-sidebar-preset:hover {
    border-color: #4a90e2;
    background: #f8f9ff;
}

.btn-sidebar-preset.active {
    border-color: #4a90e2;
    background: #4a90e2;
    color: white;
}

.btn-sidebar-preset .preset-icon {
    font-size: 16px;
    font-weight: bold;
}

.btn-sidebar-preset .preset-label {
    font-size: 12px;
    font-weight: 500;
}

.btn-sidebar-preset .preset-size {
    font-size: 10px;
    opacity: 0.8;
}

/* Slider Container */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-container label {
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

#popup-sidebar-width-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #4a90e2 0%, #4a90e2 var(--slider-progress, 25%), #ddd var(--slider-progress, 25%), #ddd 100%);
    outline: none;
    border-radius: 3px;
}

#popup-sidebar-width-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a90e2;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#popup-sidebar-width-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a90e2;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
}

/* Input Container */
.input-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#popup-sidebar-width-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

#popup-sidebar-width-input:focus {
    border-color: #4a90e2;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-action {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-action:hover {
    background: #e9ecef;
    border-color: #4a90e2;
}

.btn-toggle {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.btn-toggle:hover {
    background: #ffeaa7;
    border-color: #e0a800;
}

/* ========================================
   RESPONSIVE ANPASSUNGEN FÜR POPUP
   ======================================== */

/* ========================================
   FINALE ÜBERSTEUERUNGEN - HÖCHSTE PRIORITÄT
   ======================================== */

/* WICHTIG: Settings-Button wurde in den Header verschoben */
/* 
.btn-settings,
#sidebar-settings-btn,
button[title*="Einstellungen"],
button[onclick*="toggleSidebarSettingsPopup"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 999 !important;
}
*/

/* Sidebar-Sektionen sichtbar machen 
.online-users-section,
.chat-rooms-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}*/

/* Main Layout Komponenten erzwingen */
body .main-layout {
    display: grid !important;
    grid-template-areas: 
        "header sidebar"
        "content sidebar"
        "footer sidebar" !important;
    grid-template-columns: 1fr var(--sidebar-width, 280px) !important;
    grid-template-rows: 60px 1fr 50px !important; /* Footer fix 50px */
    height: 100vh !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
}

body .chat-header,
body .chat-container,
body .chat-footer {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}
/* body .sidebar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
} */

/* ========================================
   SIDEBAR BREITE-VARIANTEN
   ======================================== */

/* Schmale Sidebar (200px) */
.main-layout:has(.sidebar.sidebar-narrow),
.sidebar-narrow {
    --sidebar-width: 200px;
}

.main-layout:has(.sidebar.sidebar-narrow) {
    grid-template-columns: 1fr 200px !important;
}

.sidebar.sidebar-narrow {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
}

/* Standard Sidebar (280px) - Default */
.main-layout:has(.sidebar.sidebar-standard),
.sidebar-standard {
    --sidebar-width: 280px;
}

.main-layout:has(.sidebar.sidebar-standard) {
    grid-template-columns: 1fr 280px !important;
}

.sidebar.sidebar-standard {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
}

/* Breite Sidebar (400px) */
.main-layout:has(.sidebar.sidebar-wide),
.sidebar-wide {
    --sidebar-width: 400px;
}

.main-layout:has(.sidebar.sidebar-wide) {
    grid-template-columns: 1fr 400px !important;
}

.sidebar.sidebar-wide {
    width: 400px !important;
    min-width: 400px !important;
    max-width: 400px !important;
}

/* Versteckte Sidebar */
.main-layout:has(.sidebar.sidebar-hidden),
.main-layout.sidebar-hidden-layout {
    grid-template-columns: 1fr 0px !important;
    grid-template-areas: 
        "header header"
        "content content"
        "footer footer" !important;
}

.sidebar.sidebar-hidden {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateX(100%) !important;
}

/* Fallback für Browser ohne :has() Support */
.main-layout.sidebar-narrow-layout {
    grid-template-columns: 1fr 200px !important;
}

.main-layout.sidebar-standard-layout {
    grid-template-columns: 1fr 280px !important;
}

.main-layout.sidebar-wide-layout {
    grid-template-columns: 1fr 400px !important;
}

.main-layout.sidebar-hidden-layout {
    grid-template-columns: 1fr 0px !important;
    grid-template-areas: 
        "header header"
        "content content"
        "footer footer" !important;
}

/* ========================================
   KOMPAKTER MODUS
   ======================================== */

.sidebar.compact-mode {
    --sidebar-padding: 8px; /* Reduzierter Abstand */
}

.sidebar.compact-mode #sidebar-user-container {
    padding: 10px 50px 10px 10px !important; /* Weniger Padding */
    min-height: 50px !important; /* Reduzierte Höhe */
}

.sidebar.compact-mode .online-users-section {
    padding: 10px 10px 5px 10px !important; /* Weniger Padding, oben positioniert */
    min-height: auto !important; /* Entfernt min-height: 150px für minimalen Abstand */
    max-height: 45vh !important; /* Kompakter im compact mode */
}

.sidebar.compact-mode .chat-rooms-section {
    padding: 10px 10px 10px 10px !important; /* Weniger Padding, unten positioniert */
    min-height: 120px !important; /* Reduzierte Mindesthöhe für Räume */
}

.sidebar.compact-mode .online-users-section h5,
.sidebar.compact-mode .chat-rooms-section h5 {
    margin: 0 0 8px 0 !important; /* Weniger Margin */
    font-size: 13px !important; /* Kleinere Schrift */
}

.sidebar.compact-mode #online-users-list .user-item,
.sidebar.compact-mode #chat-rooms .room-item {
    padding: 6px 10px !important; /* Weniger Padding für Items */
    margin: 1px 0 !important; /* Weniger Margin */
    font-size: 13px !important; /* Kleinere Schrift */
}

.sidebar.compact-mode #user-search {
    padding: 6px !important; /* Weniger Padding für Suchfeld */
    margin-bottom: 8px !important; /* Weniger Margin */
    font-size: 13px !important; /* Kleinere Schrift */
}

/* Kompakte Scrollbar für kompakten Modus */
.sidebar.compact-mode .sidebar-scroll-area::-webkit-scrollbar,
.sidebar.compact-mode #online-users-list::-webkit-scrollbar,
.sidebar.compact-mode #chat-rooms::-webkit-scrollbar {
    width: 4px !important; /* Schmalere Scrollbar */
}

/* ========================================
   SIDEBAR HIDE/SHOW ANIMATIONS
   ======================================== */

/* Smooth Transitions für Sidebar Hide/Show */
.sidebar {
    transition: all 0.3s ease-in-out !important;
}

.main-layout {
    transition: grid-template-columns 0.3s ease-in-out !important;
}

/* Hidden Sidebar State */
.sidebar.hidden {
    transform: translateX(100%) !important;
    opacity: 0 !important;
}

/* Show Button für versteckte Sidebar */
.sidebar-show-button {
    position: fixed !important;
    top: 50% !important;
    right: 10px !important;
    transform: translateY(-50%) !important;
    background: rgba(6, 74, 247, 0.9) !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    cursor: pointer !important;
    z-index: 9998 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    transition: all 0.3s ease !important;
}

.sidebar-show-button:hover {
    background: rgba(6, 74, 247, 1) !important;
    transform: translateY(-50%) scale(1.1) !important;
}

.sidebar-show-button.visible {
    display: flex !important;
}
