/* ==============================================
   AudioNido — Chat Sidebar
   Visual desktop mode only (>900px viewport)
   ============================================== */

/* ── Layout: main becomes flex row when chat is open ── */
.mode-visual.chat-sidebar-open #main-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    overflow: visible;
}

.mode-visual.chat-sidebar-open #main-content > .container {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    margin: 0;
}

/* ── Sidebar shell ── */
#chat-sidebar {
    flex: 0 0 300px;
    width: 300px;
    background: rgba(15, 15, 26, 0.97);
    border-left: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 84px);
    position: sticky;
    top: 84px;
    overflow: hidden;
    transition: flex-basis 0.2s ease, width 0.2s ease;
}

#chat-sidebar.chat-collapsed {
    flex-basis: 44px;
    width: 44px;
}

/* ── Chat panel (when a station is active) ── */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
    gap: 6px;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-station-name {
    font-size: 0.78em;
    font-weight: 700;
    color: var(--accent, #00E5FF);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-listeners {
    font-size: 0.7em;
    color: rgba(255, 255, 255, 0.4);
}

.chat-collapse-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.3em;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.chat-collapse-btn:hover,
.chat-collapse-btn:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

/* ── Messages list ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.chat-messages::-webkit-scrollbar {
    width: 3px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

/* ── Individual message bubble ── */
.chat-message {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px 10px 10px 2px;
    padding: 6px 10px;
    max-width: 94%;
    align-self: flex-start;
    word-break: break-word;
}

.chat-message.chat-mine {
    background: rgba(78, 205, 196, 0.13);
    border-radius: 10px 10px 2px 10px;
    align-self: flex-end;
}

.chat-msg-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}

.chat-msg-name {
    font-size: 0.7em;
    font-weight: 700;
    color: var(--accent-hover, #00B8D4);
}

.chat-message.chat-mine .chat-msg-name {
    color: var(--accent, #00E5FF);
}

.chat-msg-time {
    font-size: 0.64em;
    color: rgba(255, 255, 255, 0.28);
}

.chat-msg-text {
    font-size: 0.81em;
    color: rgba(255, 255, 255, 0.87);
    line-height: 1.45;
}

.chat-empty {
    font-size: 0.78em;
    color: rgba(255, 255, 255, 0.32);
    text-align: center;
    padding: 24px 12px;
    margin: auto;
}

/* ── Input area ── */
.chat-input-area {
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-login-prompt {
    font-size: 0.76em;
    color: rgba(255, 255, 255, 0.38);
    text-align: center;
    padding: 8px 0;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chat-input-field {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.81em;
    color: #fff;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.chat-input-field:focus {
    border-color: rgba(78, 205, 196, 0.5);
    background: rgba(255, 255, 255, 0.09);
}

.chat-input-field::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

.chat-input-field:disabled {
    opacity: 0.5;
}

.chat-send-btn {
    background: var(--accent-hover, #00B8D4);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #0d0d0d;
    transition: background 0.15s, opacity 0.15s;
    padding: 0;
}

.chat-send-btn:hover,
.chat-send-btn:focus-visible {
    background: var(--accent, #00E5FF);
    outline: none;
}

.chat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.chat-cooldown {
    font-size: 0.7em;
    color: rgba(255, 255, 255, 0.38);
    text-align: right;
    padding-right: 4px;
}

.chat-error {
    font-size: 0.7em;
    color: #ff6b6b;
    padding: 1px 2px;
}

/* ── Collapsed vertical bar ── */
.chat-collapsed-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 44px;
}

.chat-expand-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.72em;
    font-family: inherit;
    cursor: pointer;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 14px 8px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.15s;
}

.chat-expand-btn:hover,
.chat-expand-btn:focus-visible {
    color: var(--accent, #00E5FF);
    outline: none;
}

/* ── Feed panel (no station playing) ── */
.chat-feed {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-feed-header {
    padding: 10px 12px;
    font-size: 0.72em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.42);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

.chat-feed-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.chat-feed-list::-webkit-scrollbar {
    width: 3px;
}

.chat-feed-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.chat-feed-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 9px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 7px;
    border-left: 2px solid rgba(78, 205, 196, 0.3);
}

.chat-feed-item-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.chat-feed-avatar {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: none;
    font-size: 0.58em;
    font-weight: 700;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.chat-feed-avatar:hover { opacity: 0.8; transform: scale(1.1); }

.chat-feed-station {
    flex: 1;
    min-width: 0;
    font-size: 0.7em;
    font-weight: 700;
    color: var(--accent-hover, #00B8D4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* button reset */
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    transition: color 0.15s;
}
.chat-feed-station:hover { color: #fff; }

.chat-feed-user {
    font-size: 0.67em;
    color: rgba(255, 255, 255, 0.35);
}

.chat-feed-msg {
    font-size: 0.77em;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Responsive: hide on narrow viewports ── */
@media (max-width: 900px) {
    #chat-sidebar {
        display: none !important;
    }

    .mode-visual.chat-sidebar-open #main-content {
        display: block;
    }

    .mode-visual.chat-sidebar-open #main-content > .container {
        max-width: var(--max-width);
        margin: 0 auto;
    }
}
