/* ═══════════════════════════════════════════════════════════
   Webradio Manager v2 — Chat UI Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Chat Toggle Button (in header) ──────────────────────── */

.chat-toggle-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

#chat-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 6px 12px;
    color: var(--text-primary, #e0e0e0);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, border-color 0.2s;
}

#chat-toggle-btn:hover {
    background: var(--bg-tertiary, #2a2a3e);
    border-color: var(--accent-color, #6366f1);
}

#chat-toggle-btn svg {
    width: 18px;
    height: 18px;
}

#chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
}

/* ── Chat Panel (sidebar) ────────────────────────────────── */

#chat-panel {
    position: fixed;
    right: -380px;
    top: 0;
    bottom: 0;
    width: 360px;
    max-width: 100vw;
    background: var(--bg-primary, #121218);
    border-left: 1px solid var(--border-color, #333);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

#chat-panel.open {
    right: 0;
}

/* ── Chat Header ─────────────────────────────────────────── */

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #333);
    background: var(--bg-secondary, #1e1e2e);
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #e0e0e0);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header h3 svg {
    width: 18px;
    height: 18px;
    color: var(--accent-color, #6366f1);
}

#chat-online-count {
    font-size: 12px;
    color: var(--text-secondary, #888);
    font-weight: 400;
}

#chat-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    cursor: pointer;
    font-size: 22px;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

#chat-close-btn:hover {
    color: var(--text-primary, #e0e0e0);
}

/* ── Chat Messages ───────────────────────────────────────── */

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color, #333);
    border-radius: 3px;
}

/* ── Chat Message ────────────────────────────────────────── */

.chat-msg {
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border-color, #333);
    animation: chatMsgIn 0.15s ease-out;
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.deleted {
    opacity: 0.5;
    background: transparent;
    border-color: transparent;
    padding: 4px 10px;
}

.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.chat-msg-user {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color, #6366f1);
}

.chat-msg-user.own {
    color: #22c55e;
}

.chat-msg-time {
    font-size: 11px;
    color: var(--text-muted, #555);
    margin-left: auto;
}

.chat-msg-delete {
    background: none;
    border: none;
    color: var(--text-muted, #555);
    cursor: pointer;
    font-size: 12px;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.chat-msg:hover .chat-msg-delete {
    opacity: 1;
}

.chat-msg-delete:hover {
    color: #ef4444;
}

.chat-msg-text {
    font-size: 13px;
    color: var(--text-primary, #e0e0e0);
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg-system {
    font-size: 12px;
    color: var(--text-muted, #555);
    font-style: italic;
}

/* ── Chat Input ──────────────────────────────────────────── */

.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-color, #333);
    background: var(--bg-secondary, #1e1e2e);
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: var(--bg-primary, #121218);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary, #e0e0e0);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
}

#chat-input:focus {
    border-color: var(--accent-color, #6366f1);
}

#chat-input::placeholder {
    color: var(--text-muted, #555);
}

#chat-send-btn {
    background: var(--accent-color, #6366f1);
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

#chat-send-btn:hover:not(:disabled) {
    background: var(--accent-hover, #818cf8);
}

#chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Empty State ─────────────────────────────────────────── */

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted, #555);
    text-align: center;
    padding: 20px;
}

.chat-empty svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.chat-empty p {
    font-size: 13px;
    margin: 0;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 480px) {
    #chat-panel {
        width: 100vw;
        right: -100vw;
    }

    #chat-panel.open {
        right: 0;
    }
}
