/* ═══════════════════════════════════════════════
   ESCAPE FROM CAPITALISM — VaultBBS Chat Styles
   CRT/BBS aesthetic, ephemeral messaging
   ═══════════════════════════════════════════════ */

/* ── Chat Screen Layout ──────────────────────────────────────────────────── */

#chat-screen {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);  /* account for nav bar */
    overflow: hidden;
}

/* ── Chat Container ──────────────────────────────────────────────────────── */

.chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.chat-sidebar {
    width: 200px;
    background: #0a0a0a;
    border-right: 1px solid #0a4f0a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.chat-sidebar-section {
    padding: 12px 10px;
    border-bottom: 1px solid #0a4f0a;
}

.chat-sidebar-section h3 {
    color: #ffb000;
    font-size: 10px;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-shadow: 0 0 4px #ffb000;
    font-weight: normal;
}

.chat-sidebar-section ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.chat-sidebar-section li {
    padding: 5px 8px;
    color: #0a4f0a;
    cursor: pointer;
    font-size: 13px;
    transition: color 0.15s, text-shadow 0.15s;
    border-left: 2px solid transparent;
}

.chat-sidebar-section li:hover {
    color: #e0e0e0;
}

.chat-sidebar-section li.active {
    color: #00ff41;
    text-shadow: 0 0 6px #00ff41;
    border-left-color: #00ff41;
}

.chat-sidebar-section li .online-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #00ff41;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 4px #00ff41;
}

.chat-sidebar-footer {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid #0a4f0a;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.chat-sidebar-footer .chat-handle {
    color: #00ff41;
    text-shadow: 0 0 4px #00ff41;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-disconnect-btn {
    background: none;
    border: 1px solid #0a4f0a;
    color: #0a4f0a;
    font-family: inherit;
    font-size: 10px;
    padding: 3px 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.15s, border-color 0.15s;
}

.chat-disconnect-btn:hover {
    color: #ff3333;
    border-color: #ff3333;
}

/* ── Mobile Header (chat only) ──────────────────────────────────────────── */

.chat-mobile-header {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #0a4f0a;
    background: #0a0a0a;
}

.chat-mobile-header .chat-logo {
    color: #00ff41;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 4px #00ff41;
}

.chat-mobile-header .chat-handle-mobile {
    color: #ffb000;
    flex: 1;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-hamburger {
    background: none;
    border: 1px solid #0a4f0a;
    color: #00ff41;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
}

/* ── Messages Area ──────────────────────────────────────────────────────── */

.chat-messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    scroll-behavior: smooth;
}

/* ── Individual Messages ─────────────────────────────────────────────────── */

.chat-msg {
    margin-bottom: 10px;
    padding: 4px 0;
    animation: chatMsgFadeIn 0.3s ease;
    line-height: 1.5;
}

.chat-msg .chat-sender {
    color: #00ff41;
    font-weight: bold;
    text-shadow: 0 0 4px #00ff41;
}

.chat-msg.self .chat-sender {
    color: #ffb000;
    text-shadow: 0 0 4px #ffb000;
}

.chat-msg .chat-time {
    color: #0a4f0a;
    font-size: 11px;
    margin-left: 8px;
}

.chat-msg .chat-content {
    color: #e0e0e0;
    display: block;
    margin-top: 2px;
    word-wrap: break-word;
}

/* ── Message Dissolve Animation ──────────────────────────────────────────── */

.chat-msg.expiring {
    animation: chatDissolve 5s ease forwards;
}

.chat-msg.expiring .chat-content {
    animation: chatGlitchText 0.3s steps(2) infinite;
}

.chat-msg.dissolved {
    display: none;
}

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

@keyframes chatDissolve {
    0%   { opacity: 1; filter: none; }
    20%  { opacity: 0.9; filter: brightness(1.2); }
    40%  { opacity: 0.7; filter: brightness(0.8); }
    60%  { opacity: 0.5; filter: blur(0.5px); }
    80%  { opacity: 0.2; filter: blur(1px); }
    100% { opacity: 0; filter: blur(2px); height: 0; margin: 0; padding: 0; overflow: hidden; }
}

@keyframes chatGlitchText {
    0%   { transform: translateX(0); }
    25%  { transform: translateX(-1px); }
    50%  { transform: translateX(1px); }
    75%  { transform: translateX(-1px); }
    100% { transform: translateX(0); }
}

/* ── Rate Limit Bar ─────────────────────────────────────────────────────── */

.chat-rate-bar {
    height: 28px;
    background: rgba(255, 176, 0, 0.1);
    border-top: 1px solid #ffb000;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.chat-rate-bar-fill {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    background: rgba(255, 176, 0, 0.2);
    transition: width 0.1s linear;
}

.chat-rate-bar-text {
    position: relative;
    z-index: 1;
    color: #ffb000;
    font-size: 12px;
    padding: 0 12px;
    text-shadow: 0 0 4px #ffb000;
    width: 100%;
    text-align: center;
}

/* ── Message Form ────────────────────────────────────────────────────────── */

.chat-msg-form {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #0a4f0a;
    background: #0a0a0a;
}

#chat-msg-input {
    flex: 1;
    background: #050505;
    border: 1px solid #0a4f0a;
    color: #e0e0e0;
    font-family: 'DejaVu Sans Mono', 'IBM Plex Mono', 'Fira Mono', 'Consolas', monospace;
    font-size: 14px;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#chat-msg-input:focus {
    border-color: #00ff41;
    box-shadow: 0 0 4px rgba(0,255,65,0.2);
}

.chat-send-btn {
    background: #00ff41;
    color: #050505;
    border: none;
    font-family: 'DejaVu Sans Mono', 'IBM Plex Mono', 'Fira Mono', 'Consolas', monospace;
    font-size: 13px;
    font-weight: bold;
    padding: 8px 16px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: opacity 0.15s, box-shadow 0.15s;
}

.chat-send-btn:hover {
    opacity: 0.85;
    box-shadow: 0 0 8px #00ff41;
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Chat Welcome / Empty State ──────────────────────────────────────────── */

.chat-welcome {
    color: #0a4f0a;
    text-align: center;
    padding: 40px 20px;
    font-size: 13px;
    line-height: 1.8;
}

.chat-welcome strong {
    color: #00ff41;
    text-shadow: 0 0 4px #00ff41;
}

/* ── Sidebar Overlay (mobile) ───────────────────────────────────────────── */

.chat-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

.chat-sidebar-overlay.show {
    display: block;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */

#chat-messages::-webkit-scrollbar { width: 6px; }
#chat-messages::-webkit-scrollbar-track { background: #050505; }
#chat-messages::-webkit-scrollbar-thumb { background: #0a4f0a; }
#chat-messages::-webkit-scrollbar-thumb:hover { background: #00ff41; }

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

.chat-room-header {
    padding: 8px 16px;
    border-bottom: 1px solid #0a4f0a;
    background: #0a0a0a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-room-header .chat-room-name {
    color: #00ff41;
    font-size: 13px;
    text-shadow: 0 0 4px #00ff41;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.chat-room-header .chat-msg-count {
    color: #0a4f0a;
    font-size: 11px;
    margin-left: auto;
}

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

@media (max-width: 700px) {
    .chat-mobile-header {
        display: flex;
    }

    .chat-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        z-index: 100;
        transition: left 0.25s ease;
        background: #0a0a0a;
    }

    .chat-sidebar.open {
        left: 0;
    }

    .chat-sidebar-footer .chat-disconnect-btn {
        display: inline-block;
    }

    #chat-screen {
        height: 100vh;
    }
}

@media (min-width: 701px) {
    .chat-mobile-header {
        display: none;
    }
    
    .chat-sidebar-footer .chat-disconnect-btn {
        display: inline-block;
    }
}