/* ============================================================
   TarnShift – Teamchat Messenger Styles
   ============================================================ */

.chat-layout {
    display: flex; height: calc(100vh - 56px);
    background: var(--bg-primary, #0f1117);
}

/* ---- Sidebar ---- */
.chat-sidebar {
    width: 320px; min-width: 280px; max-width: 360px;
    background: var(--bg-secondary, #161822);
    border-right: 1px solid var(--border-color, #2a2d3a);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.chat-sidebar-header {
    padding: 1rem; border-bottom: 1px solid var(--border-color, #2a2d3a);
    display: flex; align-items: center; gap: 0.75rem;
}
.chat-sidebar-header h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.chat-search-box {
    margin: 0.5rem 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary, #1e2030);
    border: 1px solid var(--border-color, #2a2d3a);
    border-radius: 8px; color: var(--text-primary, #e2e4f0);
    font-size: 0.85rem; width: calc(100% - 1.5rem);
    outline: none; transition: border-color 0.2s;
}
.chat-search-box:focus { border-color: var(--primary, #8b5cf6); }
.chat-kanal-list {
    flex: 1; overflow-y: auto; padding: 0.25rem 0;
}
.chat-kanal-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.chat-kanal-item:hover { background: rgba(139,92,246,0.08); }
.chat-kanal-item.active {
    background: rgba(139,92,246,0.12);
    border-left-color: var(--primary, #8b5cf6);
}
.chat-kanal-icon {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
    background: rgba(139,92,246,0.15);
}
.chat-kanal-icon.team-service { background: rgba(16,185,129,0.15); }
.chat-kanal-icon.team-kueche { background: rgba(239,68,68,0.15); }
.chat-kanal-icon.team-manager { background: rgba(245,158,11,0.15); }
.chat-kanal-info { flex: 1; min-width: 0; }
.chat-kanal-name {
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-primary, #e2e4f0);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-kanal-preview {
    font-size: 0.75rem; color: var(--text-muted, #6b7280);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
}
.chat-kanal-meta {
    display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
    flex-shrink: 0;
}
.chat-kanal-time { font-size: 0.65rem; color: var(--text-muted, #6b7280); }
.chat-badge {
    background: var(--primary, #8b5cf6); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px; display: flex;
    align-items: center; justify-content: center;
    padding: 0 5px;
}
.chat-section-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted, #6b7280);
}

/* ---- Main Chat Area ---- */
.chat-main {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0; background: var(--bg-primary, #0f1117);
}
.chat-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #2a2d3a);
    display: flex; align-items: center; gap: 0.75rem;
    background: var(--bg-secondary, #161822);
}
.chat-header-info { flex: 1; }
.chat-header-name { font-size: 1rem; font-weight: 600; }
.chat-header-sub { font-size: 0.75rem; color: var(--text-muted, #6b7280); }
.chat-header-actions { display: flex; gap: 0.5rem; }
.chat-header-btn {
    background: none; border: 1px solid var(--border-color, #2a2d3a);
    color: var(--text-primary, #e2e4f0);
    padding: 0.35rem 0.6rem; border-radius: 6px;
    cursor: pointer; font-size: 0.8rem;
    transition: all 0.15s;
}
.chat-header-btn:hover { background: rgba(139,92,246,0.15); border-color: var(--primary, #8b5cf6); }

/* Pinned banner */
.chat-pinned-bar {
    padding: 0.5rem 1rem;
    background: rgba(245,158,11,0.1);
    border-bottom: 1px solid rgba(245,158,11,0.2);
    font-size: 0.8rem; cursor: pointer;
    display: flex; align-items: center; gap: 0.5rem;
}
.chat-pinned-bar:hover { background: rgba(245,158,11,0.15); }

/* Messages area */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 1rem 1.25rem;
    display: flex; flex-direction: column; gap: 0.25rem;
}
.chat-date-sep {
    text-align: center; margin: 1rem 0 0.5rem;
    font-size: 0.7rem; color: var(--text-muted, #6b7280);
}
.chat-date-sep span {
    background: var(--bg-secondary, #161822);
    padding: 0.25rem 0.75rem; border-radius: 10px;
}
.chat-msg {
    display: flex; gap: 0.5rem; max-width: 75%;
    animation: chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.chat-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary, #8b5cf6);
    color: #fff; font-size: 0.7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-msg-bubble {
    background: var(--bg-secondary, #161822);
    border: 1px solid var(--border-color, #2a2d3a);
    border-radius: 12px; padding: 0.5rem 0.75rem;
    position: relative; min-width: 60px;
}
.chat-msg.me .chat-msg-bubble {
    background: rgba(139,92,246,0.15);
    border-color: rgba(139,92,246,0.3);
}
.chat-msg-sender {
    font-size: 0.7rem; font-weight: 600;
    color: var(--primary, #8b5cf6);
    margin-bottom: 2px;
}
.chat-msg-text {
    font-size: 0.88rem; line-height: 1.4;
    word-break: break-word;
}
.chat-msg-time {
    font-size: 0.6rem; color: var(--text-muted, #6b7280);
    text-align: right; margin-top: 4px;
}
.chat-msg-image {
    max-width: 280px; border-radius: 8px;
    cursor: pointer; margin: 4px 0;
}
.chat-msg-file {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem; background: var(--bg-tertiary, #1e2030);
    border-radius: 8px; font-size: 0.8rem; margin: 4px 0;
    text-decoration: none; color: var(--text-primary);
}
.chat-msg-file:hover { background: rgba(139,92,246,0.1); }
.chat-msg-pinned { border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.05); }
.chat-msg-deleted .chat-msg-text { font-style: italic; color: var(--text-muted); }
.chat-msg-reactions {
    display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap;
}
.chat-reaktion-chip {
    background: var(--bg-tertiary, #1e2030);
    border: 1px solid var(--border-color, #2a2d3a);
    border-radius: 12px; padding: 2px 6px;
    font-size: 0.7rem; cursor: pointer;
    transition: all 0.15s;
}
.chat-reaktion-chip:hover { border-color: var(--primary); }
.chat-reaktion-chip.mine { border-color: var(--primary); background: rgba(139,92,246,0.15); }

/* Message actions (hover) */
.chat-msg-actions {
    position: absolute; top: -8px; right: 4px;
    display: none; gap: 2px;
    background: var(--bg-secondary); border-radius: 6px;
    border: 1px solid var(--border-color); padding: 2px;
}
.chat-msg-bubble:hover .chat-msg-actions { display: flex; }
.chat-msg-action-btn {
    background: none; border: none; cursor: pointer;
    font-size: 0.75rem; padding: 2px 4px; border-radius: 4px;
    color: var(--text-muted);
}
.chat-msg-action-btn:hover { background: rgba(139,92,246,0.15); color: var(--text-primary); }

/* ---- Input Area ---- */
.chat-input-area {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color, #2a2d3a);
    background: var(--bg-secondary, #161822);
    display: flex; align-items: flex-end; gap: 0.5rem;
}
.chat-input-wrapper {
    flex: 1; display: flex; align-items: center;
    background: var(--bg-tertiary, #1e2030);
    border: 1px solid var(--border-color, #2a2d3a);
    border-radius: 12px; padding: 0.35rem 0.75rem;
    transition: border-color 0.2s;
}
.chat-input-wrapper:focus-within { border-color: var(--primary, #8b5cf6); }
.chat-input {
    flex: 1; background: none; border: none;
    color: var(--text-primary, #e2e4f0);
    font-size: 0.9rem; outline: none;
    resize: none; max-height: 120px; min-height: 20px;
    line-height: 1.4;
}
.chat-input::placeholder { color: var(--text-muted, #6b7280); }
.chat-attach-btn, .chat-emoji-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; padding: 4px;
    color: var(--text-muted); transition: color 0.15s;
}
.chat-attach-btn:hover, .chat-emoji-btn:hover { color: var(--text-primary); }
.chat-send-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary, #8b5cf6); border: none;
    color: #fff; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; flex-shrink: 0;
}
.chat-send-btn:hover { transform: scale(1.05); background: #7c3aed; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Quick actions bar */
.chat-quick-actions {
    display: flex; gap: 0.5rem; padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow-x: auto;
}
.chat-quick-btn {
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 0.35rem 0.75rem;
    border-radius: 16px; font-size: 0.75rem;
    white-space: nowrap; cursor: pointer; transition: all 0.15s;
}
.chat-quick-btn:hover { border-color: var(--primary); background: rgba(139,92,246,0.1); }

/* ---- Empty State ---- */
.chat-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted); gap: 1rem;
}
.chat-empty-icon { font-size: 3rem; opacity: 0.3; }
.chat-empty-text { font-size: 0.95rem; }

/* ---- Emoji Picker ---- */
.emoji-picker {
    position: absolute; bottom: 100%; right: 0;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 0.75rem;
    display: none; z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}
.emoji-picker.show { display: grid; grid-template-columns: repeat(8,1fr); gap: 4px; }
.emoji-btn {
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; padding: 4px; border-radius: 6px;
    transition: background 0.15s;
}
.emoji-btn:hover { background: rgba(139,92,246,0.15); }

/* ---- Mobile (core rules, layout handled in mobile.css) ---- */
@media(max-width:768px) {
    .chat-layout {
        flex-direction: column;
        position: relative;
    }
    .chat-sidebar {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        flex: 1 !important;
        position: relative;
        z-index: 10;
        display: flex !important;
        flex-direction: column;
        overflow-y: auto;
        border-right: none;
    }
    .chat-main {
        display: none !important;
    }
    /* When a chat is selected, show main and hide sidebar */
    .chat-layout.chat-active .chat-sidebar {
        display: none !important;
    }
    .chat-layout.chat-active .chat-main {
        display: flex !important;
        flex-direction: column;
        flex: 1;
    }
    .chat-msg { max-width: 90%; }
    .chat-search-box { width: calc(100% - 1.5rem); box-sizing: border-box; }
}

/* ---- Navbar Badge ---- */
.nav-chat-badge {
    background: #ef4444; color: #fff;
    font-size: 0.6rem; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 4px; margin-left: 4px;
    vertical-align: super;
}
