/* TurcoDC — Discord + Telegram Hybrid Dark/AMOLED Responsive PWA Styles */

:root {
    --bg-rail: #07090e;
    --bg-sidebar: #0f1420;
    --bg-chat: #141a29;
    --bg-elevated: #1b2336;
    --bg-hover: #222c44;
    --bg-input: #0d111b;
    --bubble-self: #253b6e;
    --bubble-other: #1b2438;
    --border: #253047;
    --text: #e6edf5;
    --text-muted: #8e9bb0;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --green: #3ba55d;
    --red: #ed4245;
    --amber: #f0b232;
    --radius: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-rail);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: transparent;
}

a {
    color: #79a6ff;
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Boot & Auth */
.app-booting, .auth-screen {
    height: 100dvh;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow-y: auto;
    background: radial-gradient(circle at top, #18223a 0%, #090c14 70%);
}
.boot-loader { text-align: center; color: var(--text-muted); }
.boot-spinner {
    width: 40px; height: 40px; margin: 0 auto 12px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.auth-logo {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.auth-logo img { width: 44px; height: 44px; border-radius: 12px; }
.auth-logo h1 { margin: 0; font-size: 1.35rem; }
.auth-tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
    background: var(--bg-rail); padding: 4px; border-radius: 10px; margin-bottom: 16px;
}
.auth-tab {
    padding: 8px; border-radius: 8px; font-weight: 600; color: var(--text-muted);
}
.auth-tab.active { background: var(--accent); color: #fff; }

/* Main Layout */
.workspace {
    display: grid;
    grid-template-columns: 70px 265px 1fr;
    height: 100dvh;
    width: 100%;
    padding-top: var(--safe-top);
}

.left-drawer {
    display: contents;
}

/* Group Rail */
.group-rail {
    background: var(--bg-rail);
    border-right: 1px solid #151b28;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 calc(12px + var(--safe-bottom));
    gap: 10px;
    overflow-y: auto;
    scrollbar-width: none;
}
.rail-btn {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 23px;
    background: var(--bg-elevated);
    color: var(--text);
    font-weight: 700;
    font-size: 0.95rem;
    display: grid;
    place-items: center;
    transition: border-radius 0.18s, background 0.18s;
    flex-shrink: 0;
    overflow: visible;
}
.rail-btn img {
    width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
}
.rail-btn:hover, .rail-btn.active {
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
}
.rail-btn.action {
    color: #57f287;
    background: #141c2b;
    font-size: 1.25rem;
}
.rail-btn.action:hover { background: var(--green); color: #fff; }
.rail-sep { width: 32px; height: 2px; background: var(--border); border-radius: 2px; }
.badge-pill {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 19px; height: 19px;
    padding: 0 5px;
    background: var(--red);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 99px;
    display: grid;
    place-items: center;
    border: 2px solid var(--bg-rail);
}

/* Channel Sidebar */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}
.sidebar-header {
    height: 54px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    gap: 8px;
}
.sidebar-header-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px;
}
.cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 8px 4px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.ch-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 9px;
    color: var(--text-muted);
    text-align: left;
    margin-bottom: 2px;
}
.ch-item:hover { background: var(--bg-hover); color: var(--text); }
.ch-item.active { background: #263352; color: #fff; font-weight: 600; }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-tag {
    background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 800;
    padding: 1px 6px; border-radius: 6px; letter-spacing: 0.04em;
}

/* Voice Channel Member Tree inside Sidebar */
.voice-tree {
    padding: 2px 0 6px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.voice-tree-user {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.83rem; color: #c7d2e3; padding: 3px 6px; border-radius: 7px;
}
.voice-tree-user:hover { background: rgba(255,255,255,0.04); }
.avatar-xs {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700;
    display: grid; place-items: center; flex-shrink: 0; object-fit: cover;
}
.speaking-ring {
    box-shadow: 0 0 0 2.5px var(--green), 0 0 10px rgba(59, 165, 93, 0.65) !important;
}

/* Persistent Bottom Voice Bar + User Footer */
.voice-bar {
    background: #0c121e;
    border-top: 1px solid var(--border);
    padding: 9px 10px;
}
.voice-bar-top {
    display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 7px;
}
.voice-status-text { font-size: 0.8rem; font-weight: 700; color: var(--green); }
.voice-bar-actions {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
}
.vbtn {
    padding: 6px 4px; border-radius: 8px; background: var(--bg-elevated);
    font-size: 0.82rem; font-weight: 600; color: var(--text);
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.vbtn:hover { background: var(--bg-hover); }
.vbtn.active { background: var(--green); color: #fff; }
.vbtn.danger { background: rgba(237, 66, 69, 0.2); color: #ff8082; }
.vbtn.danger:hover { background: var(--red); color: #fff; }

.user-footer {
    background: #0a0e17;
    border-top: 1px solid var(--border);
    padding: 9px 10px calc(9px + var(--safe-bottom));
    display: flex;
    align-items: center;
    gap: 9px;
}
.avatar-sm {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff; font-weight: 700;
    display: grid; place-items: center; flex-shrink: 0; object-fit: cover;
}
.user-footer-meta { flex: 1; min-width: 0; }
.user-footer-name { font-weight: 700; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-footer-sub { font-size: 0.74rem; color: var(--text-muted); }

/* Main Chat & Stage Column */
.main-col {
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    position: relative;
}
.topbar {
    height: 54px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(15, 20, 32, 0.88);
    backdrop-filter: blur(8px);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mobile-menu-btn { display: none; font-size: 1.3rem; padding: 6px; border-radius: 8px; }
.topbar-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-topic { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
    padding: 7px 10px; border-radius: 8px; background: var(--bg-elevated);
    color: var(--text); font-size: 0.85rem; font-weight: 600;
}
.icon-btn:hover { background: var(--bg-hover); }

/* Pinned Banner */
.pin-bar {
    background: #192238;
    border-bottom: 1px solid var(--border);
    padding: 6px 14px;
    font-size: 0.83rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Voice Stage & Screen Share Area */
.voice-stage {
    background: #0b0f19;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    max-height: 56vh;
    overflow-y: auto;
}
.stage-video-wrap {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
    max-height: 40vh;
    display: flex;
    justify-content: center;
}
.stage-video-wrap video {
    width: 100%;
    max-height: 40vh;
    object-fit: contain;
}
.stage-video-controls {
    position: absolute;
    bottom: 8px; right: 8px;
    display: flex; gap: 6px;
    background: rgba(0, 0, 0, 0.65);
    padding: 5px 8px;
    border-radius: 8px;
}
.voice-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 8px;
}
.voice-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.voice-card-head { display: flex; align-items: center; gap: 9px; }
.vol-slider-row { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--text-muted); }
.vol-slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }

/* Walkie Banner */
.walkie-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: rgba(240, 178, 50, 0.13); border: 1px solid rgba(240, 178, 50, 0.45);
    padding: 8px 12px; border-radius: 10px; margin-top: 8px; font-size: 0.84rem;
}
.ptt-hold-btn {
    padding: 9px 16px; border-radius: 99px; background: var(--amber); color: #111;
    font-weight: 800; user-select: none; touch-action: none;
}
.ptt-hold-btn.recording { background: var(--red); color: #fff; transform: scale(1.04); }

/* Telegram-Style Chat Stream */
.messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.msg-row {
    display: flex;
    gap: 9px;
    max-width: 82%;
    align-items: flex-end;
}
.msg-row.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.msg-bubble {
    background: var(--bubble-other);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px 14px 14px 4px;
    padding: 8px 12px;
    min-width: 110px;
    position: relative;
    word-break: break-word;
}
.msg-row.mine .msg-bubble {
    background: var(--bubble-self);
    border-radius: 14px 14px 4px 14px;
}
.msg-sender {
    font-size: 0.78rem; font-weight: 700; color: #8ab4f8; margin-bottom: 2px;
    cursor: pointer;
}
.msg-reply-quote {
    border-left: 3px solid var(--accent);
    background: rgba(0, 0, 0, 0.22);
    padding: 4px 8px;
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 0.8rem;
    cursor: pointer;
}
.msg-text { white-space: pre-wrap; }
.msg-text code {
    background: rgba(0, 0, 0, 0.35); padding: 1px 5px; border-radius: 5px; font-size: 0.88em;
}
.msg-text pre {
    background: #0a0e17; padding: 9px; border-radius: 8px; overflow-x: auto; margin: 6px 0;
}
.mention-chip {
    background: rgba(88, 101, 242, 0.28); color: #c9d2ff; padding: 0 4px; border-radius: 4px; font-weight: 600;
}
.msg-trans-box {
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px dashed rgba(255, 255, 255, 0.16);
    font-size: 0.76rem;
    color: #b7c6de;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.msg-attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 5px; }
.msg-img {
    max-width: min(340px, 68vw);
    max-height: 280px;
    border-radius: 10px;
    cursor: zoom-in;
    object-fit: cover;
}
.file-pill {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(0, 0, 0, 0.28); padding: 7px 11px; border-radius: 8px; font-size: 0.84rem;
}

/* Voice Note Waveform Player */
.vn-player {
    display: flex; align-items: center; gap: 9px; min-width: 220px; padding: 4px 0;
}
.vn-play-btn {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff;
    display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.vn-bars {
    flex: 1; height: 26px; display: flex; align-items: center; gap: 2px; cursor: pointer;
}
.vn-bar {
    flex: 1; background: rgba(255, 255, 255, 0.3); border-radius: 2px; min-height: 4px;
}
.vn-bar.played { background: #7ee787; }
.vn-speed-btn {
    padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,0.3); font-size: 0.72rem; font-weight: 700;
}

/* Reactions & Footer Meta */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.react-chip {
    padding: 2px 7px; border-radius: 99px; font-size: 0.76rem;
    background: rgba(255, 255, 255, 0.08); border: 1px solid transparent;
}
.react-chip.mine { background: rgba(88, 101, 242, 0.28); border-color: var(--accent); }
.msg-meta {
    display: flex; align-items: center; justify-content: flex-end; gap: 6px;
    font-size: 0.7rem; color: rgba(230, 237, 245, 0.6); margin-top: 3px;
}
.msg-actions {
    opacity: 0; transition: opacity 0.15s;
    display: flex; gap: 3px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: 8px; padding: 2px 4px;
}
.msg-row:hover .msg-actions, .msg-row:focus-within .msg-actions { opacity: 1; }
.msg-actions button { font-size: 0.8rem; padding: 3px 5px; border-radius: 5px; }
.msg-actions button:hover { background: var(--bg-hover); }

/* Composer */
.composer-wrap {
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
    padding: 8px 12px calc(8px + var(--safe-bottom));
}
.typing-line {
    font-size: 0.75rem; color: #7ee787; min-height: 17px; padding: 0 4px 3px;
}
.composer-banner {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-elevated); padding: 6px 10px; border-radius: 8px;
    margin-bottom: 6px; font-size: 0.82rem;
}
.composer-attachments {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px;
}
.pending-att {
    background: var(--bg-elevated); border: 1px solid var(--border);
    padding: 4px 9px; border-radius: 8px; font-size: 0.8rem; display: flex; align-items: center; gap: 6px;
}
.composer-row {
    display: flex; align-items: flex-end; gap: 8px;
}
.composer-input {
    flex: 1;
    max-height: 130px;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    resize: none;
}
.composer-input:focus { outline: none; border-color: var(--accent); }
.send-btn {
    height: 40px; padding: 0 15px; border-radius: 11px;
    background: var(--accent); color: #fff; font-weight: 700;
}
.send-btn:hover { background: var(--accent-hover); }

/* Modals, Forms & Lightbox */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(4, 6, 12, 0.76);
    display: grid; place-items: center;
    padding: 16px;
}
.modal {
    width: 100%; max-width: 560px; max-height: 88dvh;
    background: var(--bg-sidebar); border: 1px solid var(--border);
    border-radius: 16px; display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 780px; }
.modal-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; font-weight: 700;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: #b8c4d8; margin-bottom: 4px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 9px 11px; border-radius: 9px;
    background: var(--bg-input); border: 1px solid var(--border);
}
.btn-primary {
    padding: 9px 16px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700;
}
.btn-secondary {
    padding: 9px 14px; border-radius: 9px; background: var(--bg-elevated); color: var(--text); font-weight: 600;
}
.btn-danger {
    padding: 8px 13px; border-radius: 9px; background: rgba(237, 66, 69, 0.2); color: #ff8587; font-weight: 600;
}
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-chip {
    padding: 5px 10px; border-radius: 99px; background: var(--bg-elevated);
    border: 1px solid var(--border); font-size: 0.82rem; cursor: pointer;
}
.lang-chip.selected { background: rgba(88, 101, 242, 0.3); border-color: var(--accent); color: #fff; }

.lightbox {
    position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,0.9);
    display: grid; place-items: center; padding: 20px; cursor: zoom-out;
}
.lightbox img { max-width: 95vw; max-height: 90dvh; border-radius: 8px; }

#toast-root {
    position: fixed; bottom: calc(18px + var(--safe-bottom)); right: 18px; z-index: 120;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    background: #1e2942; border: 1px solid var(--border); color: #fff;
    padding: 10px 15px; border-radius: 10px; font-size: 0.88rem;
    box-shadow: 0 10px 24px rgba(0,0,0,0.45); pointer-events: auto;
    display: flex; align-items: center; gap: 8px; max-width: min(390px, calc(100vw - 36px));
}
.toast.err { border-color: var(--red); background: #2c161b; }
.toast-count {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 99px;
    flex-shrink: 0;
}

/* Multilingual Switcher Pills (TR / EN / RU) */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--bg-rail);
    border: 1px solid var(--border);
    padding: 2px;
    border-radius: 99px;
    flex-shrink: 0;
}
.lang-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.lang-pill:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}
.lang-pill.active {
    background: var(--accent);
    color: #fff;
}

/* Mobile Responsive Drawer & Long Cyrillic/Multilingual Label Safety */
@media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; }
    .mobile-menu-btn { display: inline-flex; }
    .left-drawer {
        position: fixed; inset: 0 auto 0 0; z-index: 75;
        display: grid; grid-template-columns: 66px 255px;
        height: 100dvh; transform: translateX(-102%);
        transition: transform 0.22s ease;
        box-shadow: 16px 0 40px rgba(0,0,0,0.6);
    }
    .left-drawer.open { transform: translateX(0); }
    .drawer-backdrop {
        position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.55);
    }
    .msg-row { max-width: 92%; }
    .msg-actions { opacity: 1; }
    .walkie-bar { flex-wrap: wrap; }
    .composer-banner { flex-wrap: wrap; gap: 6px; }
    .topbar { padding: 0 10px; gap: 6px; }
    .lang-pill { padding: 3px 6px; font-size: 0.7rem; }
}
