/* Smileys in Nachrichten: Maximal 100px Breite/Höhe, kleinere Smileys bleiben 1:1 */
.pm-time {
    font-size: 0.85em;
    font-style: italic;
    color: #888;
}
.pm-message img, #pm-messages img {
    max-width: 120px;
    max-height: 120px;
    width: auto;
    height: auto;
    vertical-align: middle;
    display: inline-block;
}
/* Container für das gesamte Popup */
.private-message-popup {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    /* z-index wird vom PopupManager verwaltet */
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    width: 600px;
    max-width: 98vw;
    min-width: 320px;
    height: auto;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    touch-action: manipulation;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.pm-header, .smiley-header {
    background-color: #f1f1f1;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move; /* Zeigt an, dass der Header beweglich ist */
}

.pm-header h3 {
    margin: 0;
    font-size: 12px; /* Kleinere Schriftgröße */
}

.pm-header .close {
    cursor: pointer;
    font-size: 18px; /* Kleinere Schriftgröße */
    font-weight: bold;
    color: #333;
    transition: color 0.2s;
    z-index: 9999; /* Höchste Ebene sicherstellen */
    position: relative; /* Um z-index zu aktivieren */
}

.pm-header .close:hover {
    color: #ffcccc;
}

/* Nachrichtenbereich */
#pm-messages {
    flex: 1; /* Nimmt den verfügbaren Platz ein */
    overflow-y: auto; /* Scrollbar für Nachrichten */
    margin: 0;
    padding: 10px;
    border-bottom: 1px solid #ddd; /* Trennlinie zum unteren Menü */
    background-color: #fff;
    font-size: 14px;
    line-height: 1.5;
    max-height: calc(1.5em * 6 + 20px); /* Maximal 6 Zeilen + Padding */
}

/* Einzelne Nachricht */
.pm-message {
    word-wrap: break-word; /* Lange Wörter umbrechen */
    white-space: normal; /* Zeilenumbruch aktivieren */
    overflow-wrap: break-word; /* Alternative für Textumbruch */
    margin-bottom: 8px; /* Abstand zwischen Nachrichten */
    line-height: 1.4; /* Angemessener Zeilenabstand */
}

/* Unteres Menü */
#pm-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #ddd; /* Trennlinie zum Nachrichtenbereich */
    background-color: #f9f9f9; /* Hintergrundfarbe für das Menü */
    flex-shrink: 0; /* Verhindert, dass das Menü schrumpft */
    position: sticky; /* Fixiert das Menü am unteren Rand des Containers */
    bottom: 0;
}

#pm-input {
    flex: 1; /* Nimmt den verfügbaren Platz ein */
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

#pm-form .btn {
    padding: 8px 12px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#pm-form .btn:hover {
    background-color: #0056b3;
}

/* Smiley-Styles */

.smiley-sort {
    margin-bottom: 10px;
    padding: 5px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
}

.smiley-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.smiley-grid li {
    cursor: pointer;
    transition: transform 0.2s;
}

.smiley-grid li:hover {
    transform: scale(1.1);
}

/* Smiley-Popup */
.smiley-container {
    position: fixed; /* Fixed statt absolute für konsistente Positionierung */
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); /* Stärkerer Schatten für bessere Sichtbarkeit */
    border-radius: 8px;
    width: 600px; /* Breiter für mehr Smileys */
    max-width: 90%; /* Responsive auf kleineren Bildschirmen */
    max-height: 80vh; /* Prozentuale Höhe relativ zum Viewport */
    overflow: hidden;
    /* z-index wird vom PopupManager verwaltet */
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Scrollbar für überlaufende Inhalte */
    left: 50%; /* Horizontale Zentrierung */
    top: 50%; /* Vertikale Zentrierung */
    transform: translate(-50%, -50%); /* Perfekte Zentrierung */
}

/* Smiley-Header bleibt oben fixiert */
.smiley-sort-dropdown {
    margin-left: auto;
    padding: 5px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    z-index: 100; /* Höherer z-index für das Dropdown */
    pointer-events: auto; /* Explizit pointer-events aktivieren */
}

.smiley-sort-dropdown:hover {
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

.smiley-sort-dropdown:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

/* Smiley-Body mit Scrollbar */
.smiley-body {
    flex: 1;
    overflow-y: auto; /* Scrollbar hinzufügen */
    padding: 10px;
}

/* Smiley-Liste */
.smiley-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
    justify-content: center;
}

/* Smiley-Elemente */
.smiley-grid li {
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smiley-grid li:hover {
    transform: scale(1.1);
}

@media (max-width: 600px) {
    .private-message-popup {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        min-width: unset !important;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
        font-size: 15px !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important; /* Verhindert Scrolling des gesamten Popups */
        position: absolute !important; /* Absolute statt fixed für bessere Samsung-Kompatibilität */
    }
    .pm-body {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 !important;
        overflow: hidden !important;
        position: relative !important; /* Für die absolute Positionierung der Kinder */
        height: calc(100vh - 50px) !important; /* Höhe abzüglich Header */
    }
    .pm-header, .smiley-header {
        flex-direction: row;
        align-items: center;
        padding: 8px;
        font-size: 1em;
        width: 100%;
        box-sizing: border-box;
        height: 50px !important; /* Feste Höhe für konsistente Berechnung */
    }
    .pm-header h3 {
        font-size: 1.1em;
        width: 100%;
        text-align: center;
        margin: 0;
    }
    .pm-header .close {
        font-size: 28px;
        margin-left: auto;
        align-self: flex-end;
    }
    #pm-messages {
        order: 1 !important;
        flex: 1 !important;
        font-size: 1em;
        max-height: none !important;
        padding: 8px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        margin: 0 auto;
        background: #fff;
        overflow-y: auto !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 130px !important; /* Platz für Eingabefeld und Buttons lassen */
    }
    #pm-form {
        order: 2 !important;
        flex-direction: row !important;
        gap: 6px;
        padding: 8px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        align-items: center !important;
        position: absolute !important;
        bottom: 70px !important;
        left: 0 !important;
        right: 0 !important;
        background: #f9f9f9 !important;
        z-index: 10 !important;
        height: 60px !important; /* Feste Höhe für konsistente Berechnung */
    }
    #pm-input {
        font-size: 1.1em;
        padding: 14px 10px;
        flex: 1 !important;
        border-radius: 6px;
        box-sizing: border-box;
        min-height: 44px !important;
    }
    #pm-form .btn {
        width: auto !important;
        font-size: 1em;
        padding: 14px 10px;
        min-height: 44px !important;
        border-radius: 6px;
    }
    .pm-actions {
        order: 3 !important;
        padding: 8px 4px;
        background: #f0f0f0;
        border-top: 1px solid #ddd;
        width: 100%;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        z-index: 9;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 70px !important; /* Feste Höhe für konsistente Berechnung */
    }
    .pm-actions .btn {
        flex: 1;
        min-height: 44px;
        font-size: 1.1em;
        margin: 0 2px;
    }
    .pm-close-mobile {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Samsung-spezifische Fixes */
    @supports (-webkit-touch-callout: none) {
        /* iOS & Samsung-Browser-spezifische Regeln */
        .private-message-popup {
            height: 100% !important;
            position: fixed !important;
        }
        .pm-body {
            height: calc(100% - 50px) !important;
        }
        #pm-messages {
            -webkit-overflow-scrolling: touch !important; /* Sanftes Scrollen auf iOS */
        }
    }
    
    .smiley-container {
        width: 95vw;
        max-width: 95vw;
        max-height: 80vh;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        border-radius: 8px;
        padding: 0;
        box-sizing: border-box;
        /* z-index wird vom PopupManager verwaltet */
        position: fixed;
        overflow-y: auto;
    }
    .smiley-body {
        padding: 8px;
    }
    .smiley-grid {
        gap: 6px;
    }
    .smiley-grid li {
        font-size: 1.2em;
    }
    /* Zusätzliche Optimierungen für Touch-Bedienung */
    .pm-header, .smiley-header {
        touch-action: pan-y;
    }
    #pm-input, #pm-form .btn {
        min-height: 44px; /* Bessere Touch-Fläche */
    }
}

/* --- Mobile-Optimierung für Volvo/kleine Displays: Nachrichtenbereich & Buttons immer sichtbar --- */
@media (max-width: 900px), (max-height: 600px) {
  .private-message-popup {
    max-height: 100vh !important;
    height: 100vh !important;
    min-width: 0 !important;
    width: 100vw !important;
    border-radius: 0 !important;
    font-size: 1em !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    left: 0;
    top: 0;
    transform: none;
    position: absolute !important;
    overflow: hidden !important;
  }
  
  .pm-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative !important;
    height: calc(100vh - 50px) !important;
  }
  
  #pm-messages {
    flex: 1;
    max-height: none !important;
    min-height: 80px;
    font-size: 1em;
    padding: 8px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    background: #fff;
    overflow-y: auto;
    order: 1;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 130px !important;
  }
  
  #pm-form {
    position: absolute !important;
    bottom: 70px !important;
    left: 0 !important;
    right: 0 !important;
    background: #f9f9f9;
    z-index: 10;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 4px;
    gap: 6px;
    flex-direction: row;
    align-items: center;
    order: 2;
    height: 60px !important;
  }
  
  .pm-actions {
    padding: 8px 4px;
    background: #f0f0f0;
    border-top: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    order: 3;
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 70px !important;
  }
  
  #pm-form .btn, #pm-form button {
    min-height: 44px;
    font-size: 1.1em;
  }
  
  .pm-actions .btn {
    flex: 1;
    min-height: 44px;
    font-size: 1.1em;
    margin: 0 2px;
  }
  
  /* Verbessertes Touch-Ziel für die Buttons */
  .pm-close-mobile {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Admin/Mod-Button-Leiste immer sichtbar */
@media (max-width: 900px), (max-height: 600px) {
  .admin-btn-grid, .admin-footer-buttons {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 20;
    width: 100vw;
    box-sizing: border-box;
    padding: 8px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  .admin-btn-grid .btn, .admin-footer-buttons .btn {
    min-height: 44px;
    font-size: 1.1em;
    width: 100%;
  }
}

/* Speziell für Samsung Galaxy Geräte */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
  .private-message-popup {
    position: fixed !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
  }
  
  .pm-body {
    position: relative !important;
    height: calc(100% - 50px) !important;
    max-height: calc(100% - 50px) !important;
    overflow: hidden !important;
  }
  
  #pm-messages {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 130px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  #pm-form {
    position: absolute !important;
    bottom: 70px !important;
    left: 0 !important;
    right: 0 !important;
  }
  
  .pm-actions {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
  }
}

/* Speziell für Notebooks mit kleineren Bildschirmen */
@media (max-width: 1366px) and (max-height: 768px) {
    .smiley-container {
        max-height: 70vh;
        width: 550px;
        max-width: 80%;
        /* z-index wird vom PopupManager verwaltet */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .smiley-grid {
        gap: 8px;
    }
    
    .smiley-grid li img {
        max-width: 30px;
        max-height: 30px;
    }
}
