/* === Flexbox-Layout (Hauptcontainer) === */
.reakom-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Chat-Pane (integriertes Sliding Pane, KEIN Overlay) === */
.chat-pane {
    width: 0;
    overflow: hidden;
    background: white;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    flex-shrink: 0;
}

.chat-pane.open {
    width: 380px;
}

/* === Chat-Icon in XAF-Toolbar (per JS injiziert) === */
.chat-toolbar-item {
    display: inline-flex;
    align-items: center;
}

.chat-toolbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.chat-toolbar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: #dc3545;
    color: white;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* === Pane-Header === */
.chat-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #6c757d;
    padding: 0 4px;
    line-height: 1;
}

.chat-close-btn:hover {
    color: #212529;
}

/* === Chat-Liste === */
.chat-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-list-header {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.chat-search-input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
}

.chat-search-input:focus {
    border-color: #3459e6;
}

.chat-new-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #3459e6;
    color: white;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-new-btn:hover {
    background: #2a47c4;
}

.chat-list-items {
    flex: 1;
    overflow-y: auto;
}

.chat-list-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.chat-list-item:hover {
    background: #f8f9fa;
}

.chat-list-item.unread {
    background: #f0f4ff;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #495057;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.preview-sender {
    font-weight: 600;
    color: #495057;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.chat-time {
    font-size: 11px;
    color: #adb5bd;
}

.chat-list-badge {
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #3459e6;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.chat-loading,
.chat-empty {
    padding: 24px 16px;
    text-align: center;
    color: #adb5bd;
    font-size: 14px;
}

/* === Conversation Header === */
.chat-conversation {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-conv-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.chat-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    padding: 4px;
    display: flex;
    align-items: center;
}

.chat-back-btn:hover {
    color: #212529;
}

.chat-conv-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-conv-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-members {
    font-size: 12px;
    color: #6c757d;
}

.chat-open-detail-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #adb5bd;
    padding: 0;
    margin-left: auto;
    margin-right: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.chat-open-detail-btn:hover {
    color: #3459e6;
}

/* === Nachrichten-Bereich === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* === Chat-Bubbles === */
.chat-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-bubble.own {
    margin-left: auto;
    background: #3459e6;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.other {
    margin-right: auto;
    background: #f0f0f0;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.bubble-sender {
    font-size: 12px;
    font-weight: 600;
    color: #3459e6;
    margin-bottom: 2px;
}

.chat-bubble.own .bubble-time {
    color: rgba(255, 255, 255, 0.7);
}

.bubble-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
    margin-top: 2px;
}

/* === Tipp-Anzeige === */
.chat-typing {
    padding: 2px 16px;
    font-size: 12px;
    color: #6c757d;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
}

.typing-dots span {
    animation: typingDot 1.4s infinite;
    font-size: 18px;
    line-height: 1;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.2; }
    30% { opacity: 1; }
}

/* === Eingabe === */
.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
    align-items: flex-end;
}

.chat-input-field {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    font-family: inherit;
}

.chat-input-field:focus {
    border-color: #3459e6;
}

/* Anhang-Button (Büroklammer) */
.chat-attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    color: #6c757d;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.chat-attach-btn:hover:not(:disabled) {
    color: #3459e6;
    background: #f0f4ff;
}

.chat-attach-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3459e6;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #2a47c4;
}

.chat-send-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
}

/* === Neuer Chat Dialog === */
.chat-new-dialog {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-new-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 8px 0;
}

.chat-new-body .chat-search-input {
    margin: 0 16px 8px;
    flex: 0 0 auto;
}

.chat-user-list {
    flex: 1;
    overflow-y: auto;
}

.chat-user-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    align-items: center;
}

.chat-user-item:hover {
    background: #f8f9fa;
}

.chat-user-name {
    font-size: 14px;
    font-weight: 500;
}

/* === Teilnehmerverwaltung === */
.chat-members {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-members-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-members-list {
    flex: 1;
    overflow-y: auto;
}

.chat-member-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    align-items: center;
}

.chat-member-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.chat-member-you {
    font-weight: 400;
    color: #6c757d;
    font-size: 12px;
    margin-left: 4px;
}

.chat-member-remove {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #adb5bd;
    padding: 0 4px;
    line-height: 1;
}

.chat-member-remove:hover {
    color: #dc3545;
}

.chat-members-add {
    border-top: 1px solid #dee2e6;
    padding: 8px 0;
}

.chat-members-add-btn {
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #3459e6;
    font-weight: 500;
    text-align: left;
}

.chat-members-add-btn:hover {
    background: #f8f9fa;
}

.chat-members-add .chat-search-input {
    margin: 4px 16px 8px;
}

.chat-members-add .chat-user-list {
    max-height: 200px;
    overflow-y: auto;
}

/* === Chat-Tab in Aktivität-DetailView === */
.chat-tab-container {
    display: flex;
    flex-direction: column;
    height: 500px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.chat-tab-container .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-tab-container .chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #dee2e6;
    background: white;
    flex-shrink: 0;
    align-items: flex-end;
}

/* === Toast === */
.chat-toast {
    position: fixed;
    top: 56px;
    right: 24px;
    width: 320px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1010;
    cursor: pointer;
    animation: chatSlideDown 0.3s ease;
}

.chat-toast:hover {
    background: #f8f9fa;
}

.chat-toast-sender {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.chat-toast-text {
    font-size: 13px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes chatSlideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* === Chat-Bubble: Anhänge === */

/* Bubble-Text: Abstand zu Anhängen */
.bubble-text + .bubble-pdfs,
.bubble-text + .chat-img-grid {
    margin-top: 6px;
}

.bubble-pdfs + .chat-img-grid {
    margin-top: 6px;
}

/* --- PDF-Zeilen --- */
.bubble-pdf-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.bubble-pdf-row:hover {
    background: rgba(0, 0, 0, 0.06);
}

.chat-bubble.own .bubble-pdf-row:hover {
    background: rgba(255, 255, 255, 0.12);
}

.bubble-pdf-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.chat-bubble.own .bubble-pdf-icon {
    background: rgba(255, 255, 255, 0.18);
}

.bubble-pdf-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.bubble-pdf-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bubble-pdf-size {
    font-size: 11px;
    opacity: 0.7;
}

.bubble-pdf-download {
    flex-shrink: 0;
    opacity: 0.5;
    font-size: 16px;
}

.bubble-pdf-row:hover .bubble-pdf-download {
    opacity: 1;
}

/* --- Bild-Grid (WhatsApp-Style) --- */
.chat-img-grid {
    display: grid;
    gap: 2px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 280px;
}

.chat-img-grid.grid-1 {
    grid-template-columns: 1fr;
}

.chat-img-grid.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.chat-img-grid.grid-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.chat-img-grid.grid-3 .chat-img-cell:first-child {
    grid-row: span 2;
}

.chat-img-grid.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.chat-img-cell {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 1;
    background: #e9ecef;
}

.chat-img-grid.grid-1 .chat-img-cell {
    aspect-ratio: auto;
    max-height: 280px;
}

.chat-img-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.15s;
}

.chat-img-cell:hover img {
    transform: scale(1.05);
}

.chat-img-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Lightbox === */
.chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatFadeIn 0.2s ease;
}

.chat-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.chat-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-lightbox-nav.prev {
    left: 16px;
}

.chat-lightbox-nav.next {
    right: 16px;
}

.chat-lightbox-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* === PDF-Lightbox === */
.chat-lightbox-pdf-container {
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 5%;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.chat-lightbox-pdf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.chat-lightbox-pdf-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-lightbox-pdf-download {
    font-size: 13px;
    color: #1a73e8;
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background 0.15s;
}

.chat-lightbox-pdf-download:hover {
    background: rgba(26, 115, 232, 0.1);
}

.chat-lightbox-pdf-frame {
    flex: 1;
    width: 100%;
    border: none;
}

@keyframes chatFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Upload: Preview-Leiste === */
.chat-upload-preview {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
    overflow-x: auto;
    align-items: center;
}

.upload-preview-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #e9ecef;
}

.upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.upload-preview-pdf {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #6c757d;
    gap: 2px;
    padding: 4px;
}

.upload-preview-pdf-icon {
    font-size: 20px;
}

.upload-preview-pdf-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

.upload-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.upload-preview-remove:hover {
    background: rgba(220, 53, 69, 0.8);
}

.upload-preview-clear {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: none;
    border: 1px solid #adb5bd;
    color: #6c757d;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.upload-preview-clear:hover {
    background: #dee2e6;
    color: #dc3545;
}

/* === Upload: Drag & Drop Overlay === */
.chat-drag-overlay {
    position: absolute;
    inset: 0;
    background: rgba(52, 89, 230, 0.12);
    border: 2px dashed #3459e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.chat-drag-overlay span {
    background: #3459e6;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* === Upload: Fortschritt in Bubble === */
.bubble-upload-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    opacity: 0.8;
}

.bubble-upload-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
}

.chat-bubble.other .bubble-upload-bar {
    background: rgba(0, 0, 0, 0.1);
}

.bubble-upload-bar-fill {
    height: 100%;
    background: white;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.chat-bubble.other .bubble-upload-bar-fill {
    background: #3459e6;
}

/* === Upload: Fehler-Toast === */
.chat-upload-error {
    padding: 6px 16px;
    background: #fff3cd;
    color: #856404;
    font-size: 12px;
    border-top: 1px solid #ffc107;
    flex-shrink: 0;
}
