/* ============================================================
   xPulse Chat – views/chat.css
   ============================================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar       { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg-system {
    text-align: center;
    font-size: 11px;
    color: var(--text-dim);
    padding: 0.5rem 0;
}

.msg {
    display: flex;
    flex-direction: column;
    max-width: 72%;
    animation: msgIn 0.2s ease both;
}
.msg.mine   { align-self: flex-end;   align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
    padding: 0.55rem 0.85rem;
    border-radius: 2px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.msg.mine   .msg-bubble { background: var(--accent); color: #fff; }
.msg.theirs .msg-bubble { background: var(--surface); border: 1px solid var(--border); color: var(--text); }

.msg-meta {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

/* Typing indicator */
#typing-indicator {
    padding: 0.2rem 1.2rem 0;
    min-height: 1.35rem;
    display: none;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}
#typing-indicator.visible { display: block; }

.typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    margin-left: 0.3rem;
    vertical-align: middle;
}
.typing-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Input area */
.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 0.85rem 1.2rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    padding: 0.6rem 0.85rem;
    outline: none;
    resize: none;
    border-radius: 2px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.2s;
}
.chat-input-area textarea:focus       { border-color: var(--accent); }
.chat-input-area textarea::placeholder { color: var(--muted); }
.chat-input-area textarea:disabled    { opacity: 0.4; cursor: not-allowed; }

.btn-send {
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 18px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.btn-send:hover    { opacity: 0.8; }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Chat Layout mit Info Panel ── */

#content:has(.chat-wrap) {
    flex-direction: row;
    overflow: hidden;
}

.chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    position: relative;  /* Anker für floating toggle */
}

/* ── Info Tab Toggle Button ── */

.chat-info-toggle {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 10;
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 3px 0 0 3px;
    color: var(--text-dim);
    font-size: 11px;
    width: 18px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    line-height: 1;
    box-shadow: -2px 0 6px rgba(0,0,0,0.25);
    padding: 0;
}
.chat-info-toggle:hover { border-color: var(--accent2); color: var(--accent2); }
.chat-info-toggle.hidden { display: none; }

/* ── Chat Info Panel ── */

.chat-info-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
    animation: slideInRight 0.2s ease both;
}

.chat-info-panel.hidden { display: none; }

.chat-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-info-title {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.chat-info-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    padding: 0.1rem;
    line-height: 1;
    transition: color 0.15s;
}
.chat-info-close:hover { color: var(--text); }

.chat-info-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Peer Block */
.chat-info-peer {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.chat-info-peer-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--mono);
}

.chat-info-peer-status {
    font-size: 11px;
    color: var(--text-dim);
}

/* Stats */
.chat-info-stats {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.chat-info-label {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.chat-info-value {
    font-size: 11px;
    color: var(--text);
    font-family: var(--mono);
    text-align: right;
}

/* Actions */
.chat-info-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.chat-info-btn-danger {
    width: auto;
    background: none;
    border: 1px solid #c0606a33;
    border-radius: 2px;
    color: #c0606a88;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chat-info-btn-danger:hover { background: #c0606a12; border-color: #c0606a66; color: #c0606a; }

/* ── Mobile: Panel als Overlay von rechts ── */

@media (max-width: 768px) {
    #content:has(.chat-wrap) {
        position: relative;
    }

    .chat-info-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 300;
        width: min(280px, 85vw);
        border-left: 1px solid var(--border);
    }

    .chat-info-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 299;
    }
    .chat-info-backdrop.hidden { display: none; }
}

@media (min-width: 769px) {
    .chat-info-backdrop { display: none !important; }
}
