/* ═══════════════════════════════════════════
   GLHF Unified Chat - Dark Theme
   ═══════════════════════════════════════════ */

/* Enerhodar: не оголошуємо @font-face тут — у темі (main.css) уже є з ascent-override;
   повторний @font-face без тих самих метрик ламав вирівнювання цифр у .header-wallet на /stream/. */

/* Page wrapper — override theme defaults for fullscreen chat */
.stream-chat-page {
    padding-top: var(--glhf-header-height, 80px) !important;
    padding-bottom: 4rem !important; /* Fixed: added padding above footer */
    min-height: 100vh;
}

.admin-bar .stream-chat-page {
    padding-top: calc(var(--glhf-header-height, 80px) + 32px) !important;
}

@media (max-width: 782px) {
    .admin-bar .stream-chat-page {
        padding-top: calc(var(--glhf-header-height, 80px) + 46px) !important;
    }
}

/* ── Two-column Stream Layout ── */
.stream-layout {
    display: flex;
    height: calc(100vh - var(--glhf-header-height, 80px));
    overflow: hidden;
}

.admin-bar .stream-layout {
    height: calc(100vh - var(--glhf-header-height, 80px) - 32px);
}

@media (max-width: 782px) {
    .admin-bar .stream-layout {
        height: calc(100vh - var(--glhf-header-height, 80px) - 46px);
    }
}

.stream-layout-troll {
    width: 420px;
    min-width: 350px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid #1e2a3a;
    background: #0a0e14;
    scrollbar-width: thin;
    scrollbar-color: #2a3a50 #0a0e14;
}

.stream-layout-troll::-webkit-scrollbar { width: 5px; }
.stream-layout-troll::-webkit-scrollbar-track { background: #0a0e14; }
.stream-layout-troll::-webkit-scrollbar-thumb { background: #2a3a50; border-radius: 3px; }

.stream-layout-chat {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Troll panel adjustments when inside stream layout */
.stream-layout-troll .glhf-troll-container {
    max-width: 100%;
    padding: 1rem;
}

.stream-layout-troll .troll-header {
    border-radius: 0;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
}

.stream-layout-troll .troll-header::before {
    display: none;
}

.stream-layout-troll .troll-actions {
    grid-template-columns: 1fr;
}

.stream-layout-troll .troll-action-card {
    padding: 1rem;
}

.stream-layout-troll .troll-offline-notice {
    border-radius: 12px;
}

/* Chat adjustments when inside stream layout */
.stream-layout-chat .glhf-uc-wrap {
    height: 100%;
}

@media (max-width: 900px) {
    .stream-layout {
        flex-direction: column-reverse;
    }

    .stream-layout-troll {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-top: 1px solid #1e2a3a;
        max-height: 45vh;
    }

    .stream-layout-chat {
        flex: 1;
        min-height: 0;
    }
}

.glhf-uc-wrap {
    --uc-bg: transparent;
    --uc-bg-toolbar: rgba(0, 0, 0, 0.25);
    --uc-bg-card: #111822;
    --uc-border: rgba(0, 255, 100, 0.15); /* Firm accent border */
    --uc-text: #e8edf3;
    --uc-text-dim: #8899aa;
    --uc-text-muted: #5a6a7a;
    --uc-green: #00ff64;
    --uc-red: #f44336;
    --uc-twitch: #9146ff;
    --uc-youtube: #ff0000;
    --uc-discord: #5865f2;
    --uc-radius: 14px;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--uc-text);
    display: flex;
    flex-direction: column;
    height: 100%;
    -webkit-font-smoothing: antialiased;

    overflow: hidden;
}

/* Glassmorphism Styles (Only for standard web, NOT overlays) */
.stream-layout-chat .glhf-uc-wrap {
    background: linear-gradient(145deg, rgba(0, 255, 100, .06) 0%, rgba(120, 80, 220, .04) 50%, rgba(10, 14, 20, .85) 100%);
    border: 1px solid var(--uc-border);
    border-radius: var(--uc-radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    backdrop-filter: blur(12px);
}

/* ── Toolbar ── */
.uc-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--uc-bg-toolbar);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.uc-toolbar-title {
    font-family: 'Enerhodar', 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--uc-text);
    margin-right: auto;
}

.uc-filters {
    display: flex;
    gap: 6px;
    align-items: center;
}

.uc-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--uc-border);
    border-radius: 4px;
    background: transparent;
    color: var(--uc-text);
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.uc-filter-btn[data-source="twitch"] { border-color: var(--uc-twitch); color: var(--uc-twitch); }
.uc-filter-btn[data-source="youtube"] { border-color: var(--uc-youtube); color: var(--uc-youtube); }
.uc-filter-btn[data-source="discord"] { border-color: var(--uc-discord); color: var(--uc-discord); }

.uc-filter-btn.uc-filter-off {
    opacity: 0.3;
    border-color: var(--uc-border);
    color: var(--uc-text-muted);
}

.uc-statuses {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

/* ── Voice Channel Counts ── */
.uc-voice-counts {
    display: flex;
    gap: 8px;
    align-items: center;
}

.uc-voice-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid rgba(88, 101, 242, 0.3);
    background: rgba(88, 101, 242, 0.08);
    color: var(--uc-text-dim);
    transition: all 0.3s ease;
    cursor: default;
    position: relative;
}

.uc-voice-badge.has-members {
    border-color: rgba(88, 101, 242, 0.5);
    background: rgba(88, 101, 242, 0.12);
    color: var(--uc-text);
}

.uc-voice-badge-icon {
    display: inline-flex;
    align-items: center;
    color: var(--uc-discord);
    flex-shrink: 0;
}

.uc-voice-badge-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    text-transform: uppercase;
}

.uc-voice-badge-count {
    font-weight: 800;
    font-size: 13px;
    color: var(--uc-discord);
    min-width: 14px;
    text-align: center;
}

.uc-voice-badge.has-members .uc-voice-badge-count {
    color: #7b8cff;
}

.uc-voice-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--uc-text-muted);
    flex-shrink: 0;
}

.uc-voice-badge.has-members .uc-voice-badge-dot {
    background: var(--uc-green);
    box-shadow: 0 0 6px var(--uc-green);
    animation: uc-pulse 1.5s infinite;
}

/* Tooltip with member names */
.uc-voice-badge-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--uc-bg-card);
    border: 1px solid var(--uc-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--uc-text-dim);
    white-space: normal;
    max-width: 600px;
    min-width: 360px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    line-height: 1.6;
}

.uc-voice-badge-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 16px;
    border: 5px solid transparent;
    border-bottom-color: var(--uc-border);
}

@media (max-width: 480px) {
    .uc-voice-badge-tooltip {
        min-width: 0;
        max-width: calc(100vw - 24px);
    }
}

.uc-voice-badge.has-members:hover .uc-voice-badge-tooltip {
    display: block;
}

.uc-source-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--uc-text-muted);
}

.uc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--uc-text-muted);
}

.uc-status-live .uc-status-dot { background: var(--uc-red); box-shadow: 0 0 6px var(--uc-red); animation: uc-pulse 1.5s infinite; }
.uc-status-on .uc-status-dot { background: var(--uc-green); }
.uc-status-off .uc-status-dot { background: var(--uc-text-muted); }
.uc-status-error .uc-status-dot { background: var(--uc-red); }
.uc-status-no-stream .uc-status-dot { background: #ff9800; }

.uc-status-live { color: var(--uc-red); }
.uc-status-on { color: var(--uc-green); }
.uc-status-no-stream { color: #ff9800; }
.uc-status-error { color: var(--uc-red); }

@keyframes uc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Chat Area ── */
.uc-chat-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.uc-chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px; /* Reduced margin between messages */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.uc-chat-messages::-webkit-scrollbar { width: 6px; }
.uc-chat-messages::-webkit-scrollbar-track { background: transparent; }
.uc-chat-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 3px; }

.uc-chat-messages::after {
    content: '';
    display: block;
    flex-shrink: 0;
    min-height: 20px;
}

.uc-chat-messages:not(.uc-align-top)::before {
    content: '';
    flex: 1 1 auto;
}
.uc-chat-messages.uc-align-top::before {
    display: none;
}

/* ── Message ── */
.uc-msg {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Glassmorphism for Messages on Web UI */
.stream-layout-chat .uc-msg {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-left: 3px solid transparent; /* Keeps text aligned and reserves space */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stream-layout-chat .uc-msg:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.07);
    border-left-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

/* Base colored stripes only for main Web UI chat */
.stream-layout-chat .uc-msg.uc-msg-twitch { border-left-color: var(--uc-twitch); }
.stream-layout-chat .uc-msg.uc-msg-youtube { border-left-color: var(--uc-youtube); }
.stream-layout-chat .uc-msg.uc-msg-discord { border-left-color: var(--uc-discord); }

.stream-layout-chat .uc-msg.uc-msg-twitch:hover { border-left-color: var(--uc-twitch); box-shadow: -2px 0 12px rgba(145, 70, 255, 0.25), 0 6px 18px rgba(0, 0, 0, 0.2); }
.stream-layout-chat .uc-msg.uc-msg-youtube:hover { border-left-color: var(--uc-youtube); box-shadow: -2px 0 12px rgba(255, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.2); }
.stream-layout-chat .uc-msg.uc-msg-discord:hover { border-left-color: var(--uc-discord); box-shadow: -2px 0 12px rgba(88, 101, 242, 0.25), 0 6px 18px rgba(0, 0, 0, 0.2); }

.uc-time {
    font-size: 11px;
    color: var(--uc-text-muted);
    font-variant-numeric: tabular-nums;
    opacity: 0.6;
    margin-right: 8px;
}

.uc-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    width: 20px;
    height: 18px;
    padding: 2px;
    border-radius: 3px;
    line-height: 1;
    margin-right: 8px;
    opacity: 0.8;
}

.uc-badge svg {
    width: 12px;
    height: 12px;
}

.uc-badge-twitch { background: rgba(145, 70, 255, 0.2); color: var(--uc-twitch); }
.uc-badge-youtube { background: rgba(255, 0, 0, 0.15); color: #ff4444; }
.uc-badge-discord { background: rgba(88, 101, 242, 0.2); color: var(--uc-discord); }
.uc-badge-donation { background: rgba(0, 255, 100, 0.16); color: var(--uc-green); }
.uc-badge-local { background: rgba(0, 255, 100, 0.1); color: var(--uc-green); }

.uc-author {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    margin-right: 8px;
    letter-spacing: 0.2px;
}

.uc-msg-twitch .uc-author { color: #b78eff; }
.uc-msg-youtube .uc-author { color: #ff8888; }
.uc-msg-discord .uc-author { color: #8e9bff; }
.uc-msg-donation .uc-author { color: #00ff64; font-weight: 700; text-shadow: 0 1px 4px rgba(0,255,100,0.4); }
.uc-msg-donation {
    border: 1px solid rgba(0, 255, 100, 0.15);
    border-left: 3px solid var(--uc-green);
    background: linear-gradient(90deg, rgba(0, 255, 100, 0.07), rgba(0, 255, 100, 0.01));
    box-shadow: 0 0 12px rgba(0, 255, 100, 0.2);
}
.uc-msg-donation:hover {
    border-color: rgba(0, 255, 100, 0.25);
    box-shadow: 0 0 16px rgba(0, 255, 100, 0.4);
}

.uc-btn-replay {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    float: right;
    width: 24px;
    height: 24px;
    margin-left: 10px;
    margin-top: -3px;
    margin-bottom: -3px;
    background: rgba(0, 255, 100, 0.1);
    color: var(--uc-green);
    border: 1px solid rgba(0, 255, 100, 0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}
.uc-btn-replay:hover {
    background: rgba(0, 255, 100, 0.25);
    border-color: rgba(0, 255, 100, 0.4);
    transform: scale(1.05);
}
.uc-btn-replay:active {
    transform: scale(0.95);
}
.uc-btn-replay.uc-replay-loading {
    opacity: 0.5;
    pointer-events: none;
    animation: uc-spin 1s linear infinite;
}
.uc-btn-replay.uc-replay-success {
    background: var(--uc-green);
    color: #000;
    animation: none;
}
@keyframes uc-spin { 
    to { transform: rotate(360deg); } 
}

.uc-mod-badge {
    margin-right: 3px;
    font-size: 12px;
}

.uc-text {
    color: var(--uc-text);
    text-shadow: 0 0 3px #000;
}

.uc-text a {
    color: #72aee6;
    text-decoration: none;
}
.uc-text a:hover {
    text-decoration: underline;
}

.uc-text .uc-code-inline {
    font-family: "Courier New", Consolas, monospace;
    font-size: 0.9em;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 3px;
    padding: 1px 5px;
}

.uc-text .uc-spoiler {
    background: #4a4a4a;
    color: transparent;
    border-radius: 3px;
    padding: 0 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.uc-text .uc-spoiler:hover,
.uc-text .uc-spoiler.uc-revealed {
    background: rgba(255,255,255,0.08);
    color: inherit;
}

.uc-text strong { font-weight: 700; }
.uc-text em { font-style: italic; }
.uc-text del { text-decoration: line-through; opacity: 0.7; }
.uc-text u { text-decoration: underline; }

/* ── System messages ── */
.uc-msg-system {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 4px 0;
    border-radius: 6px;
    font-size: 0.85em;
    line-height: 1.4;
}
.uc-msg-system-error {
    background: rgba(244, 67, 54, 0.15);
    border-left: 3px solid #f44336;
    color: #ff8a80;
}
.uc-msg-system-success {
    background: rgba(76, 175, 80, 0.15);
    border-left: 3px solid #4caf50;
    color: #69f0ae;
}
.uc-system-icon {
    flex-shrink: 0;
    font-size: 1.1em;
}
.uc-system-text {
    flex: 1;
}

/* ── Appear animations ── */
.uc-appear-fade {
    animation: uc-a-fade-in 0.4s ease both;
}
.uc-appear-slide-left {
    animation: uc-a-slide-left 0.4s ease both;
}
.uc-appear-slide-right {
    animation: uc-a-slide-right 0.4s ease both;
}
.uc-appear-slide-up {
    animation: uc-a-slide-up 0.4s ease both;
}

@keyframes uc-a-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes uc-a-slide-left {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes uc-a-slide-right {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes uc-a-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Disappear animations ── */
.uc-disappear-fade {
    animation: uc-d-fade 1s ease forwards;
}
.uc-disappear-slide-left {
    animation: uc-d-slide-left 0.6s ease forwards;
}
.uc-disappear-slide-right {
    animation: uc-d-slide-right 0.6s ease forwards;
}
.uc-disappear-slide-down {
    animation: uc-d-slide-down 0.6s ease forwards;
}

@keyframes uc-d-fade {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes uc-d-slide-left {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-60px); }
}
@keyframes uc-d-slide-right {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(60px); }
}
@keyframes uc-d-slide-down {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(30px); }
}

.uc-discord-channel {
    font-size: 10px;
    color: var(--uc-text-muted);
    margin-right: 2px;
}

/* ── Scroll to bottom button ── */
.uc-scroll-btn {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--uc-text);
    background: rgba(17, 24, 34, 0.9);
    border: 1px solid var(--uc-border);
    border-radius: 20px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    z-index: 10;
    transition: all 0.2s ease;
}

.uc-scroll-btn:hover {
    background: rgba(30, 42, 58, 0.95);
    border-color: var(--uc-green);
    color: var(--uc-green);
}

/* ── Empty state ── */
.uc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--uc-text-muted);
    gap: 12px;
    padding: 40px;
    text-align: center;
}

.uc-empty-icon {
    font-size: 48px;
    opacity: 0.3;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .uc-toolbar {
        padding: 8px 12px;
        gap: 8px;
    }

    .uc-toolbar-title {
        font-size: 13px;
        width: 100%;
    }

    .uc-msg {
        font-size: 13px;
    }

    .uc-chat-messages {
        padding: 8px;
    }

    .uc-voice-counts {
        gap: 4px;
    }

    .uc-voice-badge {
        padding: 3px 6px;
        gap: 4px;
        font-size: 11px;
    }

    .uc-voice-badge-name {
        max-width: 70px;
        font-size: 10px;
    }
}

/* ── Local Chat Input ── */
.uc-chat-input-area {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}
.uc-chat-form {
    display: flex;
    gap: 10px;
}
.uc-chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--uc-text);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}
.uc-chat-input:focus {
    border-color: rgba(0, 255, 100, 0.4);
    box-shadow: 0 0 0 2px rgba(0, 255, 100, 0.1);
}
.uc-send-btn {
    background: rgba(0, 255, 100, 0.1);
    color: var(--uc-green);
    border: 1px solid rgba(0, 255, 100, 0.2);
    border-radius: 8px;
    padding: 0 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.uc-send-btn:hover {
    background: rgba(0, 255, 100, 0.2);
    border-color: rgba(0, 255, 100, 0.4);
    transform: translateY(-1px);
}
.uc-chat-auth-prompt {
    text-align: center;
    font-size: 13px;
    color: var(--uc-text-muted);
    padding: 6px 0;
}
.uc-chat-auth-prompt a {
    color: var(--uc-green);
    text-decoration: none;
    font-weight: 600;
}
.uc-chat-auth-prompt a:hover {
    text-decoration: underline;
}

/* Local Message Brand */
.stream-layout-chat .uc-msg.uc-msg-local {
    border-left-color: var(--uc-green);
}
.uc-msg-local .uc-author {
    color: var(--uc-green) !important;
}
.stream-layout-chat .uc-msg.uc-msg-local:hover {
    border-left-color: var(--uc-green);
    box-shadow: -2px 0 12px rgba(0, 255, 100, 0.25), 0 6px 18px rgba(0, 0, 0, 0.2);
}
