/* ==========================================================================
   أنماط مجتمع الطلاب التفاعلي والنشر المجهول وفحص سعة الصور (1MB)
   ========================================================================== */

.community-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 992px) {
  .community-layout-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Post Creator Card */
.create-post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.create-post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  min-width: 0;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.author-chip-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary-glow);
  color: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.author-name-preview {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-primary);
}

.role-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Anonymous Switcher */
.anonymous-switch-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: var(--tap-min);   /* هدف لمس مطابق لـ WCAG 2.2 */
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.switch-label input {
  display: none;
}

.switch-slider {
  width: 42px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  position: relative;
  transition: var(--transition);
  border: 1px solid var(--border-strong);
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: var(--transition);
}

.switch-label input:checked + .switch-slider {
  background: var(--color-accent);
  border-color: var(--color-accent-light);
}

.switch-label input:checked + .switch-slider::before {
  transform: translateX(-20px);
}

.post-textarea {
  width: 100%;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--text-primary);
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: var(--transition);
  margin-bottom: 16px;
}

.post-textarea:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* 1MB Image Upload Controls */
.upload-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.upload-actions-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-upload-btn-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.file-upload-btn-label:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-primary-light);
  border-color: var(--color-primary-light);
}

.file-upload-btn-label input {
  display: none;
}

.upload-quota-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.quota-pill {
  font-family: var(--font-latin);
  background: rgba(244, 63, 94, 0.15);
  color: var(--on-surface-danger);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Image Preview & Error Feedback */
.image-preview-wrapper {
  margin: 14px 0;
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.image-preview-wrapper.hidden {
  display: none;
}

.image-preview-el {
  max-height: 220px;
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  object-fit: contain;
  background: #000000;
}

.remove-img-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.remove-img-btn:hover {
  background: var(--color-rose);
}

.image-size-error-box {
  margin: 12px 0;
}

.image-size-error-box.hidden {
  display: none;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.alert-danger {
  background: rgba(136, 19, 55, 0.25);
  border: 1px solid rgba(244, 63, 94, 0.5);
  color: #fecdd3;
}

.alert-danger strong {
  display: block;
  color: var(--on-surface-danger);
  margin-bottom: 2px;
}

.size-ok {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--on-surface-success);
  font-weight: 700;
}

/* Community Feed */
.community-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.community-post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.community-post-card:hover {
  border-color: var(--border-strong);
}

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.post-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.avatar-user {
  background: rgba(2, 132, 199, 0.15);
  color: var(--color-primary-light);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.avatar-anon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--on-surface-accent);
  border: 1px dashed rgba(245, 158, 11, 0.4);
}

.post-author-meta {
  display: flex;
  flex-direction: column;
}

.author-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.author-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.author-name.name-anon {
  color: var(--on-surface-accent);
}

.anon-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--on-surface-accent);
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.role-chip {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.post-time-cat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-cat-badge {
  color: var(--color-primary-light);
}

.post-body {
  margin-bottom: 16px;
}

.post-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.post-img-container {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 380px;
  background: #000000;
}

.post-attachment-img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  cursor: zoom-in;
  transition: var(--transition);
}

.post-attachment-img:hover {
  transform: scale(1.02);
}

.img-meta-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  /* الوسم ده قاعد فوق صورة المنشور بخلفية سوداء ثابتة، فنصّه لازم
     يكون فاتحًا ثابتًا — التوكن كان بيقلبه بنّي غامق في النهاري. */
  background: rgba(0, 0, 0, 0.75);
  color: rgba(241, 245, 249, 0.95);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Post Actions */
.post-actions-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.post-action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  min-height: var(--tap-min);
  padding-block: var(--space-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-arabic);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.post-action-btn:hover {
  color: var(--color-primary-light);
}

.post-action-btn.active-liked {
  color: var(--color-rose);
}

.post-action-btn.active-liked i {
  fill: var(--color-rose);
}

/* Comments Section */
.comments-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.avatar-anon-sm {
  background: rgba(245, 158, 11, 0.15);
  color: var(--on-surface-accent);
}

.comment-bubble {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.comment-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.comment-author {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-primary);
}

.comment-author.name-anon {
  color: var(--on-surface-accent);
}

.comment-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.comment-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Add Comment Input */
.add-comment-box {
  margin-top: 8px;
}

.add-comment-box.hidden {
  display: none;
}

.comment-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-input {
  flex: 1 1 140px;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-arabic);
  font-size: 0.85rem;
  outline: none;
}

.comment-input:focus {
  border-color: var(--color-primary-light);
}

.comment-anon-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.anon-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.anon-checkbox-label input {
  accent-color: var(--color-accent);
}

/* Community Sidebar */
.community-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.widget-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.community-guidelines-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.community-guidelines-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.community-guidelines-list li i {
  color: var(--color-primary-light);
  flex-shrink: 0;
  margin-top: 3px;
}

/* زرّ كشف الهوية — يظهر للمعيد فما فوق فقط.
   شكله متعمَّد إنه "إجراء جادّ" مش أيقونة عادية: الكشف بيتسجّل باسم
   اللي عمله، فالزرّ لازم يقول كده قبل ما يتضغط. */
.reveal-identity-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  padding: var(--space-1) var(--space-3);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--on-surface-danger);
  background: transparent;
  border: 1px dashed currentColor;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--t-colors);
}

.reveal-identity-btn :is(i, svg) { width: 14px; height: 14px; }

@media (hover: hover) and (pointer: fine) {
  .reveal-identity-btn:hover {
    background: var(--fill-danger);
    border-style: solid;
    border-color: transparent;
    color: #ffffff;
  }
}

/* شرح النشر المجهول
   النسخة القديمة كانت بتقول "الهوية مشفرة ولا تظهر حتى لمشرفي الموقع" —
   وده كان غير صحيح تقنيًا (ما كانش فيه تشفير ولا هوية مخزّنة أصلًا)،
   وغير سليم كسياسة: وعد بحماية مطلقة بيشجّع على الإساءة لأن صاحبها
   عارف إن محدّش هيوصله. النص الجديد بيقول الحقيقة بالظبط. */
.anon-explainer {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}

.anon-terms {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.anon-terms li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
}

.anon-terms li :is(i, svg) {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--on-surface-accent);
}

.anon-terms strong { color: var(--text-primary); }

/* اسم الكاتب كرابط لبروفايله — للمنشورات غير المجهولة فقط.
   المجهول بيفضل <span> مش <a>: أي href فيه id بينسف المجهولية. */
.author-link {
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-xs);
}

@media (hover: hover) and (pointer: fine) {
  .author-link:hover { color: var(--on-surface-primary); text-decoration: underline; }
}

/* ==========================================================================
   أشرطة الفلاتر وأزرار التصفية الموحدة (Community Filter Pills)
   ========================================================================== */
.curriculum-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4, 16px);
  background: var(--bg-surface, #0e1629);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 12px);
  padding: 12px 18px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 16px;
  background: var(--bg-card, #131e36);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  color: var(--text-secondary, #cbd5e1);
  font-family: var(--font-arabic, 'Cairo', sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 9999px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.filter-pill-btn:hover {
  background: var(--bg-hover, #22345e);
  color: var(--text-primary, #ffffff);
  border-color: var(--color-primary, #0284c7);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.filter-pill-btn.active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
  color: #ffffff !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  font-weight: 700;
}

@media (max-width: 768px) {
  .curriculum-controls-bar {
    padding: 10px 12px;
  }

  .curriculum-controls-bar .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .curriculum-controls-bar .filter-group .filter-pill-btn {
    flex-shrink: 0;
  }
}
