/* ============================================================
   Chatas.lt – BS5 šablonas
   ============================================================ */
:root {
    --brand: #4c3bcf;
    --brand-2: #e8590c;
    --bs-primary: #4c3bcf;
    --bs-primary-rgb: 76, 59, 207;
    --bs-link-color: #4c3bcf;
    --bs-link-color-rgb: 76, 59, 207;
    --bs-link-hover-color: #3a2ba8;
    --page-bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --line: rgba(0, 0, 0, .08);
    --muted: #6c757d;
    --mine-bg: #ece9ff;
    --mention-bg: #fff4d6;
    --nav-h: 58px;
}
[data-bs-theme="dark"] {
    --brand: #8f80ff;
    --bs-primary: #7a69f5;
    --bs-primary-rgb: 122, 105, 245;
    --bs-link-color: #a99dff;
    --bs-link-color-rgb: 169, 157, 255;
    --bs-link-hover-color: #c4bcff;
    --page-bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1d212c;
    --line: rgba(255, 255, 255, .08);
    --muted: #9aa0ac;
    --mine-bg: #272247;
    --mention-bg: #3b3218;
    --bs-body-bg: #0f1117;
}
.btn-primary {
    --bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: #3a2ba8; --bs-btn-hover-border-color: #3a2ba8;
    --bs-btn-active-bg: #33259a; --bs-btn-active-border-color: #33259a;
    --bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
}
.text-bg-primary { background-color: var(--bs-primary) !important; }

html, body { min-height: 100%; }
body { background: var(--page-bg); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.min-w-0 { min-width: 0; }

/* ---------- Navigacija ---------- */
.site-nav { background: var(--surface); border-bottom: 1px solid var(--line); min-height: var(--nav-h); }
.site-nav .nav-link { font-weight: 500; border-radius: .5rem; padding-inline: .75rem !important; }
.site-nav .nav-link.active { color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), .08); }
.brand-logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 1.05rem; }
.brand-text { letter-spacing: -.01em; }
.brand-tld { color: var(--brand-2); }
.brand-logo-lg { width: 60px; height: 60px; border-radius: 18px; font-size: 1.8rem; }
.nav-icon-btn { color: var(--bs-body-color); font-size: 1.15rem; }
.site-footer { background: var(--surface); border-top: 1px solid var(--line); }
.site-footer a { text-decoration: none; }

/* ---------- Hero ---------- */
.hero { background: radial-gradient(1200px 400px at 10% -10%, #8f80ff 0, transparent 60%),
        linear-gradient(135deg, #2f2391 0%, #4c3bcf 50%, #a03fb0 100%); color: #fff; }
.hero-badge { background: rgba(255,255,255,.15); font-weight: 500; padding: .5rem .9rem; }
.text-gradient { background: linear-gradient(90deg, #ffd43b, #ff8787); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .hero-form { max-width: 520px; }
.hero .hero-form .form-control { border: 0; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #51cf66; margin-right: 4px;
    box-shadow: 0 0 0 0 rgba(81,207,102,.7); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(81,207,102,0); } 100% { box-shadow: 0 0 0 0 rgba(81,207,102,0); } }
.hero-mock { background: rgba(255,255,255,.95); color: #212529; border-radius: 20px; padding: 1.25rem; transform: rotate(-1.5deg); }
.mock-msg { display: flex; gap: .7rem; margin-bottom: .9rem; }
.mock-msg p { margin: 0; background: #f1f3f9; padding: .45rem .75rem; border-radius: 4px 14px 14px 14px; display: inline-block; }
.mock-msg b { font-size: .8rem; display: block; margin-bottom: 2px; }
.mock-msg .mock-reply { display: block; width: fit-content; background: transparent; border-left: 3px solid #7048e8; border-radius: 0; font-size: .75rem; color: #666; padding: 0 .5rem; margin-bottom: 4px; }
.mock-av { flex: 0 0 34px; height: 34px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; }
.mock-typing { font-size: .8rem; color: #888; }
.mock-typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #aaa; margin-right: 2px; animation: blink 1.2s infinite; }
.mock-typing span:nth-child(2) { animation-delay: .2s; } .mock-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3 } 40% { opacity: 1 } }

/* ---------- Kortelės / turinys ---------- */
.room-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: transform .15s, box-shadow .15s; color: inherit; }
.room-card:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1.25rem rgba(0,0,0,.08); }
.room-icon { flex: 0 0 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
    color: #fff; background: var(--c); }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; }
.feature i { font-size: 1.4rem; color: var(--bs-primary); display: inline-block; margin-bottom: .4rem; }
.feature h6 { margin-bottom: .3rem; }
.content-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; }
@media (min-width: 768px) { .content-card { padding: 2.25rem; } }
.rules-list li { margin-bottom: .6rem; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 1rem .5rem; }
.stat-v { font-size: 1.6rem; font-weight: 800; color: var(--bs-primary); }
.stat-l { font-size: .8rem; color: var(--muted); }

/* ---------- 300x250 reklama ---------- */
.ad-slot { width: 300px; max-width: 100%; text-align: center; }
.ad-label { display: block; font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.ad-300x250 { width: 300px; height: 250px; max-width: 100%; overflow: hidden; margin: 0 auto; border-radius: 8px; }
.ad-placeholder { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    border: 2px dashed rgba(var(--bs-primary-rgb), .35); border-radius: 8px; color: var(--muted);
    background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 10px, var(--surface-2) 10px, var(--surface-2) 20px); }

/* ============================================================
   POKALBIAI
   ============================================================ */
body.page-chat { height: 100vh; height: 100dvh; overflow: hidden; }
body.page-chat .site-nav { position: relative; }
@media (max-width: 991.98px) { body.page-chat .site-nav { display: none; } } /* telefone – daugiau vietos pokalbiui */
.chat-app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.login-view { flex: 1; overflow-y: auto; }
.login-card { border-radius: 20px; }

.chat-shell { flex: 1 1 auto; min-height: 0; display: flex; background: var(--surface); }
.chat-side, .chat-users { background: var(--surface-2); }
.side-inner { display: flex; flex-direction: column; height: 100%; overflow-y: auto; padding: .75rem 0; }
@media (min-width: 992px) {
    .chat-side { width: 270px; flex: 0 0 270px; border-right: 1px solid var(--line); }
    .chat-side .offcanvas-header { display: none; }
}
@media (min-width: 1200px) {
    .chat-users { width: 300px; flex: 0 0 316px; border-left: 1px solid var(--line); }
    .chat-users .offcanvas-header { display: none; }
}
.chat-side.offcanvas-lg, .chat-users.offcanvas-xl { --bs-offcanvas-width: 300px; }
@media (max-width: 991.98px) { .chat-side .side-inner { height: auto; flex: 1; } }

.me-card { display: flex; gap: .75rem; align-items: center; padding: .5rem 1rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: .5rem; }
.status-btn { color: var(--muted); font-size: .8rem; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #adb5bd; }
.status-dot.online { background: #40c057; }
.status-dot.away { background: #fab005; }

.side-section { margin-bottom: .75rem; }
.side-title { display: flex; justify-content: space-between; align-items: center; padding: .35rem 1rem; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }
.side-list { list-style: none; margin: 0; padding: 0 .5rem; }
.side-list li a, .side-list li > .member { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 10px;
    color: var(--bs-body-color); text-decoration: none; cursor: pointer; position: relative; min-height: 40px; }
.side-list li a:hover, .side-list li > .member:hover { background: rgba(var(--bs-primary-rgb), .07); }
.side-list li a.active { background: rgba(var(--bs-primary-rgb), .14); color: var(--bs-primary); font-weight: 600; }
.side-list .hash { width: 26px; text-align: center; color: var(--muted); font-weight: 700; }
.side-list .unread { margin-left: auto; }
.side-list .x-close { margin-left: auto; opacity: 0; font-size: .8rem; color: var(--muted); padding: 0 .2rem; }
.side-list li a:hover .x-close { opacity: 1; }
.side-list .unread + .x-close { margin-left: .25rem; }
@media (hover: none) { .side-list .x-close { opacity: .6; } }
.side-footer { display: flex; align-items: center; gap: .35rem; padding: .75rem 1rem 0; border-top: 1px solid var(--line); margin-top: auto; }
.conn-state.bad { color: #fa5252; }

.avatar { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff;
    font-weight: 700; font-size: .9rem; position: relative; text-transform: uppercase; user-select: none; }
.avatar.sm { width: 26px; height: 26px; font-size: .72rem; }
.avatar .status-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border: 2px solid var(--surface-2); }
.member .nick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .me-tag { font-size: .7rem; color: var(--muted); }
.member .st-text { font-size: .72rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Centrinis stulpelis ---------- */
.chat-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; position: relative; }
.chat-header { display: flex; align-items: center; gap: .35rem; padding: .5rem .75rem; border-bottom: 1px solid var(--line); min-height: 58px;
    padding-top: max(.5rem, env(safe-area-inset-top)); }
.chat-title { font-weight: 700; font-size: 1.05rem; }
.chat-topic { font-size: .78rem; color: var(--muted); }
.btn-icon { --bs-btn-padding-x: .5rem; --bs-btn-padding-y: .3rem; font-size: 1.2rem; color: var(--bs-body-color); border: 0; line-height: 1; }
.btn-icon:hover { background: rgba(var(--bs-primary-rgb), .08); }
.members-count { position: absolute; top: -2px; right: -4px; font-size: .6rem; }
.badge-dot { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #fa5252; }
.search-bar { display: flex; align-items: center; gap: .5rem; padding: .4rem .75rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }

.messages { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: .75rem 0 .5rem; overscroll-behavior: contain; scroll-behavior: auto; }
.load-older { text-align: center; padding: .25rem 0 .75rem; }
.new-below { position: absolute; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 5; box-shadow: 0 4px 12px rgba(0,0,0,.2); }

.msg { display: flex; gap: .7rem; padding: .15rem 1rem; position: relative; }
.msg:hover { background: rgba(var(--bs-primary-rgb), .035); }
.msg.first { margin-top: .65rem; }
.msg .avatar-col { width: 36px; flex: 0 0 36px; }
.msg .avatar { cursor: pointer; width: 36px; height: 36px; }
.msg .content { min-width: 0; flex: 1; }
.msg .meta { display: flex; align-items: baseline; gap: .5rem; line-height: 1.2; margin-bottom: 1px; }
.msg .meta .nick { font-weight: 700; cursor: pointer; font-size: .92rem; }
.msg .meta .time { font-size: .7rem; color: var(--muted); }
.msg .hover-time { position: absolute; left: 1rem; width: 36px; text-align: center; font-size: .62rem; color: var(--muted); top: .45rem; opacity: 0; }
.msg:hover .hover-time { opacity: 1; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.45; }
.msg .body code { background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; font-size: .85em; color: #d6336c; }
.msg .body a { word-break: break-all; }
.msg .body .mention { background: rgba(var(--bs-primary-rgb), .15); color: var(--bs-primary); border-radius: 4px; padding: 0 2px; font-weight: 600; }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 3px 0 0 #fab005; }
.msg.mine .content .body { }
.msg .edited { font-size: .68rem; color: var(--muted); margin-left: .3rem; }
.msg.deleted .body { color: var(--muted); font-style: italic; }
.msg .reply-ref { font-size: .78rem; color: var(--muted); border-left: 3px solid rgba(var(--bs-primary-rgb), .5); padding: 0 .5rem; margin: 2px 0 3px;
    cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.msg .reply-ref b { color: var(--bs-body-color); }
.msg.flash { animation: flash 1.5s; }
@keyframes flash { 0%, 40% { background: rgba(var(--bs-primary-rgb), .2); } 100% { background: transparent; } }
.msg .actions { position: absolute; right: .75rem; top: -14px; display: none; background: var(--surface); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); z-index: 3; }
.msg:hover .actions, .msg.show-actions .actions { display: flex; }
.msg .actions button { border: 0; background: none; padding: .25rem .5rem; color: var(--muted); font-size: .9rem; }
.msg .actions button:hover { color: var(--bs-primary); }
.msg.me-action .body { font-style: italic; }
.msg-img { display: block; max-width: min(320px, 100%); max-height: 240px; border-radius: 10px; margin-top: .35rem; border: 1px solid var(--line); }

.sys { text-align: center; font-size: .78rem; color: var(--muted); padding: .2rem 1rem; }
.sys i { margin-right: .25rem; }
.sys.system-msg { color: var(--bs-body-color); background: rgba(250, 176, 5, .14); margin: .5rem 1rem; border-radius: 10px; padding: .5rem .75rem; font-size: .88rem; }
.day-sep { display: flex; align-items: center; gap: .75rem; margin: 1rem 1rem .25rem; font-size: .72rem; color: var(--muted); font-weight: 600; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.empty-state { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }

.typing { min-height: 22px; font-size: .75rem; color: var(--muted); padding: 0 1rem; }
.typing .dots span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 2px; animation: blink 1.2s infinite; }
.typing .dots span:nth-child(2) { animation-delay: .2s; } .typing .dots span:nth-child(3) { animation-delay: .4s; }

.composer { padding: .25rem .75rem .75rem; padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
.composer-row { display: flex; align-items: flex-end; gap: .35rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: .3rem; }
.composer-row:focus-within { border-color: rgba(var(--bs-primary-rgb), .5); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .12); }
#msg-input { border: 0; background: transparent; resize: none; box-shadow: none; max-height: 160px; padding: .45rem .25rem; font-size: 16px; /* iOS be zoom */ line-height: 1.35; }
.btn-send { border-radius: 10px; padding: .45rem .8rem; }
.reply-box { display: flex; align-items: center; gap: .5rem; font-size: .82rem; padding: .35rem .6rem; margin-bottom: .35rem;
    background: rgba(var(--bs-primary-rgb), .08); border-left: 3px solid var(--bs-primary); border-radius: 6px; }
.reply-box #reply-text { color: var(--muted); }
.emoji-panel { width: 300px; max-height: 260px; overflow-y: auto; }
.emoji-panel .emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-panel button { border: 0; background: none; font-size: 1.35rem; padding: .15rem; border-radius: 6px; line-height: 1.2; }
.emoji-panel button:hover { background: rgba(var(--bs-primary-rgb), .1); }
.emoji-panel .emoji-cat { font-size: .68rem; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: .35rem .2rem .15rem; }

.chat-users .ad-slot { margin-bottom: .5rem; }
#all-rooms .list-group-item { display: flex; align-items: center; gap: .6rem; }

@media (max-width: 575.98px) {
    .msg { padding: .15rem .6rem; gap: .55rem; }
    .msg .avatar-col { width: 32px; flex-basis: 32px; }
    .msg .avatar { width: 32px; height: 32px; }
    .msg .hover-time { display: none; }
    .msg .actions { right: .4rem; }
    .chat-header { padding-inline: .4rem; }
    .composer { padding-inline: .5rem; }
}
