/* ===== الخطوط ===== */
@font-face {
    font-family: 'Tajawal';
    src: url('/fonts/Tajawal-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('/fonts/Tajawal-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('/fonts/Tajawal-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

/* ===== المتغيرات الأساسية ===== */
:root {
    /* الخلفيات */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #263347;

    /* النصوص */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    /* الحدود */
    --border: #1e293b;
    --border-hover: #334155;

    /* الثيم الافتراضي — طالب أزرق */
    --accent: #2563eb;
    --accent-light: #3b82f620;
    --accent-text: #93c5fd;

    /* الخطوط */
    --font-arabic: 'Tajawal', sans-serif;
    --font-english: 'Inter', sans-serif;

    /* الحجم */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ===== ثيمات الأدوار ===== */
[data-theme="student"] {
    --accent: #2563eb;
    --accent-light: #2563eb20;
    --accent-text: #93c5fd;
}
[data-theme="teacher"] {
    --accent: #0891b2;
    --accent-light: #0891b220;
    --accent-text: #67e8f9;
}
[data-theme="admin"] {
    --accent: #7c3aed;
    --accent-light: #7c3aed20;
    --accent-text: #c4b5fd;
}
[data-theme="org"] {
    --accent: #d97706;
    --accent-light: #d9770620;
    --accent-text: #fcd34d;
}

/* ===== الأساسيات ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    direction: rtl;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-weight: 400;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* اللغة الإنجليزية */
:lang(en), [lang="en"] {
    font-family: var(--font-english);
    direction: ltr;
}

/* ===== العناوين ===== */
h1, h2, h3, h4 {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-family: var(--font-arabic);
    font-weight: 500;
    font-size: 14px;
    transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 0.5px solid var(--border-hover);
}
.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== الحقول ===== */
.input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 0.5px solid var(--border-hover);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: 14px;
    transition: border-color 0.15s;
    outline: none;
}
.input:focus {
    border-color: var(--accent);
}
.input::placeholder {
    color: var(--text-muted);
}

/* ===== البطاقات ===== */
.card {
    background: var(--bg-secondary);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.card-hover {
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.card-hover:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

/* ===== الشريط الجانبي ===== */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-left: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.sidebar-section {
    padding: 8px;
}

.sidebar-label {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* ===== عناصر الشريط الجانبي ===== */
.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: background 0.1s, color 0.1s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: right;
    font-family: var(--font-arabic);
}
.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--accent-light);
    color: var(--accent-text);
    font-weight: 500;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
}
.nav-item {
    position: relative;
}

/* ===== الفضاءات والغرف والزوايا ===== */
.space-item {
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.1s;
}
.space-item:hover { color: var(--text-primary); }
.space-item.active { color: var(--accent-text); }

.room-item {
    padding: 5px 10px 5px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.1s;
}
.room-item:hover { color: var(--text-secondary); }
.room-item.active { color: var(--text-primary); }

.corner-item {
    padding: 5px 10px 5px 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.1s;
}
.corner-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.corner-item.active {
    background: var(--accent-light);
    color: var(--accent-text);
}

/* ===== أيقونات أنواع الزوايا ===== */
.corner-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* ===== منطقة الدردشة ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.chat-header {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 700;
}

.chat-header-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== الرسائل ===== */
.message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.message-content .message-name {
    font-size: 13px;
    color: var(--accent-text);
    font-weight: 500;
    margin-bottom: 3px;
}

.message-content .message-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.message-content .message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ===== شريط الإدخال ===== */
.input-area {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-top: 0.5px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.input-box {
    flex: 1;
    background: var(--bg-primary);
    border: 0.5px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 42px;
    max-height: 120px;
    transition: border-color 0.15s;
}
.input-box:focus { border-color: var(--accent); }
.input-box::placeholder { color: var(--text-muted); }

/* ===== شارة الدور ===== */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--accent-light);
    color: var(--accent-text);
}

/* ===== مؤشر التشفير ===== */
.encrypt-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    background: #064e3b;
    color: #34d399;
}

/* ===== بطاقات الإحصائيات ===== */
.stat-card {
    background: var(--bg-secondary);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== الاستجابة للموبايل ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        border-left: none;
        border-bottom: 0.5px solid var(--border);
    }
}