/* ============================================
   CodeBridge Academy - التصميم الرئيسي
   ألوان حديثة ومتناسقة - متجاوب
   ============================================ */

:root {
    --primary: #0f766e;
    --primary-dark: #0d5c56;
    --primary-light: #14b8a6;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --bg: #f0fdfa;
    --bg-card: #ffffff;
    --text: #134e4a;
    --text-muted: #5eead4;
    --border: #99f6e4;
    --shadow: 0 4px 20px rgba(15, 118, 110, 0.12);
    --radius: 12px;
    --font-ar: 'Tajawal', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
    width: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-ar);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

.main-content {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

/* مساحة بين المحتوى والفوتر في لوحات التحكم */
body.page-admin .main-content,
body.page-teacher .main-content,
body.page-student .main-content {
    padding-bottom: 3.5rem;
    margin-bottom: 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
    min-width: 0;
}

/* ----- Header ----- */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 0.85rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    overflow-x: hidden;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.5rem;
    min-width: 0;
}

.logo-icon {
    font-family: var(--font-mono);
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 1.1rem;
}

.logo-mark {
    width: 60px;
    height: 60px;
    object-fit: contain;
    flex-shrink: 0;
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.main-nav a {
    color: rgba(255,255,255,0.95);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--accent-light);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ----- Buttons ----- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-family: var(--font-ar);
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-outline {
    border-color: rgba(255,255,255,0.7);
    color: #fff;
}

.btn-outline:hover {
    background: rgba(255,255,255,0.15);
}

.btn-success { background: var(--primary-light); color: #fff; }
.btn-success:hover { background: var(--primary); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline-secondary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}
.btn-outline-secondary:hover {
    background: rgba(15, 118, 110, 0.1);
}

/* زر التعديل - واضح في كل الصفحات (لوحة التحكم والجداول) */
.btn-edit {
    border: 2px solid var(--accent-light);
    color: var(--accent-light);
    background: transparent;
}
.btn-edit:hover {
    background: var(--accent-light);
    color: var(--primary-dark);
    border-color: var(--accent-light);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
    align-items: center;
}
.form-actions .btn-primary {
    flex: 1;
    min-width: 200px;
}
.form-actions .btn-outline-secondary {
    text-decoration: none;
}
.btn-icon {
    margin-left: 0.35rem;
    font-weight: bold;
}
.btn-register, .btn-login {
    font-size: 1.05rem;
    padding: 0.75rem 1.5rem;
}

/* زر العودة في لوحة التحكم */
.btn-back {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    border: none;
}
.btn-back:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* زر العودة للأخبار — واضح على أي خلفية */
.btn-back-news {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff !important;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    transition: background 0.2s;
}
.btn-back-news:hover {
    background: var(--primary-dark);
    color: #fff !important;
}

/* ----- Hero ----- */
.hero {
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 50%, #0a3d38 100%);
    color: #fff;
    padding: 4rem 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero .container {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 0.75rem;
    font-weight: 800;
}

.hero p {
    opacity: 0.95;
    max-width: 560px;
    margin: 0 auto 1.5rem;
}

/* ========== ستايلات الصفحة الرئيسية (Home) ========== */
body.page-home .hero-tagline {
    min-height: 2.2em;
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0;
    color: #fbbf24;
}
body.page-home .hero-tagline span {
    display: inline-block;
    animation: heroFadeIn 3s ease-in-out infinite;
}
@keyframes heroFadeIn {
    0%, 100% { opacity: 1; transform: translateY(0); }
    50% { opacity: 0.85; transform: translateY(-2px); }
}

body.page-home .section-title.animate-title {
    animation: titleGlow 4s ease-in-out infinite;
}
@keyframes titleGlow {
    0%, 100% { opacity: 1; text-shadow: 0 0 0 transparent; }
    50% { opacity: 0.95; text-shadow: 0 0 20px rgba(20, 184, 166, 0.35); }
}

body.page-home .home-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    min-width: 0;
}
body.page-home .home-feature-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(15, 118, 110, 0.12);
    border: 1px solid #99f6e4;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
body.page-home .home-feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(15, 118, 110, 0.2);
}
body.page-home .home-feature-card img,
body.page-home .home-feature-card .home-feature-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    display: block;
}
body.page-home .home-feature-card .home-feature-icon svg {
    width: 100%;
    height: 100%;
    color: var(--primary);
}
body.page-home .home-feature-card h3 {
    font-size: 1.1rem;
    color: #0d5c56;
    margin-bottom: 0.5rem;
}
body.page-home .home-feature-card p {
    font-size: 0.95rem;
    color: #134e4a;
    margin: 0;
    line-height: 1.6;
}

body.page-home .home-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 1.5rem;
}
body.page-home .home-gallery img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 12px;
    transition: transform 0.3s ease;
}
body.page-home .home-gallery img:hover {
    transform: scale(1.03);
}
@media (max-width: 768px) {
    body.page-home .home-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

body.page-home .home-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2rem 3rem;
    padding: 2rem 1.5rem;
    min-width: 0;
    background: linear-gradient(135deg, #0f766e 0%, #0d5c56 100%);
    color: #fff;
    border-radius: 12px;
    margin: 2rem 0;
}
body.page-home .home-stats-item {
    text-align: center;
}
body.page-home .home-stats-item strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.25rem;
    font-weight: 800;
}
body.page-home .home-stats-item span {
    font-size: 0.95rem;
    opacity: 0.95;
}

/* ----- Sections ----- */
.section {
    padding: 3.5rem 0;
}

.section-title {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 2rem;
    color: var(--primary-dark);
    font-weight: 800;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

/* ----- About ----- */
#about {
    background: #fff;
}

.about-content {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.about-content p {
    margin-bottom: 1rem;
    color: var(--text);
}

.about-image {
    width: 100%;
    max-width: 600px;
    height: 280px;
    margin: 1.5rem auto;
    border-radius: var(--radius);
    object-fit: cover;
    box-shadow: var(--shadow);
}

.about-highlights {
    text-align: right;
    list-style: disc;
    padding-right: 1.25rem;
    margin: 1.25rem auto 1.5rem;
    max-width: 560px;
    color: var(--text);
    line-height: 1.75;
}

.about-highlights li {
    margin-bottom: 0.5rem;
}

/* ----- دليل الطالب (الصفحة الرئيسية) ----- */
#student-guide .home-guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.home-guide-intro,
.home-guide-preview {
    padding: 1.5rem;
    text-align: right;
}

.home-guide-intro h3,
.home-guide-preview h3 {
    color: var(--primary-dark);
    font-size: 1.2rem;
}

.home-guide-steps {
    margin: 0;
    padding-right: 1.25rem;
    line-height: 1.85;
    color: var(--text);
}

.home-guide-steps li {
    margin-bottom: 0.65rem;
}

.home-guide-preview-text {
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.home-guide-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.home-guide-intro a {
    color: var(--primary);
    font-weight: 600;
}

.home-guide-page-wrap {
    max-width: 840px;
}

.home-guide-full-card {
    padding: 1.75rem;
    margin: 0 auto;
}

.home-guide-page-title {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    color: var(--primary-dark);
}

.home-guide-full-body {
    margin-top: 0.5rem;
}

/* ----- بريد المنصة (واجهة شبيهة بالبريد) ----- */
.mailbox-outer {
    padding-bottom: 2.5rem;
}

.mailbox-app {
    margin-top: 0.5rem;
}

.mailbox-topbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.mailbox-topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.mailbox-back {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    transition: background 0.2s, color 0.2s;
}

.mailbox-back:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.mailbox-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-align: right;
}

.mailbox-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.mailbox-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.mailbox-sub {
    margin: 0.15rem 0 0;
    font-size: 0.82rem;
    opacity: 0.88;
}

.mailbox-flash {
    margin-bottom: 1rem;
}

.mailbox-shell {
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    gap: 1.25rem;
    align-items: start;
}

.mailbox-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 5.5rem;
}

.mailbox-compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent) 0%, #ea8c12 100%);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.mailbox-compose-btn:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.45);
}

.mailbox-compose-icon {
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 300;
}

.mailbox-folders {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mailbox-folder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s;
}

.mailbox-folder:hover {
    background: rgba(15, 118, 110, 0.08);
    color: var(--primary-dark);
}

.mailbox-folder.is-active {
    background: rgba(15, 118, 110, 0.14);
    color: var(--primary-dark);
    border-right: 3px solid var(--primary);
}

.mailbox-folder-icon {
    font-size: 1.1rem;
    opacity: 0.9;
}

.mailbox-badge-count {
    margin-right: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.mailbox-folder-meta {
    margin-right: auto;
    font-size: 0.8rem;
    color: var(--text);
    opacity: 0.55;
    font-weight: 600;
}

.mailbox-hint {
    margin: 1rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.mailbox-main {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.mailbox-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow);
}

.mailbox-compose-panel {
    border-top: 3px solid var(--primary);
}

.mailbox-compose-panel.is-reply {
    border-top-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.12);
}

.mailbox-reply-notice {
    font-size: 0.88rem;
    color: var(--primary-dark);
    margin: 0 0 1rem;
    padding: 0.65rem 0.85rem;
    background: rgba(217, 119, 6, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(217, 119, 6, 0.22);
}

.mailbox-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-size: 1.05rem;
    color: var(--primary-dark);
}

.mailbox-panel-bar {
    width: 4px;
    height: 1.1em;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
}

.mailbox-form-row {
    margin-bottom: 1rem;
}

.mailbox-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.35rem;
}

.mailbox-input,
.mailbox-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.mailbox-input:focus,
.mailbox-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.mailbox-textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.65;
}

.mailbox-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.mailbox-send-btn {
    min-width: 8rem;
    padding: 0.6rem 1.25rem;
    font-weight: 700;
}

.mailbox-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    background: rgba(15, 118, 110, 0.04);
    border-radius: 8px;
    border: 1px dashed var(--border);
}

.mailbox-thread-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mailbox-thread-item {
    border-bottom: 1px solid var(--border);
}

.mailbox-thread-item:last-child {
    border-bottom: none;
}

.mailbox-thread-row {
    display: flex;
    align-items: stretch;
    gap: 0.15rem;
}

.mailbox-thread-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 0.35rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
    border-radius: 8px;
}

.mailbox-thread-link:hover {
    background: rgba(15, 118, 110, 0.06);
}

.mailbox-thread-item.is-unread .mailbox-thread-from,
.mailbox-thread-item.is-unread .mailbox-thread-subj {
    font-weight: 700;
}

.mailbox-thread-item.is-unread .mailbox-thread-avatar {
    box-shadow: 0 0 0 2px var(--accent);
}

.mailbox-thread-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--primary-light), var(--primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
}

.mailbox-thread-avatar-sent {
    background: linear-gradient(145deg, #94a3b8, #64748b);
}

.mailbox-thread-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.mailbox-thread-from {
    font-size: 0.9rem;
    color: var(--primary-dark);
}

.mailbox-thread-subj {
    font-size: 0.88rem;
    color: var(--text);
    opacity: 0.92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mailbox-thread-time {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--text);
    opacity: 0.55;
    white-space: nowrap;
    margin-top: 0.15rem;
}

.mailbox-thread-delete-form {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    align-self: center;
    padding: 0 0.15rem;
}

.mailbox-delete-icon {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    padding: 0.4rem;
    line-height: 1;
    border-radius: 8px;
    transition: opacity 0.15s, background 0.15s;
}

.mailbox-delete-icon:hover {
    opacity: 1;
    background: rgba(220, 38, 38, 0.1);
}

.mailbox-read {
    margin-top: 0;
}

.mailbox-read-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.mailbox-read-delete-form {
    display: inline-flex;
    margin: 0;
}

/* أزرار القراءة على خلفية فاتحة: .btn-outline الافتراضي أبيض وللرؤوس الداكنة فقط */
.mailbox-read-actions .mailbox-btn-backlist.btn-outline {
    border: 2px solid var(--primary);
    color: var(--primary-dark);
    background: #fff;
}

.mailbox-read-actions .mailbox-btn-backlist.btn-outline:hover {
    background: rgba(15, 118, 110, 0.1);
    color: var(--primary-dark);
}

.mailbox-read-actions .mailbox-btn-delete {
    border: 2px solid #b91c1c;
    color: #991b1b;
    background: #fff;
}

.mailbox-read-actions .mailbox-btn-delete:hover {
    background: #fef2f2;
    border-color: #991b1b;
    color: #7f1d1d;
}

.mailbox-read-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.mailbox-read-header {
    padding: 1.25rem 1.35rem;
    background: linear-gradient(180deg, rgba(15, 118, 110, 0.06) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
}

.mailbox-read-subject {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: var(--primary-dark);
    line-height: 1.35;
}

.mailbox-read-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mailbox-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    font-size: 0.92rem;
}

.mailbox-meta-label {
    font-weight: 700;
    color: var(--primary);
    min-width: 2.25rem;
}

.mailbox-meta-value {
    color: var(--text);
}

.mailbox-meta-time {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.mailbox-read-body {
    padding: 1.35rem 1.35rem 1.5rem;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--text);
}

@media (max-width: 900px) {
    .mailbox-shell {
        grid-template-columns: 1fr;
    }
    .mailbox-sidebar {
        position: static;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        align-items: start;
    }
    .mailbox-compose-btn {
        grid-column: 1 / -1;
    }
    .mailbox-folders {
        flex-direction: row;
        flex-wrap: wrap;
        grid-column: 1 / -1;
    }
    .mailbox-folder {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }
    .mailbox-hint {
        grid-column: 1 / -1;
    }
}

/* ----- News ----- */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 1.5rem;
    min-width: 0;
}

.news-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 28px rgba(15, 118, 110, 0.18);
}

.news-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.news-card .news-body {
    padding: 1.25rem;
}

.news-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
}

.news-card .news-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.news-card-link:hover .news-card {
    transform: translateY(-4px);
    box-shadow: 0 8px 28px rgba(15, 118, 110, 0.18);
}

.news-read-more {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

.news-card-link:hover .news-read-more {
    text-decoration: underline;
}

.news-content a {
    color: var(--primary);
    text-decoration: underline;
    word-break: break-word;
}

.news-content a:hover {
    color: var(--primary-dark);
}

/* ----- Languages ----- */
.languages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 1.25rem;
    min-width: 0;
}

.lang-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.lang-card:hover {
    transform: translateY(-4px);
}

.lang-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.lang-card h3 {
    font-size: 1.1rem;
    color: var(--primary-dark);
}

/* عرض السعر والخصم — نفس التصميم والألوان */
.lang-card-price-wrap {
    margin-top: 0.5rem;
    font-size: 1rem;
    text-align: center;
}

/* على الجوال والتابلت (حتى 992px): ترتيب عمودي — أولاً سعر قبل الخصم، تحته سعر بعد الخصم، تحته نسبة الخصم */
@media (max-width: 992px) {
    .lang-card-price-wrap {
        display: flex !important;
        flex-direction: column !important;
        align-items: center;
        gap: 0.35rem;
    }
    .lang-card-price-wrap .lang-price-old,
    .lang-card-price-wrap .lang-price-now,
    .lang-card-price-wrap .lang-price-pct {
        display: block;
        width: 100%;
        text-align: center;
        margin-left: 0 !important;
    }
    .lang-card-price-wrap .lang-price-old { order: 1; }
    .lang-card-price-wrap .lang-price-now { order: 2; }
    .lang-card-price-wrap .lang-price-pct { order: 3; }
}

/* ----- Forms ----- */
.form-section {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-ar);
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ----- رابط نسيت كلمة المرور (صفحة الدخول) ----- */
.forgot-password-wrap {
    margin: 0.75rem 0 0;
    font-size: 0.95rem;
    text-align: left;
}
.forgot-password-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s;
}
.forgot-password-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}
.forgot-password-link::before {
    content: '🔑';
    font-size: 1rem;
}

/* ----- صفحات نسيت كلمة المرور / تعيين كلمة جديدة ----- */
.auth-section {
    padding: 3rem 1.25rem;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--border);
    padding: 2rem 2rem 2.25rem;
    text-align: center;
}
.auth-forgot .auth-card { border-top: 4px solid var(--primary); }
.auth-reset .auth-card { border-top: 4px solid var(--accent); }
.auth-card-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.12) 0%, rgba(20, 184, 166, 0.08) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}
.auth-reset .auth-card-icon { background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(251, 191, 36, 0.08) 100%); color: var(--accent); }
.auth-card-title {
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin: 0 0 0.5rem;
}
.auth-card-desc {
    font-size: 0.95rem;
    color: var(--text);
    margin: 0 0 1.5rem;
    line-height: 1.6;
}
.auth-form { text-align: right; }
.auth-form .form-actions { justify-content: center; flex-wrap: wrap; gap: 0.75rem; }

/* ----- Register / Login ----- */
#register, #login {
    background: #fff;
}

.register-form .form-section,
.login-form .form-section {
    background: var(--bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ----- Dashboard (student/teacher/admin) ----- */
.dashboard-header {
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    font-size: 1.5rem;
    color: var(--primary-dark);
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 1.25rem;
    min-width: 0;
}

.dash-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.dash-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
}

table th,
table td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
    overflow-wrap: break-word;
}

table th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

table tr:hover {
    background: rgba(20, 184, 166, 0.08);
}

/* ----- Flash messages ----- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-dismissible {
    position: relative;
    padding-right: 3rem;
}
.alert-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    left: auto;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    padding: 0.25rem;
    color: inherit;
}
.alert-close:hover {
    opacity: 1;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* مؤقت الاختبار (حسب مدة المدرس) */
.test-timer-box {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin: 1rem 0;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1.1rem;
}
.test-timer-box .test-timer-label { opacity: 0.95; }
.test-timer-box .test-timer-value { font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: 0.05em; }
.test-timer-box.test-timer-low { background: #b45309; }
.test-timer-box.test-timer-warning { background: #dc2626; animation: pulse-timer 1s ease-in-out infinite; }
.test-timer-box.test-timer-ended { background: #374151; }
@keyframes pulse-timer { 50% { opacity: 0.85; } }

/* ----- Footer ----- */
.site-footer {
    background: var(--primary-dark);
    color: #fff;
    padding: 2.5rem 0 1rem;
    margin-top: auto;
    overflow-x: hidden;
}

.site-footer .container {
    max-width: 100%;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    min-width: 0;
}

.footer-contact {
    display: flex;
    flex-direction: column;
}

.footer-brand,
.footer-links,
.footer-social,
.footer-contact {
    min-width: 0;
}

@media (max-width: 768px) {
    .footer-grid {
        text-align: center;
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }
    .footer-brand,
    .footer-links,
    .footer-social,
    .footer-contact {
        width: 100%;
        max-width: 100%;
    }
    .footer-links a,
    .footer-links h4,
    .footer-contact h4 { text-align: center; }
    .footer-contact p { text-align: center; }
    .footer-legal-links {
        flex-direction: column;
        align-self: center;
        align-items: center;
        justify-content: center;
        gap: 0.35rem 0;
        width: 100%;
    }
}

.footer-social { text-align: center; }
.footer-social h4 { color: rgba(255,255,255,0.9); margin-bottom: 0.5rem; }
.footer-social-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
    justify-content: center;
}
.footer-social-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s, background 0.2s, filter 0.2s;
}
.footer-social-icons a:hover { background: rgba(255,255,255,0.2); color: var(--accent-light); }
.footer-social-icons a img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: filter 0.2s;
}
.footer-social-icons a:hover img { filter: brightness(0) saturate(100%) invert(79%) sepia(28%) saturate(1200%) hue-rotate(360deg); }
.footer-social-icons a span { font-size: 0.8rem; padding: 0 0.5rem; }

.footer-contact p {
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.footer-contact-email {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
}
.footer-contact .footer-email {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.footer-contact .footer-email:hover { color: var(--accent-light); }

.footer-legal-links {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.85rem 1.05rem;
    align-items: center;
    margin-top: auto; /* آخر شي داخل عمود التواصل */
    align-self: flex-start; /* يسار */
    justify-content: flex-start;
}

.footer-legal-links a {
    display: inline-block;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.footer-legal-links a:hover {
    color: var(--accent-light);
    border-bottom-color: var(--accent-light);
}

.footer-brand .logo-icon {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.footer-logo-mark {
    width: 52px;
    height: 52px;
    object-fit: contain;
    vertical-align: middle;
    margin-left: 0.25rem;
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.footer-brand > span:not(.logo-icon) {
    display: inline-block;
    font-weight: 800;
    font-size: 1.2rem;
    margin-right: 0.25rem;
}

.footer-links a,
.footer-links h4,
.footer-contact h4 {
    display: block;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.footer-links a:hover { color: var(--accent-light); }

.footer-auth h4 { color: rgba(255,255,255,0.9); margin-bottom: 0.5rem; }
.footer-auth-dropdown { margin-top: 0.25rem; }
.footer-auth-dropdown summary {
    cursor: pointer;
    list-style: none;
    padding: 0.4rem 0;
    color: var(--accent-light);
    font-weight: 500;
}
.footer-auth-dropdown summary::-webkit-details-marker { display: none; }
.footer-auth-dropdown summary::after { content: ' ▼'; font-size: 0.75rem; opacity: 0.8; }
.footer-auth-dropdown[open] summary::after { content: ' ▲'; }
.footer-auth-links { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.footer-auth-links a {
    display: block;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.25rem 0;
}
.footer-auth-links a:hover { color: var(--accent-light); }

.footer-bottom {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ----- Mobile nav ----- */
@media (max-width: 768px) {
    .site-header { overflow: visible; }
    .site-header .header-inner { position: relative; }
    .nav-toggle {
        display: block !important;
        padding: 0.5rem 0.75rem;
        min-width: 44px;
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
        z-index: 201;
        position: relative;
    }
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        width: 100%;
        background: var(--primary-dark);
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        z-index: 200;
        box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    }
    .nav-toggle .nav-toggle-icon {
        display: inline-block;
        font-size: 1.5rem;
        line-height: 1;
        width: 1.2em;
        text-align: center;
    }
}

/* ----- Utility ----- */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }

/* ----- Video player ----- */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    background: #000;
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ----- Checkboxes for languages ----- */
.language-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.language-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    border: 2px solid var(--border);
    min-width: 0;
}
.language-options label span {
    min-width: 0;
    word-break: break-word;
}

.language-options input:checked + span {
    font-weight: 700;
    color: var(--primary);
}

.language-options input {
    width: auto;
}

/* ----- وسائل الدفع في نموذج التسجيل (PayPal / شام كاش) ----- */
.payment-methods-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.payment-method-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.85rem 1rem;
    background: #fff;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.payment-method-option:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.12);
}
.payment-method-option input {
    width: auto;
    flex-shrink: 0;
    accent-color: var(--primary);
}
.payment-method-option input:checked + .payment-method-label .payment-method-name {
    font-weight: 700;
    color: var(--primary);
}
.payment-method-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(20, 184, 166, 0.04);
    box-shadow: 0 0 0 1px var(--primary);
}
.payment-method-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.payment-method-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
}
.payment-method-name {
    color: var(--text);
    font-size: 1rem;
    margin-left: 0.25rem;
}
/* رابط الدفع — جزء من السطر، بدون صندوق ثانوي */
.payment-method-option .payment-method-link,
a.payment-method-link,
.reg-paypal-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    padding: 0.35rem 0.75rem;
    margin-right: auto;
    background: transparent !important;
    color: var(--primary) !important;
    border: none !important;
    border-radius: 4px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.payment-method-option .payment-method-link:hover,
a.payment-method-link:hover,
.reg-paypal-link:hover {
    background: rgba(20, 184, 166, 0.12) !important;
    color: var(--primary-dark) !important;
    text-decoration: underline;
}

/* ----- وصل الدفع في لوحة الأدمن (صورة + تحميل) ----- */
.receipt-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}
.receipt-preview-link {
    display: block;
    line-height: 0;
}
.receipt-thumb {
    max-width: 120px;
    max-height: 80px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}
.receipt-thumb:hover {
    outline: 2px solid var(--primary);
}
.btn-receipt-download {
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
}

/* ========== متجاوب: منع التمرير يمين/يسار + ضبط الشاشات الصغيرة ========== */
img, video, iframe, object, embed {
    max-width: 100%;
    height: auto;
}
img { vertical-align: middle; }
video { display: block; }

input, select, textarea, button {
    max-width: 100%;
}

.dashboard-header,
.form-row,
.footer-grid,
.main-nav,
.header-inner,
.register-form,
.form-section {
    min-width: 0;
}

/* شاشات متوسطة (تابلت وأصغر) */
@media (max-width: 768px) {
    .container { padding: 0 1rem; }
    .section { padding: 2.5rem 0; }
    .section-title { font-size: 1.4rem; margin-bottom: 1.5rem; }
    .card { padding: 1.25rem; }
    .hero { padding: 3rem 0; }
    .hero h1 { font-size: 1.5rem; }
    .site-footer { padding: 2rem 0 1rem; overflow-x: hidden; }
    .site-footer .container { padding-left: 1rem; padding-right: 1rem; width: 100%; box-sizing: border-box; }
    .footer-grid { gap: 1.5rem; }
    .about-content,
    .form-section,
    .register-form .form-section { max-width: 100%; }
    .auth-card { max-width: 100%; margin-left: 0.5rem; margin-right: 0.5rem; padding: 1.5rem; }
    .dashboard-header { flex-wrap: wrap; gap: 0.75rem; }
    .dashboard-header h1 { font-size: 1.25rem; }
    .dash-card { padding: 1rem; }
    .table-wrap { width: 100%; }
    table th, table td { padding: 0.5rem 0.35rem; font-size: 0.85rem; }
    .home-guide-actions {
        flex-direction: column;
    }
    .home-guide-actions .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* شاشات صغيرة (موبايل) */
@media (max-width: 480px) {
    .container { padding: 0 0.75rem; }
    .section { padding: 2rem 0; }
    .section-title { font-size: 1.25rem; margin-bottom: 1.25rem; }
    .card { padding: 1rem; }
    .hero { padding: 2rem 0; }
    .hero h1 { font-size: 1.35rem; }
    .hero p { font-size: 0.95rem; }
    .site-footer { padding: 1.5rem 0 0.75rem; overflow-x: hidden; }
    .site-footer .container { padding-left: 0.75rem; padding-right: 0.75rem; }
    .footer-grid { gap: 1.25rem; grid-template-columns: 1fr; }
    .footer-bottom { padding-top: 0.75rem; font-size: 0.85rem; }
    .footer-brand p,
    .footer-links a,
    .footer-contact .footer-email { word-break: break-word; overflow-wrap: break-word; max-width: 100%; }
    .dash-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .form-group input,
    .form-group select,
    .form-group textarea { font-size: 16px; }
    .form-actions .btn-primary { min-width: 0; width: 100%; }
    .form-actions { flex-direction: column; }
    .form-actions .btn-outline-secondary { width: 100%; text-align: center; }
    .btn { padding: 0.5rem 1rem; font-size: 0.95rem; }
    .logo { font-size: 1.25rem; }
    .logo-text {
        font-size: 1.12rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        max-width: none;
        line-height: 1.2;
    }
    .register-form .form-section,
    .login-form .form-section { padding: 1.25rem; }
    .about-content { padding: 0 0.25rem; }
    .about-image { height: 200px; }
    .news-grid { grid-template-columns: 1fr; }
    .languages-grid { grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); }
    .lang-card { padding: 1rem; }
    .lang-card img { width: 60px; height: 60px; }
    .payment-methods-list { flex-direction: column; }
    .payment-method-option { width: 100%; }
    .language-options { flex-direction: column; }
    .language-options label { width: 100%; }
    body.page-home .home-gallery { grid-template-columns: 1fr; gap: 0.5rem; }
    body.page-home .home-stats { gap: 1.5rem; padding: 1.25rem; }
    body.page-home .home-stats-item strong { font-size: 1.5rem; }
}

/* ========== الشات — تصميم كامل (أدمن + معلم) ========== */
.chat-page-header { margin-top: 1rem; }
.chat-page-subtitle { color: var(--text-muted); margin: 0.25rem 0 0; font-size: 0.95rem; }

.chat-card {
    max-width: 820px;
    margin-top: 1.25rem;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
}

.chat-messages {
    min-height: 300px;
    max-height: 420px;
    overflow-y: auto;
    padding: 1.25rem;
    background: linear-gradient(180deg, #f0fdfa 0%, #f8fafc 100%);
}

/* فقاعة الرسالة */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    position: relative;
}
.chat-msg:last-child { margin-bottom: 0; }
.chat-msg-me {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-bottom-left-radius: 4px;
}
.chat-msg-other {
    align-self: flex-start;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-bottom-right-radius: 4px;
}

.chat-msg-head { margin-bottom: 0.35rem; }
.chat-msg-sender {
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0.95;
}
.chat-msg-me .chat-msg-sender { color: rgba(255,255,255,0.95); }
.chat-msg-other .chat-msg-sender { color: var(--primary); }

/* تذييل الرسالة: الوقت + النقاط الثلاث جمب الرسالة */
.chat-msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.35rem;
}
.chat-msg-time { margin: 0; }

/* زر النقاط الثلاث — أكبر وواضح وجنب الرسالة */
.chat-msg-menu { position: relative; flex-shrink: 0; }
.chat-msg-dots {
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: rgba(0,0,0,0.1);
    color: inherit;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.chat-msg-dots:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.chat-msg-me .chat-msg-dots {
    background: rgba(255,255,255,0.4);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.chat-msg-me .chat-msg-dots:hover {
    background: rgba(255,255,255,0.65);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.chat-msg-other .chat-msg-dots {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}
.chat-msg-other .chat-msg-dots:hover {
    background: #f1f5f9;
    border-color: var(--primary-light);
}

/* القائمة المنسدلة — تعديل / حذف */
.chat-msg-dropdown {
    display: none !important;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    min-width: 140px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    z-index: 100;
    overflow: hidden;
}
.chat-msg-dropdown[hidden] { display: none !important; }
.chat-msg-dropdown[data-open="1"] { display: block !important; }

.chat-msg-dropdown a,
.chat-msg-dropdown button {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1.1rem;
    text-align: right;
    border: none;
    background: none;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-family: inherit;
}
.chat-msg-dropdown form { margin: 0; display: block; }
.chat-msg-dropdown form button { width: 100%; }
.chat-msg-dropdown > form:last-child button { border-bottom: none; }
.chat-msg-dropdown a:hover {
    background: #e0f2f1;
    color: var(--primary-dark);
}
.chat-msg-dropdown .chat-dropdown-delete {
    color: #b91c1c;
    font-weight: 600;
}
.chat-msg-dropdown .chat-dropdown-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

.chat-msg-body {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.55;
    font-size: 0.95rem;
}
.chat-msg-me .chat-msg-body { color: rgba(255,255,255,0.98); }
.chat-msg-time {
    font-size: 0.75rem;
    opacity: 0.9;
}
.chat-msg-me .chat-msg-time { color: rgba(255,255,255,0.85); }
.chat-msg-other .chat-msg-time { color: var(--text-muted); }

/* نموذج تعديل الرسالة */
.chat-edit-form {
    margin-top: 0.75rem;
    padding: 1rem;
    background: rgba(255,255,255,0.5);
    border-radius: 12px;
    border: 1px dashed var(--border);
}
.chat-msg-me .chat-edit-form { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.4); }
.chat-edit-form textarea {
    width: 100%;
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 72px;
}
.chat-edit-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }
.chat-edit-actions .btn { padding: 0.4rem 1rem; font-size: 0.9rem; }

/* منطقة الإرسال */
.chat-send-form {
    padding: 1.25rem;
    background: #fff;
    border-top: 1px solid var(--border);
}
.chat-send-form .chat-textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 88px;
    margin-bottom: 0.75rem;
}
.chat-send-form .chat-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}
.chat-send-form .btn-primary { padding: 0.55rem 1.5rem; font-size: 1rem; border-radius: 10px; }
.chat-send-form .btn-outline-secondary {
    margin-right: 0.5rem;
    padding: 0.55rem 1.1rem;
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 10px;
}

.chat-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2.5rem 1rem;
    margin: 0;
    font-size: 0.95rem;
}

/* ========== قائمة المحادثات — الأدمن (جميع المعلمين + بحث) ========== */
.chat-conversations-wrap { padding: 1.25rem; }
.chat-list-title {
    margin: 0 0 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
}
.chat-teacher-search { margin-bottom: 1.25rem; }
.chat-search-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.chat-search-bar {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 260px;
    max-width: 520px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chat-search-bar .chat-search-input {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border: none;
    background: transparent;
    color: var(--primary-dark);
}
.chat-search-bar .chat-search-input::placeholder {
    color: var(--text-muted);
}
.chat-search-bar .chat-search-input:focus {
    outline: none;
}
.chat-search-bar .btn {
    flex-shrink: 0;
    margin: 0;
    border-radius: 0;
    border: none;
    border-inline-start: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
}
.chat-search-cancel { flex-shrink: 0; }
.chat-list { list-style: none; padding: 0; margin: 0; }
.chat-list li { list-style: none; margin-bottom: 0.5rem; }
.chat-list li:last-child { margin-bottom: 0; }
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-list-item:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 16px rgba(20, 184, 166, 0.12);
}
.chat-list-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.chat-list-body { flex: 1; min-width: 0; }
.chat-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.chat-list-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-dark);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.chat-list-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.chat-list-preview {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-list-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(20, 184, 166, 0.12);
    padding: 2px 8px;
    border-radius: 8px;
    margin-right: 0.35rem;
}
.chat-list-unread {
    background: var(--primary);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

@media (max-width: 768px) {
    .main-content .container { max-width: 100%; }
    .site-header .container { max-width: 100%; }
    .chat-messages { max-height: 340px; }
    .chat-msg { max-width: 92%; }
    .chat-list-item { padding: 0.85rem 1rem; }
    .chat-list-avatar { width: 42px; height: 42px; font-size: 1rem; }
}

/* تعليقات الكورس (تم حذفها) */
.user-guide-content h2 { margin: 0 0 1rem; font-size: 1.35rem; color: var(--primary-dark); }
.user-guide-content h3 { margin: 1.25rem 0 0.5rem; font-size: 1.1rem; color: var(--primary-dark); }
.user-guide-content p { margin: 0 0 0.75rem; }
.user-guide-content ul { margin: 0 0 0.75rem; padding-right: 1.5rem; }
