/* =====================================================
   PD Managment Panel — Theme
   Accent: #507dde  |  Base: deep tactical navy
   ===================================================== */

@font-face {
    font-family: 'PDFont';
    src: url('../fonts/FONT.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root{
    --accent: #507dde;
    --accent-soft: rgba(80,125,222,.18);
    --accent-border: rgba(80,125,222,.32);
    --accent-glow: rgba(80,125,222,.45);
    --bg-0: #070a14;
    --bg-1: #0c1224;
    --bg-2: #11192f;
    --panel: rgba(16,22,40,.72);
    --panel-solid: #121a30;
    --text: #e7ecfb;
    --text-dim: #93a3c8;
    --text-faint: #5f6f93;
    --line: rgba(120,150,230,.14);
    --danger: #ff6b6b;
    --success: #4ddb9b;
    --radius: 16px;
    --font: 'PDFont','Vazirmatn','Vazir',Tahoma,Arial,sans-serif;
}

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

html,body{ height:100%; }

body{
    font-family: var(--font);
    color: var(--text);
    direction: rtl;
    background: radial-gradient(circle at 18% 14%, rgba(80,125,222,.10) 0%, transparent 45%),
                radial-gradient(circle at 85% 80%, rgba(80,125,222,.07) 0%, transparent 50%),
                linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 55%, var(--bg-2) 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* faint tactical grid overlay */
body::before{
    content:'';
    position:fixed; inset:0; pointer-events:none; z-index:0;
    background-image:
        linear-gradient(rgba(80,125,222,.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(80,125,222,.045) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: radial-gradient(circle at 50% 30%, rgba(0,0,0,.6), transparent 75%);
}

a{ color: var(--accent); }

::-webkit-scrollbar{ width:6px; height:6px; }
::-webkit-scrollbar-track{ background: rgba(255,255,255,.03); }
::-webkit-scrollbar-thumb{ background: linear-gradient(180deg,#507dde,#3a5fc0); border-radius:4px; }

/* =====================================================
   AUTH / LOGIN PAGE
   ===================================================== */
.auth-body{
    display:flex; align-items:center; justify-content:center;
    min-height:100vh; padding:20px; position:relative; z-index:1;
}

.auth-card{
    width:100%; max-width:400px;
    background: var(--panel);
    border:1px solid var(--accent-border);
    border-radius: 22px;
    padding: 38px 32px;
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    box-shadow: 0 25px 80px rgba(0,0,0,.55), 0 0 60px rgba(80,125,222,.08) inset;
    position: relative;
    overflow:hidden;
}

.auth-card::before{
    content:'';
    position:absolute; top:-60%; right:-40%; width:220px; height:220px;
    background: radial-gradient(circle, rgba(80,125,222,.35), transparent 70%);
    filter: blur(10px);
}

.auth-badge{
    width:74px; height:74px; margin:0 auto 18px;
    position:relative; display:flex; align-items:center; justify-content:center;
}

.auth-badge svg{
    width:100%; height:100%;
    filter: drop-shadow(0 0 18px var(--accent-glow));
}

.auth-title{
    text-align:center; font-size:22px; font-weight:700;
    letter-spacing:1px; margin-bottom:4px;
    background: linear-gradient(135deg,#a9c0ff,#507dde);
    -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent;
}

.auth-subtitle{
    text-align:center; color:var(--text-faint); font-size:12px;
    letter-spacing:3px; text-transform:uppercase; margin-bottom:28px;
}

.auth-field{ margin-bottom:16px; }

.auth-field label{
    display:block; font-size:12px; color:var(--text-dim); margin-bottom:7px;
    letter-spacing:.5px;
}

.auth-field input{
    width:100%; padding:13px 16px; border-radius:12px;
    border:1px solid var(--line); background:rgba(255,255,255,.04);
    color:var(--text); font-family:var(--font); font-size:14px;
    transition: all .25s ease;
}

.auth-field input:focus{
    outline:none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: rgba(255,255,255,.06);
}

.auth-submit{
    width:100%; margin-top:8px; padding:14px; border:none; border-radius:12px;
    background: linear-gradient(135deg,#507dde,#3a5fc0);
    color:#fff; font-size:15px; font-weight:700; font-family:var(--font);
    cursor:pointer; letter-spacing:1px; transition: all .25s ease;
    box-shadow: 0 8px 24px rgba(80,125,222,.35);
}

.auth-submit:hover{ transform: translateY(-2px); box-shadow: 0 12px 30px rgba(80,125,222,.5); }
.auth-submit:active{ transform: translateY(0); }

.auth-error{
    background: rgba(255,107,107,.08); border:1px solid rgba(255,107,107,.3);
    color:var(--danger); font-size:13px; padding:10px 14px; border-radius:10px;
    margin-bottom:16px; text-align:center;
}

.auth-footer{
    text-align:center; margin-top:22px; font-size:11px; color:var(--text-faint);
    letter-spacing:2px; text-transform:uppercase;
}

/* =====================================================
   APP SHELL
   ===================================================== */
.app{
    display:flex; height:100vh; height:100dvh; position:relative; z-index:1;
    overflow:hidden;
}

/* ---------- Sidebar (right side in RTL) ---------- */
.sidebar{
    width:300px; min-width:300px; height:100%;
    background: var(--panel);
    border-left:1px solid var(--line);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    display:flex; flex-direction:column;
}

.sidebar-group{
    display:flex; align-items:center; gap:12px; padding:18px 16px;
    border-bottom:1px solid var(--line); cursor:pointer;
    transition: background .2s ease;
}
.sidebar-group:hover{ background: rgba(80,125,222,.06); }

.sidebar-group .group-avatar{
    width:46px; height:46px; border-radius:50%; overflow:hidden; flex-shrink:0;
    background: linear-gradient(135deg,#3a5fc0,#507dde);
    display:flex; align-items:center; justify-content:center;
    box-shadow: 0 0 0 2px rgba(80,125,222,.25);
}
.sidebar-group .group-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.sidebar-group .group-avatar svg{ width:24px; height:24px; fill:#fff; opacity:.9; }

.sidebar-group .group-info{ flex:1; min-width:0; }
.sidebar-group .group-name{ font-weight:700; font-size:15px; color:var(--text); }
.sidebar-group .group-sub{ font-size:11px; color:var(--text-faint); margin-top:2px; letter-spacing:1px; }

.sidebar-user{
    display:flex; align-items:center; gap:10px; padding:14px 16px;
    border-bottom:1px solid var(--line);
}
.sidebar-user .me-avatar{
    width:34px; height:34px; border-radius:50%; overflow:hidden; flex-shrink:0;
    background: linear-gradient(135deg,#3a5fc0,#507dde);
    display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; color:#fff;
}
.sidebar-user .me-avatar img{ width:100%; height:100%; object-fit:cover; }
.sidebar-user .me-info{ flex:1; min-width:0; }
.sidebar-user .me-name{ font-size:13px; font-weight:700; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-user .me-rank{ font-size:10px; color:var(--accent); letter-spacing:1px; margin-top:1px; }
.sidebar-user .icon-btn{ flex-shrink:0; }

/* topic list */
.topic-list{
    flex:1; overflow-y:auto; padding:8px;
}

.topic-item{
    display:flex; align-items:center; gap:12px; padding:12px 12px;
    border-radius:14px; cursor:pointer; margin-bottom:4px;
    transition: all .2s ease; position:relative; border:1px solid transparent;
}
.topic-item:hover{ background: rgba(80,125,222,.08); }
.topic-item.active{
    background: linear-gradient(135deg, rgba(80,125,222,.22), rgba(80,125,222,.08));
    border-color: var(--accent-border);
}

.topic-icon{
    width:40px; height:40px; border-radius:12px; flex-shrink:0;
    display:flex; align-items:center; justify-content:center;
    background: rgba(80,125,222,.12); border:1px solid var(--accent-border);
}
.topic-icon svg{ width:20px; height:20px; fill:var(--accent); }

.topic-meta{ flex:1; min-width:0; }
.topic-title{ font-size:14px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:flex; align-items:center; gap:6px;}
.topic-preview{ font-size:11px; color:var(--text-faint); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }

.topic-lock{ width:13px; height:13px; fill:var(--text-faint); flex-shrink:0; }

.topic-badge{
    min-width:20px; height:20px; padding:0 6px; border-radius:10px;
    background: var(--accent); color:#fff; font-size:11px; font-weight:700;
    display:flex; align-items:center; justify-content:center; flex-shrink:0;
    box-shadow: 0 0 12px var(--accent-glow);
}
.topic-badge.mention{ background: linear-gradient(135deg,#ff8a5c,#ff6b35); }

/* ---------- Main chat area ---------- */
.main{
    flex:1; display:flex; flex-direction:column; min-width:0; position:relative;
    background: rgba(255,255,255,.015);
}

.main-header{
    display:flex; align-items:center; gap:12px; padding:14px 20px;
    border-bottom:1px solid var(--line);
    background: rgba(10,14,26,.45); backdrop-filter: blur(14px);
    position:relative; z-index:5;
}

.main-header .back-btn{ display:none; }

.main-header .header-titles{ flex:1; min-width:0; }
.main-header .header-title{ font-size:16px; font-weight:700; color:var(--text); display:flex; align-items:center; gap:8px;}
.main-header .header-sub{ font-size:11px; color:var(--text-faint); margin-top:2px; letter-spacing:1px; }

.lock-pill{
    display:inline-flex; align-items:center; gap:4px; font-size:10px;
    padding:2px 8px; border-radius:8px; background: rgba(255,107,107,.12);
    color:var(--danger); border:1px solid rgba(255,107,107,.25);
}
.lock-pill svg{ width:10px; height:10px; fill:currentColor; }

.icon-btn{
    width:38px; height:38px; border-radius:50%; border:1px solid var(--line);
    background: rgba(255,255,255,.03); display:flex; align-items:center; justify-content:center;
    cursor:pointer; transition: all .2s ease; flex-shrink:0;
}
.icon-btn:hover{ background: var(--accent-soft); border-color: var(--accent-border); }
.icon-btn svg{ width:18px; height:18px; fill: var(--text-dim); transition: fill .2s ease; }
.icon-btn:hover svg{ fill: var(--accent); }

/* messages list */
.chat-room{ flex:1; overflow-y:auto; padding:18px 16px 8px; }
#message-list{ list-style:none; display:flex; flex-direction:column; gap:2px; }

#message-list li{
    display:flex; max-width:78%; clear:both; word-break:break-word;
    margin-bottom:10px; align-items:flex-end; gap:8px;
}
#message-list li.own{ align-self:flex-start; flex-direction:row-reverse; }
#message-list li.other{ align-self:flex-end; }

.msg-avatar{
    width:32px; height:32px; border-radius:50%; flex-shrink:0; overflow:hidden;
    background: linear-gradient(135deg,#3a5fc0,#507dde);
    display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; color:#fff;
    box-shadow: 0 0 0 2px rgba(80,125,222,.18);
}
.msg-avatar img{ width:100%; height:100%; object-fit:cover; }
.msg-avatar.spacer{ visibility:hidden; }

.message-bubble{
    position:relative; padding:10px 14px; border-radius:18px;
    box-shadow:0 4px 16px rgba(0,0,0,.25);
    backdrop-filter: blur(8px); animation: msgIn .25s ease-out;
    min-width:64px;
}
@keyframes msgIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:translateY(0);} }

li.own .message-bubble{
    background: linear-gradient(135deg,#507dde,#3f63c4);
    color:#fff; border-bottom-left-radius:6px;
    border:1px solid rgba(150,180,255,.25);
}
li.other .message-bubble{
    background: linear-gradient(135deg,#161e34,#1c2740);
    color:#dde4f7; border-bottom-right-radius:6px;
    border:1px solid var(--line);
}

.msg-header{ display:flex; align-items:center; gap:6px; margin-bottom:4px; font-size:11px; flex-wrap:wrap; }
li.own .msg-header{ color: rgba(255,255,255,.85); justify-content:flex-end; }
li.other .msg-header{ color: var(--text-dim); }

.msg-name{ font-weight:700; font-family: var(--font); }
.rank-tag{
    font-size:9px; padding:1px 6px; border-radius:6px; letter-spacing:.5px;
    border:1px solid currentColor; opacity:.85; font-weight:700;
}
.rank-tag.arteshbod{ color:#ffd166; border-color:#ffd166; }
.rank-tag.operator{ color:#7ef0c0; border-color:#7ef0c0; }
.msg-time{ font-size:9.5px; opacity:.65; }
.msg-time .edited{ opacity:.7; font-style:italic; margin-right:3px; }

.msg-reply-btn{ cursor:pointer; opacity:.6; transition: all .2s ease; display:flex; }
.msg-reply-btn:hover{ opacity:1; transform: scale(1.15); }
.msg-reply-btn svg{ width:13px; height:13px; fill:currentColor; }

.msg-content{ font-size:14.5px; line-height:1.7; user-select:text; }
.msg-content .mention{ color:#ffd166; font-weight:700; }
li.other .msg-content .mention{ color:#ffd166; }
.msg-content .msg-link{ text-decoration:underline; word-break:break-all; }
li.own .msg-content .msg-link{ color:#fff; }
li.other .msg-content .msg-link{ color:#9db4ff; }

/* reply preview inside a message */
.msg-reply-quote{
    border-right:3px solid var(--accent); background:rgba(255,255,255,.06);
    border-radius:8px; padding:6px 10px; margin-bottom:6px; cursor:pointer;
}
li.own .msg-reply-quote{ border-right-color: rgba(255,255,255,.7); }
.msg-reply-quote .rq-name{ font-size:11px; font-weight:700; color: var(--accent); }
li.own .msg-reply-quote .rq-name{ color:#fff; }
.msg-reply-quote .rq-text{ font-size:11.5px; opacity:.75; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* system messages */
.system-li{ align-self:center !important; max-width:90% !important; }
.system-msg{
    font-size:11px; color:var(--text-faint); background:rgba(255,255,255,.03);
    border:1px solid var(--line); border-radius:12px; padding:5px 14px;
}

/* =====================================================
   ATTACHMENTS (image / video / file / archive)
   ===================================================== */
.msg-image{
    max-width:260px; max-height:260px; border-radius:14px; display:block;
    margin-bottom:6px; cursor:pointer; box-shadow:0 4px 14px rgba(0,0,0,.3);
    object-fit:cover; transition: transform .25s ease;
}
.msg-image:hover{ transform: scale(1.02); }

.msg-video-wrap{
    position:relative; max-width:280px; border-radius:14px; overflow:hidden;
    margin-bottom:6px; cursor:pointer; background:#000;
}
.msg-video-wrap video{ display:block; width:100%; max-height:280px; }
.msg-video-wrap .play-overlay{
    position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
    background: rgba(0,0,0,.25);
}
.msg-video-wrap .play-overlay svg{ width:46px; height:46px; fill:#fff; opacity:.9; filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); }

/* generic downloadable file card */
.msg-file{
    display:flex; align-items:center; gap:12px; padding:10px 12px;
    background: rgba(0,0,0,.18); border:1px solid rgba(255,255,255,.08);
    border-radius:14px; margin-bottom:6px; cursor:pointer; min-width:210px;
    transition: background .2s ease;
}
.msg-file:hover{ background: rgba(0,0,0,.28); }

.msg-file .file-info{ flex:1; min-width:0; }
.msg-file .file-name{ font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.msg-file .file-size{ font-size:11px; opacity:.7; margin-top:2px; }
.msg-file .file-size .dl-progress-text{ display:none; }
.msg-file.downloading .file-size .static-text{ display:none; }
.msg-file.downloading .file-size .dl-progress-text{ display:inline; }

/* circular progress (used for upload preview & file download) */
.progress-circle{
    width:42px; height:42px; flex-shrink:0; position:relative;
}
.progress-circle svg{ width:100%; height:100%; transform: rotate(-90deg); }
.progress-circle .pc-track{ fill:none; stroke: rgba(255,255,255,.15); stroke-width:3; }
.progress-circle .pc-bar{
    fill:none; stroke: var(--accent); stroke-width:3; stroke-linecap:round;
    stroke-dasharray: 113; stroke-dashoffset:113; transition: stroke-dashoffset .15s linear;
}
li.own .progress-circle .pc-bar{ stroke:#fff; }
li.own .progress-circle .pc-track{ stroke: rgba(255,255,255,.25); }

.progress-circle .pc-icon{
    position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
}
.progress-circle .pc-icon svg{ width:18px; height:18px; fill:currentColor; transform:none; }
.progress-circle .pc-icon.archive svg{ fill:#ffd166; }
.progress-circle .pc-icon.file svg{ fill: var(--accent); }
li.own .progress-circle .pc-icon.file svg{ fill:#fff; }

/* =====================================================
   INPUT BOX
   ===================================================== */
.input-box{
    border-top:1px solid var(--line); padding:12px 16px;
    background: rgba(10,14,26,.5); backdrop-filter: blur(14px);
    position:relative; z-index:5;
}

#reply-preview, #upload-preview{
    display:flex; align-items:center; gap:10px; padding:8px 12px;
    background: var(--accent-soft); border:1px solid var(--accent-border);
    border-radius:12px; margin-bottom:8px;
}
#reply-preview .rp-close, #upload-preview .up-close{
    width:22px; height:22px; border-radius:50%; flex-shrink:0;
    display:flex; align-items:center; justify-content:center; cursor:pointer;
    background: rgba(255,255,255,.08); color:var(--text-dim); font-size:14px;
}
#reply-preview .rp-close:hover, #upload-preview .up-close:hover{ background:rgba(255,80,80,.2); color:var(--danger); }
#reply-preview .rp-body, #upload-preview .up-body{ flex:1; min-width:0; }
#reply-preview .rp-name{ font-size:12px; font-weight:700; color:var(--accent); }
#reply-preview .rp-text{ font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#upload-preview .up-name{ font-size:12.5px; font-weight:600; }
#upload-preview .up-size{ font-size:11px; color:var(--text-dim); }
#upload-preview img.up-thumb{ width:40px; height:40px; border-radius:8px; object-fit:cover; flex-shrink:0; }

.message-box{ display:flex; align-items:flex-end; gap:8px; position:relative; }

#message-input{
    flex:1; padding:13px 16px; font-size:15px; border-radius:22px;
    border:1px solid var(--line); background: rgba(255,255,255,.04);
    color:var(--text); font-family:var(--font); resize:none;
    min-height:46px; max-height:140px; overflow-y:auto; transition: all .2s ease;
}
#message-input:focus{
    outline:none; border-color: var(--accent); background: rgba(255,255,255,.06);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
#message-input::placeholder{ color: var(--text-faint); }

.round-btn{
    width:46px; height:46px; min-width:46px; border-radius:50%; border:none;
    display:flex; align-items:center; justify-content:center; cursor:pointer;
    transition: all .2s ease; flex-shrink:0;
}
.round-btn svg{ width:20px; height:20px; }
#send-btn{
    background: linear-gradient(135deg,#507dde,#3a5fc0); box-shadow:0 6px 20px rgba(80,125,222,.35);
}
#send-btn svg{ fill:#fff; }
#send-btn:hover{ transform: translateY(-2px); box-shadow:0 10px 26px rgba(80,125,222,.5); }
#attach-btn{
    background: rgba(255,255,255,.05); border:1px solid var(--line);
}
#attach-btn svg{ fill: var(--text-dim); }
#attach-btn:hover{ border-color: var(--accent-border); }
#attach-btn:hover svg{ fill: var(--accent); }

/* attach menu */
.attach-menu{
    position:absolute; bottom:58px; right:0; background: var(--panel-solid);
    border:1px solid var(--accent-border); border-radius:14px; padding:8px;
    display:none; flex-direction:column; min-width:170px; box-shadow:0 10px 30px rgba(0,0,0,.5);
    backdrop-filter: blur(16px); z-index:50;
}
.attach-menu.show{ display:flex; }
.attach-menu .am-item{
    display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:10px;
    cursor:pointer; font-size:13px; color:var(--text); transition: background .2s ease;
}
.attach-menu .am-item:hover{ background: var(--accent-soft); }
.attach-menu .am-item svg{ width:18px; height:18px; fill: var(--accent); }

/* locked banner */
.locked-banner{
    display:flex; align-items:center; justify-content:center; gap:8px;
    padding:14px; color:var(--text-faint); font-size:13px; text-align:center;
}
.locked-banner svg{ width:16px; height:16px; fill:currentColor; }

/* =====================================================
   CONTEXT MENU
   ===================================================== */
.context-menu{
    position:fixed; background: var(--panel-solid); border:1px solid var(--accent-border);
    border-radius:14px; padding:6px; min-width:170px; z-index:1000;
    box-shadow: 0 12px 36px rgba(0,0,0,.55); backdrop-filter: blur(18px);
    display:none; animation: ctxIn .15s ease;
}
.context-menu.show{ display:block; }
@keyframes ctxIn{ from{opacity:0; transform:scale(.92);} to{opacity:1; transform:scale(1);} }

.context-menu .cm-item{
    display:flex; align-items:center; gap:10px; padding:10px 14px; border-radius:10px;
    cursor:pointer; font-size:13px; color:#dde4f7; transition: all .15s ease;
}
.context-menu .cm-item:hover{ background: var(--accent-soft); color:#fff; }
.context-menu .cm-item svg{ width:16px; height:16px; fill:currentColor; }
.context-menu .cm-item.danger{ color: var(--danger); }
.context-menu .cm-item.danger:hover{ background: rgba(255,107,107,.12); }
.context-menu .cm-divider{ height:1px; background: var(--line); margin:4px 6px; }

/* =====================================================
   MENTION AUTOCOMPLETE
   ===================================================== */
.mention-dropdown{
    position:absolute; bottom:100%; right:0; left:0; margin-bottom:8px;
    background: var(--panel-solid); border:1px solid var(--accent-border);
    border-radius:14px; padding:6px; max-height:180px; overflow-y:auto;
    display:none; box-shadow:0 -8px 24px rgba(0,0,0,.4); backdrop-filter: blur(16px);
}
.mention-dropdown.show{ display:block; }
.mention-dropdown .md-item{
    display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:10px;
    cursor:pointer; font-size:13px;
}
.mention-dropdown .md-item:hover, .mention-dropdown .md-item.active{ background: var(--accent-soft); }
.mention-dropdown .md-avatar{
    width:26px; height:26px; border-radius:50%; flex-shrink:0; overflow:hidden;
    background: linear-gradient(135deg,#3a5fc0,#507dde); display:flex; align-items:center; justify-content:center;
    font-size:11px; font-weight:700; color:#fff;
}
.mention-dropdown .md-avatar img{ width:100%; height:100%; object-fit:cover; }
.mention-dropdown .md-rank{ font-size:10px; color:var(--text-faint); }

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay{
    position:fixed; inset:0; background: rgba(5,8,16,.82); backdrop-filter: blur(8px);
    display:none; align-items:center; justify-content:center; z-index:2000; padding:20px;
}
.modal-overlay.show{ display:flex; animation: fadeIn .2s ease; }
@keyframes fadeIn{ from{opacity:0;} to{opacity:1;} }

/* image viewer */
.image-viewer img{ max-width:92vw; max-height:88vh; border-radius:10px; box-shadow:0 20px 60px rgba(0,0,0,.6); }
.image-viewer{ position:relative; display:flex; align-items:center; justify-content:center; }
.iv-close, .iv-download{
    position:absolute; width:46px; height:46px; border-radius:50%;
    background: rgba(20,26,42,.85); border:1px solid var(--accent-border);
    display:flex; align-items:center; justify-content:center; cursor:pointer;
    backdrop-filter: blur(10px); transition: all .2s ease;
}
.iv-close{ top:-58px; left:0; }
.iv-download{ bottom:16px; left:16px; }
.iv-close:hover, .iv-download:hover{ background: var(--accent); }
.iv-close svg, .iv-download svg{ width:20px; height:20px; fill:#fff; }

/* generic panel modal (group info, admin dialogs) */
.panel-modal{
    background: var(--panel-solid); border:1px solid var(--accent-border);
    border-radius:20px; width:100%; max-width:420px; max-height:86vh; overflow-y:auto;
    box-shadow: 0 25px 70px rgba(0,0,0,.6); animation: panelIn .25s ease;
}
@keyframes panelIn{ from{opacity:0; transform:translateY(16px) scale(.97);} to{opacity:1; transform:translateY(0) scale(1);} }

.panel-modal .pm-header{
    display:flex; align-items:center; gap:12px; padding:18px 20px;
    border-bottom:1px solid var(--line);
}
.panel-modal .pm-header .pm-title{ flex:1; font-size:16px; font-weight:700; }
.panel-modal .pm-close{
    width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center;
    cursor:pointer; background: rgba(255,255,255,.05); transition: all .2s ease;
}
.panel-modal .pm-close:hover{ background: rgba(255,80,80,.15); }
.panel-modal .pm-close svg{ width:16px; height:16px; fill: var(--text-dim); }
.panel-modal .pm-body{ padding:18px 20px; }

/* group info header (big avatar) */
.gi-avatar{
    width:90px; height:90px; border-radius:50%; margin:0 auto 14px; overflow:hidden;
    background: linear-gradient(135deg,#3a5fc0,#507dde); display:flex; align-items:center; justify-content:center;
    box-shadow: 0 0 0 4px rgba(80,125,222,.18);
}
.gi-avatar img{ width:100%; height:100%; object-fit:cover; }
.gi-avatar svg{ width:42px; height:42px; fill:#fff; }
.gi-name{ text-align:center; font-size:18px; font-weight:700; margin-bottom:4px; }
.gi-sub{ text-align:center; font-size:12px; color:var(--text-faint); margin-bottom:18px; letter-spacing:1px;}

.member-section-title{
    font-size:12px; color:var(--text-faint); letter-spacing:1px; margin:14px 0 8px;
    text-transform:uppercase;
}
.member-row{
    display:flex; align-items:center; gap:12px; padding:10px 8px; border-radius:12px;
    transition: background .2s ease;
}
.member-row:hover{ background: rgba(255,255,255,.03); }
.member-avatar{
    width:42px; height:42px; border-radius:50%; flex-shrink:0; overflow:hidden;
    background: linear-gradient(135deg,#3a5fc0,#507dde); display:flex; align-items:center; justify-content:center;
    font-size:15px; font-weight:700; color:#fff;
}
.member-avatar img{ width:100%; height:100%; object-fit:cover; }
.member-info{ flex:1; min-width:0; }
.member-name{ font-size:14px; font-weight:600; }
.member-rank{ font-size:11px; color:var(--text-faint); margin-top:2px; }

/* =====================================================
   GENERIC FORM ELEMENTS (used in panels/admin)
   ===================================================== */
.form-group{ margin-bottom:14px; }
.form-group label{ display:block; font-size:12px; color:var(--text-dim); margin-bottom:6px; }
.form-group input, .form-group select, .form-group textarea{
    width:100%; padding:11px 14px; border-radius:10px; border:1px solid var(--line);
    background: rgba(255,255,255,.04); color:var(--text); font-family:var(--font); font-size:13.5px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus{
    outline:none; border-color: var(--accent); box-shadow:0 0 0 3px var(--accent-soft);
}
.btn{
    display:inline-flex; align-items:center; justify-content:center; gap:6px;
    padding:11px 18px; border-radius:10px; border:none; cursor:pointer;
    font-family:var(--font); font-size:13.5px; font-weight:600; transition: all .2s ease;
}
.btn-primary{ background: linear-gradient(135deg,#507dde,#3a5fc0); color:#fff; box-shadow:0 6px 18px rgba(80,125,222,.3); }
.btn-primary:hover{ transform: translateY(-1px); box-shadow:0 10px 24px rgba(80,125,222,.4); }
.btn-ghost{ background: rgba(255,255,255,.05); color: var(--text); border:1px solid var(--line); }
.btn-ghost:hover{ border-color: var(--accent-border); }
.btn-danger{ background: rgba(255,107,107,.12); color: var(--danger); border:1px solid rgba(255,107,107,.3); }
.btn-danger:hover{ background: rgba(255,107,107,.2); }
.btn-block{ width:100%; }
.btn-sm{ padding:7px 12px; font-size:12px; }

.toast{
    position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px);
    background: var(--panel-solid); border:1px solid var(--accent-border); color:var(--text);
    padding:12px 22px; border-radius:14px; font-size:13px; z-index:3000;
    box-shadow:0 10px 30px rgba(0,0,0,.5); opacity:0; transition: all .3s ease; pointer-events:none;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

.empty-state{
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    height:100%; color:var(--text-faint); gap:10px; text-align:center; padding:30px;
}
.empty-state svg{ width:48px; height:48px; fill: var(--accent); opacity:.5; }

/* =====================================================
   RESPONSIVE (mobile)
   ===================================================== */
@media (max-width: 860px){
    .app{ position:relative; }
    .sidebar{
        position:absolute; inset:0; width:100%; min-width:0; z-index:20;
        transition: transform .28s ease;
    }
    .main{ position:absolute; inset:0; transform: translateX(100%); transition: transform .28s ease; z-index:10; }
    .app.chat-open .sidebar{ transform: translateX(100%); }
    .app.chat-open .main{ transform: translateX(0); }
    .main-header .back-btn{
        display:flex; width:38px; height:38px; border-radius:50%; border:1px solid var(--line);
        background: rgba(255,255,255,.03); align-items:center; justify-content:center; cursor:pointer; flex-shrink:0;
    }
    .main-header .back-btn svg{ width:18px; height:18px; fill: var(--text-dim); }
    #message-list li{ max-width:86%; }
    .panel-modal{ max-width:100%; }
}

@media (max-width: 480px){
    .auth-card{ padding:28px 22px; }
    .msg-image{ max-width:200px; max-height:200px; }
    .msg-video-wrap{ max-width:220px; }
}
