:root{
    --primary: #2f80ed;       
    --accent: #6c5ce7;        
    --bg-1: #f7f9fc;
    --card: #ffffff;
    --muted: #7b8794;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #17a2b8;
    --glass: rgba(255,255,255,0.6);
    --shadow: rgba(31,41,55,0.08);
    --sidebar-width: 360px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: 200ms cubic-bezier(.2,.9,.2,1);
    --max-container: 1200px;
    --touch-size: 48px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
    margin:0;
    font-family: 'IRANSans';
    background: linear-gradient(135deg,#e8f0ff 0%, #f6f8ff 45%, #fbfbfe 100%);
    color:#222;
    direction: rtl;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
    line-height:1.45;
    padding:20px;
}

@font-face {
    font-family: 'IRANSans';
    src: url('/static/fonts/IRANSans.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

.container{
    max-width:450px;
    width:100%;
    margin: 20px auto;
    background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(255,255,255,0.95));
    border-radius: calc(var(--radius-lg));
    box-shadow: 0 12px 30px var(--shadow);
    overflow:hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid rgba(34,34,34,0.04);
}

.container:focus-within{ transform: translateY(-4px); box-shadow: 0 18px 40px rgba(31,41,55,0.12); }

.header{
    background: linear-gradient(90deg, var(--primary), var(--accent));
    color: white;
    padding: 28px 20px;
    text-align:center;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:12px;
    flex-direction: column;
}

.logo {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    font-size: 28px;
    flex-shrink: 0;
    overflow: hidden;
}

.logo img {
    width: 64px;
    height: auto;
    margin-bottom: 0;
}

.school-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    margin-top: 10px;
    text-align: center;
}

.header > div:last-child{ font-size:0.9rem; opacity:0.95 }

.form-container{
    padding:24px;
    background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.6) 100%);
}

.tabs{
    font-family: 'IRANSans';
    display:flex;
    gap:8px;
    margin-bottom:18px;
    background: rgba(31,41,55,0.03);
    padding:6px;
    border-radius:999px;
    display: flex;
    justify-content: center;
}

.tab{
    font-family: 'IRANSans';
    flex:1;
    min-width:0;
    padding:10px 12px;
    text-align:center;
    cursor:pointer;
    border-radius:999px;
    font-weight:600;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    color:var(--muted);
    transition: all var(--transition);
    user-select:none;
}

.tab i{ font-size:16px; width:18px; display:inline-block; text-align:center; }

.tab.active{
    font-family: 'IRANSans';
    background: linear-gradient(90deg,var(--primary),var(--accent));
    color:white;
    box-shadow: 0 8px 18px rgba(44,62,80,0.08);
}

.form-section{ display:none }
.form-section.active{ display:block; animation: fadeIn var(--transition) ease both; }

.form-group{ margin-bottom:16px }

label{
    font-family: 'IRANSans';
    display:block;
    margin-bottom:8px;
    font-weight:600;
    color:#334155;
    font-size:0.95rem;
}

input[type="text"], input[type="password"], select, textarea{
    width:100%;
    padding:12px 14px;
    border-radius:var(--radius-md);
    border:1px solid rgba(15,23,42,0.06);
    background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(250,250,250,0.9));
    font-size:15px;
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
    color:#0f172a;
    -webkit-appearance:none;
}

input::placeholder{ color: #94a3b8; font-size:14px }

input:focus, select:focus, textarea:focus{
    outline:none;
    border-color: rgba(47,128,237,0.95);
    box-shadow: 0 6px 18px rgba(47,128,237,0.12);
    transform: translateY(-1px);
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    width: 100%;
    padding-left: 40px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    color: #555;
    transition: 0.2s;
}

.password-toggle:hover {
    color: #000;
}

.guest-warning-box {
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 0.82rem;
    line-height: 1.5;
    background: #fff7d1;
    border: 1px solid #ffe066;
    border-radius: 8px;
    color: #b85d00;
}

@keyframes yellowBoxPulse {
    0% {
        box-shadow: 0 0 0px rgba(255, 215, 0, 0);
    }
    50% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.9);
    }
    100% {
        box-shadow: 0 0 0px rgba(255, 215, 0, 0);
    }
}

.glow-box {
    animation: yellowBoxPulse 1.8s infinite ease-in-out;
}

.btn {
    font-family: 'IRANSans';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    transition: transform .2s ease, box-shadow .2s ease;
    box-shadow: 0 6px 18px rgba(15,23,42,0.06);
    user-select: none;
}

.btn i {
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.btn:hover {
    transform: translateY(-3px);
}

.btn:active {
    transform: translateY(1px);
}

.btn {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    color: white;
}

.btn.btn-success {
    background: linear-gradient(90deg, #34d399, #10b981);
    color: white;
}

.btn.btn-warning {
    background: linear-gradient(90deg, #ffd166, #f39c12);
    color: #111;
}

.btn.btn-danger {
    background: linear-gradient(90deg, #ff7b7b, #e74c3c);
    color: white;
}

.btn.btn-info {
    background: linear-gradient(90deg, #60a5fa, #0ea5e9);
    color: white;
}

input, textarea, select, button {
    font-family: 'IRANSans', sans-serif;
}

.guest-info{
    padding:12px 14px;
    border-radius:12px;
    background: linear-gradient(180deg, rgba(47,128,237,0.05), rgba(255,255,255,0.4));
    border-left:4px solid rgba(47,128,237,0.12);
    color:#134e8b;
    font-size:0.93rem;
}

.classroom{
    display:none;
    position:fixed;
    inset:0;
    z-index:1200;
    background: linear-gradient(180deg,#f6f8ff, #eef4ff);
    overflow:hidden;
}

.classroom-header{
    height:72px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:12px 18px;
    background: linear-gradient(90deg,var(--primary), var(--accent));
    color:white;
    box-shadow: 0 6px 20px rgba(15,23,42,0.08);
}

.header-left, .header-right{ display:flex; align-items:center; gap:8px; }
.header-center{ text-align:center; line-height:1; }
#sessionTitle{ font-weight:700; font-size:1rem; display:block  }

.user-badge{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:6px 12px;
    border-radius:999px;
    background: rgba(255,255,255,0.12);
    font-weight:700;
    font-size:0.85rem;
}

.icon-btn{
    display:inline-flex;
    align-items:center;
    gap:8px;
    min-height:var(--touch-size);
    padding:8px 12px;
    border-radius:12px;
    background: rgba(255,255,255,0.06);
    color:white;
    border:none;
    cursor:pointer;
    font-weight:600;
    transition: all var(--transition);
}

.icon-btn i{ font-size:16px; width:18px; text-align:center }
.icon-btn:hover{ transform: translateY(-3px); background: rgba(255,255,255,0.12); }

.icon-bt1{
    display:inline-flex;
    align-items:center;
    gap:8px;
    min-height:var(--touch-size);
    padding:8px 12px;
    border-radius:12px;
    background: rgba(255, 255, 255, 0.507);
    color:rgb(0, 0, 0);
    border:none;
    cursor:pointer;
    font-weight:600;
    transition: all var(--transition);
}

.icon-bt1 i{ font-size:16px; width:18px; text-align:center }
.icon-bt1:hover{ transform: translateY(-3px); background: rgba(31, 247, 128, 0.227); }

.sidebar{
    position:fixed;
    top:72px;
    width:var(--sidebar-width);
    height: calc(100vh - 72px);
    right: calc(-1 * var(--sidebar-width));
    background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.95));
    box-shadow: -12px 0 30px rgba(31,41,55,0.06);
    transition: right 260ms cubic-bezier(.2,.9,.2,1), transform var(--transition);
    z-index:1250;
    border-left:1px solid rgba(15,23,42,0.04);
    display:flex;
    flex-direction:column;
}

.sidebar.show{ right:0; transform: none; }

.sidebar-header{
    padding:16px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    border-bottom:1px solid rgba(15,23,42,0.03);
}

.sidebar-content {
    padding:0;
    display:flex;
    flex-direction:column;
    height:100%;
}

#chatMessages {
    flex:1;
    padding:12px;
    overflow-y:auto;
}

.chat-input-container {
    padding:12px;
    border-top:1px solid rgba(15,23,42,0.08);
    background:white;
}

.close-btn{
    background:none;
    border:none;
    font-size:18px;
    color:var(--muted);
    cursor:pointer;
    padding:8px;
    border-radius:8px;
}

.close-btn:hover{ background: rgba(15,23,42,0.04); color:#0f172a }

.main-content{
    /* height: calc(100vh - 72px); */
    padding:18px;
    padding-top:24px;
    transition: margin-right var(--transition);
    display:flex;
    flex-direction:column;
    gap:14px;
}

.main-content.with-sidebar{ margin-right: var(--sidebar-width); }

.video-grid{
    flex:1;
    display:grid;
    gap:14px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 320px));
    justify-content:center;
    align-items:start;
    overflow:auto;
    padding-bottom:18px;
}

.video-item{
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,250,0.95));
    border-radius:12px;
    overflow:hidden;
    position:relative;
    box-shadow: 0 8px 24px rgba(15,23,42,0.04);
    min-height:160px;
    display:flex;
    flex-direction:column;
}

.video-placeholder{
    width:100%;
    height:200px;
    display:grid;
    place-items:center;
    background: linear-gradient(180deg, rgba(15,23,42,0.06), rgba(15,23,42,0.04));
    color:var(--muted);
    font-size:2.2rem;
}

.video-item.active-speaker{ box-shadow: 0 0 0 4px rgba(39,174,96,0.12); }
.video-item.hand-raised{ animation: pulse-hand 2s infinite; border:1px solid rgba(243,156,18,0.15); }
.video-item.presenting{ box-shadow: 0 0 0 4px rgba(23,162,184,0.12); }

.user-info{
    padding:12px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    background:transparent;
}

.user-actions{ display:flex; gap:8px; align-items:center; }

.user-action-btn{
    background: rgb(255, 255, 255);
    border:none;
    padding:8px;
    border-radius:8px;
    cursor:pointer;
}

.user-action-btn:hover{ background: rgba(255, 255, 255, 0.852) }

.status-indicator{
    width:10px; height:10px; border-radius:50%;
    background:#cbd5e1;
    display:inline-block;
}

.status-indicator.audio-on{ background:var(--success) }
.status-indicator.video-on{ background:var(--success) }
.status-indicator.hand-raised{ background:var(--warning) }

.controls{
    position:fixed;
    left:50%;
    transform:translateX(-50%);
    bottom:22px;
    display:flex;
    gap:12px;
    padding:10px 16px;
    border-radius:999px;
    background: rgba(255,255,255,0.94);
    box-shadow: 0 14px 40px rgba(15,23,42,0.06);
    z-index:1300;
    align-items:center;
}

.control-btn{
    width:54px; height:54px; border-radius:50%;
    display:grid; place-items:center;
    border:none; cursor:pointer;
    font-size:18px;
    background: linear-gradient(180deg, #ffffff, #f5f7fb);
    box-shadow: 0 8px 18px rgba(15,23,42,0.04);
}

.control-btn:hover{ transform: scale(1.06) }
.control-btn.active{ background: linear-gradient(90deg,#4ade80,#16a34a); color:white; box-shadow: 0 12px 30px rgba(16,185,129,0.12) }
.control-btn.muted{ background: linear-gradient(90deg,#ff7b7b,#ef4444); color:white; }

.participants-stats{ 
    display: flex;
    justify-content: center;
    margin: 10px 0 12px 0;
}

.participants-count-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #fef9c3, #fde047);
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #854d0e;
    border: 1px solid #facc15;
    box-shadow: 0 4px 12px rgba(250, 204, 21, 0.25);
    animation: countGlow 2.2s infinite ease-in-out;
}

.participants-count-box i {
    font-size: 1.15rem;
}

@keyframes countGlow {
    0%   { box-shadow: 0 0 0 rgba(250, 204, 21, 0.0); }
    50%  { box-shadow: 0 0 14px rgba(250, 204, 21, 0.9); }
    100% { box-shadow: 0 0 0 rgba(250, 204, 21, 0.0); }
}

.participants-list{ display:flex; flex-direction:column; gap:8px; padding:12px; overflow:auto; }

.participant-item{
    display:flex; align-items:center; gap:10px;
    padding:10px; border-radius:10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,250,0.95));
    border:1px solid rgba(15,23,42,0.03);
}

.participant-avatar{ width:44px; height:44px; border-radius:50%; display:grid; place-items:center; font-weight:700; color:white; background:var(--primary) }
.participant-info{ flex:1; min-width:0 }
.participant-name{ font-weight:700; font-size:0.95rem; color:#0f172a }
.participant-role{ font-size:0.85rem; color:var(--muted) }

.chat-messages{ padding:12px; overflow:auto; display:flex; flex-direction:column; gap:10px; }
.chat-message{ max-width:78%; padding:10px 12px; border-radius:12px; font-size:0.95rem; }
.chat-message.own{ background: linear-gradient(90deg,var(--primary),var(--accent)); color:white; margin-left: auto; }
.chat-message.other{ background: linear-gradient(180deg,#f8fafc,#ffffff); color:#0f172a; margin-right:auto; border:1px solid rgba(15,23,42,0.03) }
.chat-message-header{ font-size:0.82rem; opacity:0.85; margin-bottom:6px }

.chat-input-container{ 
    display:flex; 
    gap:10px; 
    padding:12px; 
    border-top:1px solid rgba(15,23,42,0.03); 
    background:transparent 
}

.chat-input-container input{ 
    padding:12px 14px; 
    border-radius:999px; 
    border:1px solid rgba(15,23,42,0.04); 
    flex:1;
}

.whiteboard-tools{ display:flex; gap:10px; padding:12px; border-bottom:1px solid rgba(15,23,42,0.03) }
.tool-btn{ padding:8px 10px; border-radius:8px; border:1px solid rgba(15,23,42,0.04); background:transparent; cursor:pointer }
.tool-btn.active{ background: linear-gradient(90deg,var(--primary),var(--accent)); color:white; border-color:transparent }

#whiteboard{ width:100%; height:420px; border-radius:10px; border:1px solid rgba(15,23,42,0.04); background: linear-gradient(180deg,#ffffff,#fbfbff); cursor:crosshair }

.modal{ display:none; position:fixed; inset:0; background: rgba(10,12,20,0.45); z-index:1400; align-items:center; justify-content:center; padding:20px; }
.modal.show{ display:flex }
.modal-content{ width:100%; max-width:560px; background:linear-gradient(180deg,#fff,#fbfdff); border-radius:14px; overflow:auto; box-shadow: 0 20px 60px rgba(15,23,42,0.12) }
.modal-header{ padding:14px 16px; border-bottom:1px solid rgba(15,23,42,0.03); display:flex; align-items:center; justify-content:space-between }

.session-item{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px; border-radius:10px; background: linear-gradient(180deg,#f8fafc,#ffffff); border:1px solid rgba(15,23,42,0.03) }
.session-code{ font-family: monospace; background: rgba(15,23,42,0.03); padding:4px 8px; border-radius:6px; font-size:0.92rem }

.presenting-badge{ position:absolute; top:10px; left:10px; background:var(--info); color:white; padding:6px 10px; border-radius:999px; font-weight:700; font-size:0.85rem }

@keyframes fadeIn{ from{ opacity:0; transform:translateY(8px) } to{ opacity:1; transform:none } }
@keyframes pulse-hand{
    0%{ box-shadow: 0 0 0 0 rgba(243,156,18,0.08) }
    50%{ box-shadow: 0 0 0 10px rgba(243,156,18,0.04) }
    100%{ box-shadow: 0 0 0 0 rgba(243,156,18,0.08) }
}

button:focus, input:focus, .tab:focus{ outline: none; box-shadow: 0 0 0 4px rgba(47,128,237,0.12) }

@media (max-width: 1100px){
    :root{ --sidebar-width:320px }
    .video-grid{ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) }
    .container{ max-width:520px }
}

/* ====== ریسپانسیو کامل برای موبایل ====== */
@media (max-width: 768px){
    .container{ margin:10px; border-radius:14px; max-width:100% }
    .header{ padding:18px }
    .logo{ width:52px; height:52px; font-size:22px }
    .logo img { width: 48px; height: auto; }
    .tabs{ gap:6px; padding:6px }
    .tab{ padding:9px; font-size:14px }
    .video-grid{ grid-template-columns: 1fr; gap:12px; padding:12px }
    .controls{ left:12px; transform:none; right:12px; bottom:12px; justify-content:center; width: calc(100% - 24px) }
    .controls{ position:fixed; display:flex; gap:10px; padding:10px; border-radius:14px; }
    .control-btn{ width:48px; height:48px; }
    .icon-btn span{ display:none }
    .header-right { display:none; }
    
    /* سایدبار عمومی برای موبایل */
    .sidebar{ 
        width: 100%; 
        right: -100%; 
        top:72px; 
        height: calc(100vh - 72px);
        transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    .sidebar.show{ 
        right: 0; 
        box-shadow: -20px 0 40px rgba(0, 0, 0, 0.15);
    }
    
    /* تنظیمات خاص برای چت سایدبار */
    #chatSidebar {
        background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.98));
        z-index: 1400;
    }
    
    #chatSidebar .sidebar-content {
        padding: 0;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    /* پنهان کردن کنترل‌ها وقتی چت باز است */
    #chatSidebar.show ~ .main-content .controls {
        transform: translateY(100px);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    
    /* بخش پیام‌های چت */
    #chatSidebar #chatMessages {
        flex: 1;
        padding: 15px;
        overflow-y: auto;
        padding-bottom: calc(70px + 15px);
        height: calc(100dvh - 72px - 70px); /* استفاده از dvh به جای vh */
        max-height: none;
        -webkit-overflow-scrolling: touch; /* اسکرول نرم در iOS */
    }

    /* چت باکس ثابت در پایین */
    #chatSidebar .chat-input-container {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        background: white;
        padding: 12px 15px;
        border-top: 1px solid rgba(15,23,42,0.1);
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
        z-index: 1500;
        display: flex;
        align-items: center;
        gap: 10px;
        height: 70px;
        box-sizing: border-box;
        /* برای iOS */
        position: -webkit-sticky;
        position: sticky;
        bottom: 0;
    }

    /* ورودی متن چت */
    #chatSidebar #chatInput {
        flex: 1;
        padding: 14px 18px;
        border-radius: 25px;
        border: 2px solid rgba(15,23,42,0.08);
        font-size: 16px;
        background: #f8fafc;
        min-height: 50px;
        height: 50px;
        transition: all 0.3s ease;
        /* برای iOS */
        -webkit-appearance: none;
        appearance: none;
    }

    /* دکمه ارسال پیام */
    #chatSidebar .icon-bt1 {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, var(--primary), var(--accent));
        color: white;
        border: none;
        box-shadow: 0 4px 15px rgba(47, 128, 237, 0.3);
        font-size: 18px;
        flex-shrink: 0;
        /* برای iOS */
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
/* رفع مشکل viewport در موبایل */
@media (max-width: 768px) {
    /* تنظیمات کلی برای سایدبار چت */
    #chatSidebar {
        width: 100%;
        right: -100%;
        top: 72px;
        height: calc(100dvh - 72px); /* استفاده از dvh */
        background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.98));
        z-index: 1400;
        transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        overflow: hidden;
        position: fixed;
    }
    
    #chatSidebar.show {
        right: 0;
        box-shadow: -20px 0 40px rgba(0, 0, 0, 0.15);
    }
    
    /* محتوای سایدبار */
    #chatSidebar .sidebar-content {
        padding: 0;
        display: flex;
        flex-direction: column;
        height: 100%;
        position: relative;
    }
    
    /* رفع مشکل height در iOS */
    @supports (-webkit-touch-callout: none) {
        #chatSidebar {
            height: -webkit-fill-available;
        }
        
        #chatSidebar #chatMessages {
            height: calc(100% - 70px);
        }
        
        .main-content {
            height: -webkit-fill-available;
        }
    }
    
    /* رفع مشکل keyboard در موبایل */
    #chatInput {
        font-size: 16px !important; /* جلوگیری از zoom در iOS */
    }
    
    /* بهبود اسکرول در موبایل */
    #chatMessages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* رفع مشکل sticky در موبایل */
    .chat-input-container {
        position: -webkit-sticky;
        position: sticky;
        bottom: 0;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

/* تنظیمات برای دستگاه‌های iOS */
@supports (-webkit-touch-callout: none) {
    #chatSidebar #chatMessages {
        height: calc(100% - 70px);
    }
    
    #chatSidebar {
        height: -webkit-fill-available;
    }
    
    body {
        min-height: -webkit-fill-available;
    }
}

    /* رفع مشکل safe area در iPhone X و جدیدتر */
    @supports (padding: max(0px)) {
        #chatSidebar .chat-input-container {
            padding-left: max(12px, env(safe-area-inset-left));
            padding-right: max(12px, env(safe-area-inset-right));
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
        
        #chatSidebar #chatMessages {
            padding-left: max(15px, env(safe-area-inset-left));
            padding-right: max(15px, env(safe-area-inset-right));
        }
    }

    /* برای گوشی‌های قدیمی‌تر که dvh را ساپورت نمی‌کنند */
    @supports not (height: 100dvh) {
        @media (max-width: 768px) {
            #chatSidebar {
                height: calc(100vh - 72px);
            }
            
            #chatSidebar #chatMessages {
                height: calc(100vh - 72px - 70px);
            }
        }
    }

    /* اسکرول بار برای پیام‌ها */
    #chatMessages::-webkit-scrollbar {
        width: 6px;
    }
    
    #chatMessages::-webkit-scrollbar-track {
        background: rgba(15,23,42,0.03);
        border-radius: 3px;
    }
    
    #chatMessages::-webkit-scrollbar-thumb {
        background: rgba(47,128,237,0.3);
        border-radius: 3px;
    }
    
    #chatMessages::-webkit-scrollbar-thumb:hover {
        background: rgba(47,128,237,0.5);
    }
    
    /* انیمیشن برای پیام‌های جدید */
    @keyframes slideInMessage {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .chat-message {
        animation: slideInMessage 0.3s ease;
    }
}

/* تنظیمات برای صفحه‌های کوچک‌تر */
@media (max-width: 480px) {
    #chatSidebar .chat-input-container {
        padding: 10px 12px;
        gap: 8px;
    }
    
    #chatSidebar #chatInput {
        padding: 12px 15px;
        font-size: 15px;
        min-height: 46px;
    }
    
    #chatSidebar .icon-bt1 {
        min-width: 46px;
        min-height: 46px;
        font-size: 16px;
    }
}

/* حالت landscape موبایل */
@media (max-width: 768px) and (orientation: landscape) {
    #chatSidebar {
        top: 60px;
        height: calc(100vh - 60px);
    }
    
    #chatSidebar .chat-input-container {
        padding: 8px 10px;
    }
    
    #chatSidebar #chatInput {
        min-height: 44px;
        padding: 10px 14px;
    }
    
    #chatSidebar .icon-bt1 {
        min-width: 44px;
        min-height: 44px;
    }
    
    #chatSidebar #chatMessages {
        padding-bottom: 70px;
    }
}

/* انیمیشن برای نمایش/پنهان شدن سایدبار */
@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutToRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

#chatSidebar.show {
    animation: slideInFromRight 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

#chatSidebar:not(.show) {
    animation: slideOutToRight 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* تنظیمات UX برای موبایل */
@media (max-width: 768px) {
    #chatInput {
        font-size: 16px;
    }
    
    .icon-bt1, #chatInput {
        -webkit-tap-highlight-color: transparent;
    }
    
    .chat-message {
        max-width: 85%;
        line-height: 1.5;
        word-break: break-word;
    }
}

@media (max-height: 600px){
    #whiteboard{ height:260px }
}

/* تنظیمات سایدبار برای دسکتاپ */
@media (min-width: 769px) {
    .sidebar {
        display: flex;
        flex-direction: column;
    }
    
    .sidebar-content {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0; /* مهم: این باعث میشه flex درست کار کنه */
    }
    
    /* برای محتوای چت */
    #chatSidebar .sidebar-content {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
}

/* تنظیمات سایدبار برای موبایل */
@media (max-width: 768px) {
    #chatSidebar .sidebar-content {
        padding: 0;
        display: flex;
        flex-direction: column;
        height: 100%;
        position: relative;
    }
}
