.smiley-container {
    position: fixed;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    /* z-index wird vom PopupManager verwaltet */
    width: 760px;
    max-width: 95vw;
    max-height: 80vh;
    padding: 10px 12px;
    overflow: hidden;
}

.smiley-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 10px;
    /* cursor: move; entfernt, damit Dropdown nicht blockiert wird */
    background: white;
    z-index: 10;
    padding: 5px 0;
    border-bottom: 1px solid #ccc;
}

/* Titelzeile + Close nebeneinander */
.smiley-header .smiley-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.smiley-header .smiley-title h3 {
    margin: 0;
    font-size: 16px;
}

.smiley-header .close {
    width: 22px;
    height: 22px;
}

.smiley-header h3 {
    margin: 0;
    font-size: 16px;
}

.smiley-header .close {
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
}

.smiley-sort-dropdown {
    margin-left: auto; /* Positioniert das Dropdown rechts im Header */
    padding: 5px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    z-index: 9999 !important;
    position: relative !important;
    pointer-events: auto !important;
}

.smiley-body {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.smiley-grid {
    display: flex;
    flex-wrap: wrap; /* Ermöglicht das Umbruch der Smileys in die nächste Zeile */
    gap: 8px; /* Von 5px auf 8px vergrößert für bessere Optik */
    list-style: none;
    padding: 0;
}

.smiley-grid li {
    list-style: none;
    display: inline-block;
    cursor: pointer;
}

.smiley-grid img {
    max-width: 90px; /* Von 70px auf 90px vergrößert (+28%) */
    height: auto; /* Höhe automatisch anpassen, um das Seitenverhältnis beizubehalten */
    display: block; /* Zentriert das Bild im Container */
    margin: 0 auto; /* Zentriert das Bild horizontal */
    cursor: pointer;
    transition: transform 0.2s; /* Smooth hover-Effekt */
}

.smiley-grid img:hover {
    transform: scale(1.1); /* Hover-Vergrößerung für bessere UX */
}
/* Desktop: Scrollbare Inhalte im Smiley-Popup sicherstellen */
@media (min-width: 1025px) {
    .smiley-container .smiley-content,
    .smiley-container .smiley-body {
        overflow-y: auto !important;
        max-height: 60vh !important;
        height: auto !important;
        pointer-events: auto !important;
    }

    .smiley-container {
        width: 820px;
        max-width: 92vw;
        max-height: 82vh;
    }
}

.smiley-divider {
    width: 100%;
    border: none;
    border-top: 1px solid #ccc;
    margin: 10px 0;
}

@media (max-width: 600px) {
    .smiley-container {
        width: 98vw;
        max-width: 100vw;
        min-width: unset;
        left: 50%;
        top: 10px;
        transform: translate(-50%, 0);
        border-radius: 0;
        padding: 4px;
        box-sizing: border-box;
        max-height: 70vh !important; /* Begrenzung der Höhe für mobiles Scrollen */
        overflow-y: auto !important; /* Vertikales Scrollen aktivieren */
        -webkit-overflow-scrolling: touch; /* Für iOS-Geräte flüssigeres Scrollen aktivieren */
    }

    .smiley-header {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 8px 4px !important;
        font-size: 1em !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .smiley-header .smiley-title .close {
        width: 18px !important;
        height: 18px !important;
    }

    .smiley-header-title-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-bottom: 6px;
    }

    .smiley-header-title-row h3 {
        margin: 0;
        font-size: 1.1em;
        font-weight: bold;
    }

    .smiley-header .close {
        flex: 0 0 auto;
        margin: 0 !important;
        align-self: flex-start !important;
        display: block !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        padding: 0 !important;
        z-index: 2 !important;
        position: relative;
    }

    .smiley-header .close img {
        width: 34px !important;
        height: 34px !important;
        display: block;
        background: #fff !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 8px #0001;
        margin: 0;
        padding: 4px;
        z-index: 2 !important;
        position: relative;
    }

    .smiley-sort-dropdown {
        width: 100% !important;
        max-width: 100vw;
        margin-bottom: 8px;
        z-index: 1;
        font-size: 1em;
        align-self: stretch;
    }

    .smiley-body {
        gap: 6px;
    }

    .smiley-grid {
        gap: 6px; /* Von 4px auf 6px vergrößert für Mobile */
    }

    .smiley-grid img {
        max-width: 60px; /* Von 44px auf 60px vergrößert für Mobile (+36%) */
    }
}

.smiley-moderation-popup {
    min-width: 800px !important;
    max-width: 99vw !important;
}

.bildupload-moderation-popup .bildupload-popup-body {
    max-height: 70vh !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    touch-action: auto;
}

/* --- Fix: Bild-Overlay immer groß und sichtbar (Override) --- */
.image-preview-overlay {
    position: fixed !important;
    z-index: 99999 !important;
    left: 0 !important; top: 0 !important; right: 0 !important; bottom: 0 !important;
    background: rgba(0,0,0,0.88) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: zoom-out !important;
    padding: 40px 10px 10px 10px !important;
}
.image-preview-large {
    width: auto !important;
    height: auto !important;
    max-width: 95vw !important;
    max-height: 85vh !important;
    box-shadow: 0 0 32px #000 !important;
    border-radius: 10px !important;
    background: #fff !important;
    margin-bottom: 10px !important;
    display: block !important;
}
.image-preview-overlay .image-preview-link {
    color: #fff !important;
    background: #222 !important;
    padding: 8px 18px !important;
    border-radius: 8px !important;
    margin-bottom: 18px !important;
    text-decoration: underline !important;
    font-size: 1.1em !important;
    display: inline-block !important;
    position: static !important;
}

/* --- Ultra-Fix: Erzwinge Größe für Overlay-Bild gegen alle Fremd-Styles --- */
div.image-preview-overlay img.image-preview-large,
.bildupload-moderation-popup div.image-preview-overlay img.image-preview-large,
.smiley-moderation-popup div.image-preview-overlay img.image-preview-large {
    width: auto !important;
    height: auto !important;
    max-width: 98vw !important;
    max-height: 90vh !important;
    min-width: 0 !important;
    min-height: 0 !important;
    box-shadow: 0 0 32px #000 !important;
    border-radius: 10px !important;
    background: #fff !important;
    margin-bottom: 10px !important;
    display: block !important;
}

/* Smiley-Button mobile nur auf kleinen Bildschirmen anzeigen */
#smiley-btn-mobile { display: none; }
.send-btn-mobile { display: none; }
.send-btn-desktop { display: none; }
@media (max-width: 800px) {
  #smiley-btn-mobile { display: inline-flex !important; }
  .send-btn-mobile { display: inline-flex !important; }
  .send-btn-desktop { display: none !important; }
  .message-form-icons .btn-smiley { display: none !important; }
}
@media (min-width: 801px) {
  #smiley-btn-mobile { display: none !important; }
  .send-btn-mobile { display: none !important; }
  .send-btn-desktop { display: inline-flex !important; }
  .message-form-icons .btn-smiley { display: inline-flex !important; }
  .message-input-container {
    flex-direction: row !important;
    align-items: center !important;
    gap: 0 !important;
    min-height: unset !important;
    height: auto !important;
  }
  .message-input-container > div {
    min-height: unset !important;
    height: auto !important;
    width: auto !important;
  }
}
