/* ===== Looking4Group Chat – Styles ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0b141a;
    --panel:     #111b21;
    --panel-2:   #202c33;
    --input-bg:  #2a3942;
    --accent:    #00a884;
    --accent-2:  #25d366;
    --text:      #e9edef;
    --text-dim:  #8696a0;
    --bubble-me: #005c4b;
    --bubble-other: #202c33;
    --border:    #2a3942;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b141a, #16242e);
}
.auth-card {
    background: var(--panel);
    padding: 40px 34px;
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.logo { text-align: center; color: var(--accent-2); font-size: 1.8rem; }
.subtitle { text-align: center; color: var(--text-dim); margin: 6px 0 24px; font-size: .9rem; }
.tabs { display: flex; margin-bottom: 20px; border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.tab { flex: 1; padding: 12px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: .95rem; }
.tab.active { background: var(--accent); color: #fff; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form input, .dialog input, .dialog textarea {
    background: var(--input-bg);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 13px 15px;
    color: var(--text);
    font-size: .95rem;
    outline: none;
}
.auth-form input:focus, .dialog input:focus, .dialog textarea:focus { border-color: var(--accent); }
.auth-form button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.auth-form button:hover { background: var(--accent-2); }
.msg { text-align: center; margin-top: 16px; font-size: .88rem; min-height: 1.2em; }
.msg.error { color: #ff6b6b; }
.msg.success { color: var(--accent-2); }

/* ---------- App-Layout ---------- */
.app { display: flex; height: 100vh; }

.sidebar {
    width: 340px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--panel-2);
}
.me { display: flex; align-items: center; gap: 12px; }
.me-info { display: flex; flex-direction: column; line-height: 1.3; }
.my-id { font-size: .78rem; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.copy-btn { background: none; border: none; color: var(--accent-2); cursor: pointer; font-size: .9rem; }
.avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; flex-shrink: 0;
}
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 1.3rem; cursor: pointer; }
.icon-btn:hover { color: var(--text); }

.sidebar-actions { display: flex; gap: 8px; padding: 12px 16px; }
.action-btn {
    flex: 1;
    background: var(--panel-2);
    border: none;
    color: var(--text);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
}
.action-btn:hover { background: var(--input-bg); }

.conversation-list { list-style: none; overflow-y: auto; flex: 1; }
.empty-hint { padding: 24px 18px; color: var(--text-dim); font-size: .85rem; text-align: center; line-height: 1.5; }
.conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,.03);
}
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--panel-2); }
.conv-body { flex: 1; min-width: 0; }
.conv-title { display: flex; justify-content: space-between; }
.conv-title strong { font-size: .95rem; }
.conv-title .badge { font-size: .65rem; background: var(--accent); color:#fff; padding: 1px 7px; border-radius: 10px; align-self:center; }
.conv-last { color: var(--text-dim); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ---------- Chatbereich ---------- */
.chat-area { flex: 1; display: flex; flex-direction: column; background: #0b141a; }
.placeholder { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
.placeholder-inner h2 { color: var(--accent-2); margin-bottom: 8px; }
.placeholder-inner p { color: var(--text-dim); margin: 4px 0; }
.placeholder-inner .hint { margin-top: 18px; font-size: .9rem; }

.chat-window { flex: 1; display: flex; flex-direction: column; height: 100vh; }
.chat-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
}
.chat-subtitle { display: block; font-size: .78rem; color: var(--text-dim); }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 8%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background-image: linear-gradient(rgba(11,20,26,.96), rgba(11,20,26,.96));
}
.bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: .92rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}
.bubble.other { background: var(--bubble-other); align-self: flex-start; border-top-left-radius: 2px; }
.bubble.me    { background: var(--bubble-me);    align-self: flex-end;   border-top-right-radius: 2px; }
.bubble .sender { display: block; font-size: .74rem; color: var(--accent-2); margin-bottom: 2px; font-weight: 600; }
.bubble .time { display: block; font-size: .66rem; color: var(--text-dim); text-align: right; margin-top: 3px; }

.message-form {
    display: flex; gap: 10px;
    padding: 14px 18px;
    background: var(--panel-2);
    position: relative;
}

/* ---------- Emoji-Auswahl ---------- */
.emoji-panel {
    position: absolute;
    bottom: 100%; left: 14px; margin-bottom: 8px;
    width: 340px; max-width: calc(100% - 28px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
    overflow: hidden; z-index: 30;
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); }
.emoji-tab {
    flex: 1; background: none; border: none; color: var(--text);
    font-size: 1.15rem; padding: 8px 0; cursor: pointer;
}
.emoji-tab.active { background: var(--panel-2); }
.emoji-grid {
    display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px;
    padding: 8px; overflow-x: hidden;
}
.emoji-cell {
    background: none; border: none; cursor: pointer;
    font-size: 1.3rem; padding: 4px 0; border-radius: 6px; line-height: 1;
    min-width: 0; text-align: center;
}
.emoji-cell:hover { background: var(--panel-2); }
.emoji-empty { grid-column: 1 / -1; padding: 18px 8px; text-align: center; color: var(--text-dim); font-size: .85rem; }
.message-form input {
    flex: 1;
    background: var(--input-bg);
    border: none;
    border-radius: 22px;
    padding: 12px 18px;
    color: var(--text);
    font-size: .95rem;
    outline: none;
}
.message-form button {
    width: 46px; height: 46px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}
.message-form button:hover { background: var(--accent-2); }

/* ---------- Dialoge ---------- */
.dialog {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
}
.dialog-card {
    background: var(--panel);
    padding: 26px;
    border-radius: 14px;
    width: 100%; max-width: 400px;
    display: flex; flex-direction: column; gap: 12px;
}
.dialog-card h3 { color: var(--text); }
.dialog-card p { color: var(--text-dim); font-size: .85rem; }
.dialog-label { color: var(--text-dim); font-size: .82rem; }
.dialog-msg { min-height: 1.1em; font-size: .82rem; color: #ff6b6b; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn-primary { background: var(--accent); color:#fff; border:none; padding: 10px 18px; border-radius: 8px; cursor: pointer; }
.btn-secondary { background: var(--panel-2); color: var(--text); border:none; padding: 10px 18px; border-radius: 8px; cursor: pointer; }

/* ---------- Avatare als Bild ---------- */
img.avatar { object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: .8rem; }
.avatar-lg { width: 80px; height: 80px; font-size: 2rem; }

/* ---------- Seitenleisten-Tabs ---------- */
.sidebar-tabs { display: flex; }
.stab {
    flex: 1; background: var(--panel); border: none;
    color: var(--text-dim); padding: 11px; cursor: pointer;
    border-bottom: 2px solid transparent; font-size: .9rem;
}
.stab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Live-Anruf-Anzeige ---------- */
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.live-call {
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(37, 211, 102, .16); color: var(--accent-2);
    font-size: .8rem; padding: 2px 7px; border-radius: 10px;
    align-self: center; animation: livepulse 1.4s infinite;
}
.live-text { color: var(--accent-2); font-weight: 600; }
.call-live {
    display: flex; align-items: center; gap: 4px;
    color: var(--accent-2); font-size: .8rem; font-weight: 600;
    cursor: pointer; animation: livepulse 1.4s infinite; white-space: nowrap;
}
.icon-btn.live { animation: livepulse 1.4s infinite; }
#call-btn { color: var(--accent-2); }        /* grünes Telefon-Icon */
.ph-ico { vertical-align: -0.15em; }

/* ---------- Ungelesen-Badge ---------- */
.unread {
    background: var(--accent-2); color: #0b141a;
    font-size: .72rem; font-weight: 700;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    align-self: center;
}

/* ---------- Kontakt entfernen ---------- */
.contact-remove { background: none; border: none; color: var(--text-dim); font-size: 1rem; cursor: pointer; }
.contact-remove:hover { color: #ff6b6b; }

/* ---------- Chat-Header ---------- */
.chat-header-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.back-btn { display: none; font-size: 1.6rem; }

/* ---------- Nachrichten-Zeilen ---------- */
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 72%; }
.msg-row.me    { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.other { align-self: flex-start; }
.msg-row .bubble { max-width: 100%; align-self: auto; }
.bubble .text { white-space: pre-wrap; word-wrap: break-word; }
.bubble .text.deleted { font-style: italic; color: var(--text-dim); }
.bubble .meta { display: block; text-align: right; font-size: .66rem; color: var(--text-dim); margin-top: 3px; }
.bubble .meta > * { display: inline; }
.edited { font-style: italic; margin-right: 3px; }
.ticks { margin-left: 3px; }
.ticks.read { color: #53bdeb; }

/* Aktionen (bearbeiten/löschen) */
.msg-actions { display: none; gap: 2px; align-self: center; }
.msg-row:hover .msg-actions { display: flex; }
.msg-act { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: .9rem; padding: 2px; }
.msg-act:hover { color: var(--text); }

/* ---------- Profil-Dialog ---------- */
.profile-avatar-row { display: flex; align-items: center; gap: 16px; }
.file-label {
    display: inline-block; background: var(--panel-2); color: var(--text);
    padding: 11px 14px; border-radius: 8px; cursor: pointer; text-align: center; font-size: .9rem;
}
.file-label:hover { background: var(--input-bg); }

/* ---------- Mitglieder-Dialog ---------- */
.members-list { list-style: none; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.members-list li { display: flex; align-items: center; gap: 10px; }
.member-name { flex: 1; font-size: .92rem; }
.creator-tag { font-size: .64rem; background: var(--panel-2); color: var(--text-dim); padding: 1px 7px; border-radius: 8px; margin-left: 6px; }
.member-remove { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; }
.member-remove:hover { color: #ff6b6b; }
.add-member-row { display: flex; gap: 8px; }
.add-member-row input { flex: 1; }
.btn-danger { background: #c0392b; color: #fff; border: none; padding: 10px 16px; border-radius: 8px; cursor: pointer; margin-right: auto; }
.btn-danger:hover { background: #e74c3c; }

/* ---------- Anhänge ---------- */
.attach-btn {
    width: 46px; height: 46px; border-radius: 50%; border: none;
    background: var(--input-bg); color: var(--text);
    font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
}
.attach-btn:hover { background: var(--panel); }
.attach-btn:disabled { opacity: .6; cursor: default; }

.msg-image-link { display: block; }
.msg-image {
    max-width: 260px; max-height: 300px; border-radius: 8px;
    display: block; cursor: pointer;
}
.msg-image-link + .text { display: block; margin-top: 6px; }

.file-card {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255, 255, 255, .06);
    padding: 10px 12px; border-radius: 8px;
    text-decoration: none; color: var(--text); max-width: 260px;
}
.file-card:hover { background: rgba(255, 255, 255, .12); }
.file-icon { font-size: 1.6rem; line-height: 1; }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: .9rem; word-break: break-all; }
.file-size { font-size: .72rem; color: var(--text-dim); }
.file-card + .text { display: block; margin-top: 6px; }

/* ---------- Sprachnachricht (Player mit Wellenform) ---------- */
.voice-player { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0; }
.voice-player.preview { flex: 1; }
.voice-player + .text { display: block; margin-top: 6px; }
.vp-play {
    width: 34px; height: 34px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; font-size: .85rem; cursor: pointer; flex-shrink: 0;
}
.vp-play:hover { background: var(--accent-2); }
.vp-wave { cursor: pointer; flex-shrink: 0; display: block; width: 150px; height: 30px; }
.voice-player.preview .vp-wave { flex: 1 1 auto; width: 100%; min-width: 0; }
.vp-time { font-size: .72rem; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* ---------- Aufnahme-Leiste ---------- */
.rec-bar {
    position: absolute; left: 10px; right: 10px; top: 50%; transform: translateY(-50%);
    height: 46px; z-index: 5;
    display: flex; align-items: center; gap: 12px;
    background: var(--input-bg); border-radius: 23px; padding: 0 14px;
}
/* In der Leiste kompakter als im Chat */
.rec-bar .voice-player { gap: 8px; }
.rec-bar .vp-play { width: 30px; height: 30px; font-size: .8rem; }
.rec-bar .vp-wave { height: 26px; }

/* Während Aufnahme/Vorschau alle normalen Bedienelemente ausblenden
   (alles außer den beiden Leisten), damit nichts hervorschaut */
.message-form.overlay > *:not(#rec-bar):not(#prev-bar) { visibility: hidden !important; }
.rec-dot {
    width: 12px; height: 12px; border-radius: 50%; background: #ff4d4f;
    animation: recpulse 1s infinite; flex-shrink: 0;
}
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { color: var(--text-dim); font-size: .85rem; flex: 1; }
.rec-send {
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; font-size: 1.05rem; cursor: pointer; flex-shrink: 0;
}
.rec-send:hover { background: var(--accent-2); }

/* ---------- Bild-Lightbox ---------- */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .9);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 24px;
}
.lightbox img {
    max-width: 92vw; max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, .6);
}
.lightbox-close {
    position: absolute; top: 18px; right: 22px;
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255, 255, 255, .12); color: #fff;
    border: none; font-size: 1.3rem; cursor: pointer; line-height: 1;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .25); }

.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 52px; height: 52px; border-radius: 50%;
    background: rgba(255, 255, 255, .12); color: #fff;
    border: none; font-size: 2rem; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, .25); }
.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }

.lightbox-download {
    position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--accent); color: #fff; text-decoration: none;
    padding: 10px 20px; border-radius: 22px; font-size: .9rem; font-weight: 600;
}
.lightbox-download:hover { background: var(--accent-2); }

@media (max-width: 720px) {
    .lightbox-nav { width: 44px; height: 44px; font-size: 1.6rem; }
    .lightbox-nav.prev { left: 8px; }
    .lightbox-nav.next { right: 8px; }
}

/* ---------- Sprachanruf ---------- */
.call-ui {
    position: fixed; right: 20px; top: 72px; z-index: 120;
    width: 260px; max-width: calc(100vw - 32px);
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: 0 14px 44px rgba(0, 0, 0, .55);
    padding: 14px 16px;
}
.call-bar { display: flex; align-items: center; justify-content: space-between; cursor: move; margin: -4px -6px 4px; padding: 2px 4px; touch-action: none; }
.call-grip { color: var(--text-dim); font-size: 1rem; }
.call-min { background: none; border: none; color: var(--text-dim); font-size: 1.15rem; line-height: 1; cursor: pointer; width: 26px; height: 26px; border-radius: 6px; }
.call-min:hover { background: var(--panel-2); color: var(--text); }
.call-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }

/* Minimiert: kompakte Zeile ohne Teilnehmer/Name */
.call-ui.minimized { width: auto; padding: 10px 12px; }
.call-ui.minimized .call-peers, .call-ui.minimized .call-name { display: none; }
.call-ui.minimized .call-card { flex-direction: row; align-items: center; gap: 12px; }
.call-ui.minimized .call-actions { margin-top: 0; gap: 10px; }
.call-ui.minimized .call-btn { width: 40px; height: 40px; font-size: 1.05rem; }
.call-avatar .avatar { width: 96px; height: 96px; font-size: 2.4rem; }
.call-name { font-size: 1.05rem; color: var(--text); }
.call-status { color: var(--text-dim); font-size: .85rem; font-variant-numeric: tabular-nums; }
.call-peers { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 6px; max-width: 420px; }
.peer-chip { display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: .55; }
.peer-chip.on { opacity: 1; }
.peer-chip .avatar { position: relative; }
.peer-chip.on .avatar { box-shadow: 0 0 0 3px var(--accent-2); }
.peer-name { font-size: .72rem; color: var(--text); max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-actions { display: flex; gap: 16px; margin-top: 8px; }
.call-btn {
    width: 48px; height: 48px; border-radius: 50%; border: none;
    font-size: 1.2rem; color: #fff; cursor: pointer;
}
.call-btn.accept { background: #25d366; }
.call-btn.hangup { background: #e53935; }
.call-btn.mute   { background: #3a4a54; }
.call-btn.mute.active { background: #e0a400; }
.call-btn.screen { background: #3a4a54; }
.call-btn.screen.active { background: var(--accent); }
.call-btn.cam { background: #3a4a54; }
.call-btn.cam.active { background: var(--accent); }

/* Video-Kacheln (Kamera & Bildschirm) */
.call-videos { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; width: 100%; }
.call-video { width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; background: #000; object-fit: cover; cursor: zoom-in; }
.call-video.self { outline: 2px solid var(--accent-2); }
.call-video.mirror { transform: scaleX(-1); }
.call-ui.minimized .call-videos { display: none; }
.call-btn:hover { filter: brightness(1.12); }
#remote-audios { display: none; }
@media (max-width: 720px) {
    .call-ui { right: 10px; left: 10px; width: auto; top: 60px; padding: 12px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .sidebar { width: 100%; }
    .chat-area { display: none; }
    .app.mobile-chat .sidebar { display: none; }
    .app.mobile-chat .chat-area { display: flex; }
    .back-btn { display: block; }
    .msg-row { max-width: 85%; }
}
