/* News Card Specific Styles */

.news-card {
  background-color: var(--card-bg-color, #fff);
  border: 1px solid var(--card-border-color, #eef2f5);
  border-radius: 12px; /* Softer corners */
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
  overflow: hidden; /* Ensures footer gradient stays within rounded corners */
  height: auto !important;
  min-height: fit-content;
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem; /* Consistent spacing between cards */
  /* Prevent any stacking issues */
  position: relative;
  z-index: 1;
  /* Ensure proper box model */
  box-sizing: border-box;
  /* Prevent flex items from shrinking */
  flex-shrink: 0;
}

/* حالات المهام */
.news-card.updating {
  background-color: #fff3cd;
  border-color: #ffc107;
  animation: pulse-updating 2s infinite;
}

.news-card.processing {
  background-color: #cff4fc;
  border-color: #0dcaf0;
  animation: pulse-processing 2s infinite;
}

.news-card.completed {
  background-color: #d1e7dd;
  border-color: #198754;
}

.news-card.failed {
  background-color: #f8d7da;
  border-color: #dc3545;
}

.news-card.cancelled {
  background-color: #fff3cd;
  border-color: #ffc107;
}

/* تأثيرات النبض للحالات النشطة */
@keyframes pulse-updating {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

@keyframes pulse-processing {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.9; }
}

/* شارة حالة المهمة */
.task-status-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.75rem;
  z-index: 10;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.news-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

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

.news-card .card-title {
  color: var(--text-color);
  font-weight: 700; /* Bolder title */
  font-size: 1.1rem;
}

.news-card .card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted-color, #6c757d);
}

.news-card .badge.bg-info {
  background-color: var(--info-bg-color, #0dcaf0) !important;
  color: #fff;
}

.news-card .ai-summary {
  background-color: var(--ai-summary-bg, #f8f9fa);
  border: 1px solid var(--card-border-color, #eef2f5);
  margin-top: 15px;
  padding: 10px;
  border-radius: 8px;
}

/* Sentiment Badge Styles */
.sentiment-badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: 15px;
  display: inline-block;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.25rem;
  vertical-align: top;
  white-space: nowrap;
}

.sentiment-badge i {
  font-size: 0.75rem;
}

.sentiment-badge small {
  font-size: 0.65rem;
  opacity: 0.8;
  font-weight: 400;
}

/* Ensure badges in thematic categories display inline */
.news-card .card-body .mb-2 .badge {
  display: inline-block !important;
  margin-right: 0.25rem !important;
  margin-bottom: 0.25rem !important;
}

.news-card .card-footer {
  background: var(--card-footer-bg, #fcfdff);
  border-top: 1px solid var(--card-border-color, #eef2f5);
  padding: 0.75rem 1.25rem;
}

/* Star Rating Styles */
.star-rating i {
  cursor: pointer;
  font-size: 1.2rem;
  color: #d3d3d3;
  transition: color 0.2s;
}

.star-rating i:hover {
    color: #ffca28;
}

.star-rating .fas {
    color: #ffc107;
}

.star-rating.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Dark Theme Overrides */
body[data-theme='dark'] .news-card {
    background-color: #2f3e4f;
    border-color: #405265;
}

body[data-theme='dark'] .news-card .ai-summary {
    background-color: #2a3848;
    border-color: #405265;
}

body[data-theme='dark'] .news-card .card-footer {
    background-color: #2a3848;
    border-top-color: #405265;
}

body[data-theme='dark'] .star-rating i {
    color: #4a627a;
}
body[data-theme='dark'] .star-rating i:hover {
    color: #00bfa5;
}
body[data-theme='dark'] .star-rating .fas {
    color: #00bfa5;
}

/* Dark Theme Sentiment Badge Styles */
body[data-theme='dark'] .sentiment-badge .badge.bg-success {
    background-color: #28a745 !important;
    color: #fff;
}

body[data-theme='dark'] .sentiment-badge .badge.bg-danger {
    background-color: #dc3545 !important;
    color: #fff;
}

body[data-theme='dark'] .sentiment-badge .badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000;
}

/* تحسين مظهر قسم الترجمة */
.translation-section {
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  margin-top: 1rem;
}

/* إزالة المساحة الفارغة للبطاقات غير المترجمة */
.translation-section:empty,
.translation-section:blank {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}

/* تحسين المسافات في البطاقات */
.news-card .card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.news-card .card-body > * {
  margin-bottom: 0.75rem;
}

.news-card .card-body > *:last-child {
  margin-bottom: 0;
}

/* إزالة المساحة الزائدة بين العناصر */
.news-card .card-text {
  margin-bottom: 1rem;
}

.news-card .ai-summary {
  margin-bottom: 1rem;
}

/* إزالة المساحة الزائدة للعناصر الفارغة */
.news-card .mb-2:empty,
.news-card .mb-2:blank,
.news-card .card-body > div:empty,
.news-card .card-body > div:blank,
.news-card .card-body > div:not(:empty):not(:blank):empty {
  display: none !important;
  margin: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}

/* تحسين المسافات بين العناصر */
.news-card .card-body > div:not(:empty):not(:blank) {
  margin-bottom: 0.75rem;
}

.news-card .card-footer {
  margin-top: auto;
}

.translation-section:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.translation-section .text-primary {
  color: #2196f3 !important;
}

.translation-section h6 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.translation-section small {
  font-size: 0.75rem;
  font-weight: 500;
}

.translation-section p {
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

/* تحسين مظهر المودال */
.modal-xl {
  max-width: 1200px;
}

.modal-body {
  max-height: 80vh;
  overflow-y: auto;
}

.modal-body .card {
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modal-body .card-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
}

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

.modal-body h6 {
  color: #495057;
  font-weight: 600;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 0.5rem;
}

.modal-body .badge {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  margin: 0.125rem;
}

.modal-body .text-muted {
  color: #6c757d !important;
  font-style: italic;
}

/* تحسين مظهر الأزرار في المودال */
.modal-footer .btn {
  padding: 0.5rem 1.5rem;
  font-weight: 500;
}

/* تحسين مظهر قسم المحتوى المترجم */
.modal-body .card-header.bg-success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.modal-body .card-header.bg-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
}

/* تحسين مظهر زر عرض التفاصيل */
.btn-view-details {
  transition: all 0.3s ease;
}

.btn-view-details:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* أزرار التنسيق */
#grid-layout-btn, #masonry-layout-btn {
  transition: all 0.3s ease;
  border-radius: 6px !important;
}

#grid-layout-btn:hover, #masonry-layout-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#grid-layout-btn.active, #masonry-layout-btn.active {
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
  color: white !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* تحسين مظهر التمرير في المحتوى */
.modal-body div[style*="overflow-y: auto"] {
  border: 1px solid #e9ecef;
  border-radius: 0.375rem;
  padding: 0.75rem;
  background-color: #f8f9fa;
}

/* تحسين مظهر التقييم في المودال */
.modal-body .star-rating {
  font-size: 1.2rem;
}

.modal-body .star-rating i {
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-body .star-rating i:hover {
  transform: scale(1.1);
}

/* تحسين مظهر الروابط في المودال */
.modal-body a {
  color: #007bff;
  text-decoration: none;
  transition: color 0.3s ease;
}

.modal-body a:hover {
  color: #0056b3;
  text-decoration: underline;
}

/* تحسين مظهر الأيقونات */
.modal-body i {
  width: 16px;
  text-align: center;
  margin-right: 0.5rem;
}

/* تحسين مظهر التصنيفات والكيانات */
.modal-body .badge.bg-info {
  background: linear-gradient(135deg, #17a2b8 0%, #138496 100%) !important;
}

.modal-body .badge.bg-primary {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%) !important;
}

.modal-body .badge.bg-success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.modal-body .badge.bg-warning {
  background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
}

.modal-body .badge.bg-dark {
  background: linear-gradient(135deg, #343a40 0%, #212529 100%) !important;
}

/* تحسين مظهر قسم المشاعر */
.modal-body .badge.fs-6 {
  font-size: 1rem !important;
  padding: 0.5rem 1rem;
}

/* تحسين مظهر الأقسام الفارغة */
.modal-body .text-muted {
  font-style: italic;
  opacity: 0.7;
}

/* تحسين مظهر الأزرار في قسم الترجمة */
.btn-translate-modal {
  transition: all 0.3s ease;
}

.btn-translate-modal:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-translate-modal:disabled {
  transform: none;
  box-shadow: none;
}

/* تحسين مظهر التحميل */
.btn-translate-modal .fa-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   MASONRY GRID LAYOUT FOR NEWS CARDS
   ======================================== */

/* Default grid layout for better space utilization */
#news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  align-items: start; /* Align items to the top to prevent gaps */
  width: 100%;
  margin: 0 auto;
  /* Better grid behavior for different card heights */
  grid-auto-flow: row;
  grid-auto-rows: minmax(auto, max-content);
  /* Ensure proper layout */
  position: relative;
  isolation: isolate;
  /* Reset any potential issues */
  min-height: 0;
  box-sizing: border-box;
}

/* Masonry layout alternative */
#news-grid.masonry-layout {
  display: block;
  column-count: 3;
  column-gap: 1.5rem;
  column-fill: balance;
}

/* Grid layout class (default) */
#news-grid.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  align-items: start;
  width: 100%;
  margin: 0 auto;
  grid-auto-flow: row;
  grid-auto-rows: minmax(auto, max-content);
  /* Ensure proper layout */
  position: relative;
  isolation: isolate;
  min-height: 0;
  box-sizing: border-box;
}

#news-grid.masonry-layout .news-grid-item {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 1.5rem;
  display: inline-block;
}

/* Remove Bootstrap column classes when using grid */
#news-grid .col,
#news-grid .col-md-6,
#news-grid .col-lg-4,
#news-grid .mb-4 {
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Grid item styling */
.news-grid-item {
  width: 100%;
  display: block;
  position: relative;
}

/* Ensure cards fill their grid cells properly */
#news-grid .news-card {
  width: 100%;
  margin-bottom: 0; /* Remove margin since grid handles spacing */
  display: flex;
  flex-direction: column;
  height: auto;
  position: relative;
  z-index: 1;
}

/* Prevent overlapping */
#news-grid.grid-layout .news-grid-item {
  grid-row: auto;
  grid-column: auto;
}

/* Additional CSS for updated/replaced cards */
#news-grid .news-grid-item.updating {
  opacity: 0.7;
  pointer-events: none;
}

#news-grid .news-card.updating {
  opacity: 0.7;
  pointer-events: none;
  transform: scale(0.98);
}

/* Smooth transitions for card updates */
#news-grid .news-card {
  transition: all 0.3s ease;
}

/* Ensure cards maintain their proper positioning after updates */
#news-grid .news-card,
#news-grid .news-grid-item {
  /* Force proper reflow */
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Responsive grid adjustments */
@media (max-width: 576px) {
  #news-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  #news-grid.masonry-layout {
    column-count: 1;
    column-gap: 1rem;
  }
}

@media (min-width: 577px) and (max-width: 768px) {
  #news-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
  }

  #news-grid.masonry-layout {
    column-count: 2;
    column-gap: 1.25rem;
  }
}

@media (min-width: 769px) and (max-width: 992px) {
  #news-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
  }

  #news-grid.masonry-layout {
    column-count: 2;
    column-gap: 1.25rem;
  }
}

@media (min-width: 993px) and (max-width: 1200px) {
  #news-grid {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
  }

  #news-grid.masonry-layout {
    column-count: 3;
    column-gap: 1.5rem;
  }
}

@media (min-width: 1201px) {
  #news-grid {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.75rem;
  }

  #news-grid.masonry-layout {
    column-count: 4;
    column-gap: 1.75rem;
  }
}

/* Alternative: Masonry-like layout using CSS columns for better space utilization */
.news-masonry {
  column-count: 4;
  column-gap: 1.5rem;
  column-fill: balance;
}

.news-masonry .news-card {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 1.5rem;
  display: inline-block;
  width: 100%;
}

/* Fallback for older browsers */
@supports not (display: grid) {
  #news-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
  }

  #news-grid > div {
    flex: 0 1 calc(33.333% - 1rem);
    min-width: 320px;
  }
}

/* Additional safety measures to prevent overlapping */
#news-grid .news-grid-item {
  clear: both;
  float: none;
  /* Reset any inherited positioning */
  position: static;
  /* Ensure proper display */
  display: block;
  /* Reset any grid positioning */
  grid-row: auto;
  grid-column: auto;
}

#news-grid .news-card {
  clear: both;
  float: none;
  overflow: visible;
  /* Ensure proper positioning */
  position: relative;
  z-index: 1;
  /* Reset any grid positioning */
  grid-row: auto;
  grid-column: auto;
}

/* Ensure proper stacking context */
#news-grid {
  position: relative;
  isolation: isolate;
}

#news-grid .news-grid-item {
  position: relative;
  z-index: auto;
  /* Ensure proper box model */
  box-sizing: border-box;
  min-height: 0;
}

#news-grid .news-card {
  /* Ensure proper box model */
  box-sizing: border-box;
  min-height: 0;
  /* Prevent any potential overflow issues */
  overflow: visible;
  /* Ensure proper positioning */
  position: relative;
  z-index: 1;
}

/* Ensure proper spacing and alignment */
#news-grid:empty::after {
  content: "لا توجد أخبار متاحة";
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #6c757d;
  font-style: italic;
}

/* ========================================
   NEWS EDIT FORM STYLES
   ======================================== */

.news-edit-form .card {
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
}

.news-edit-form .card-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  padding: 1rem 1.25rem;
}

.news-edit-form .card-body {
  padding: 1.5rem;
}

.news-edit-form .form-label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
}

.news-edit-form .form-control,
.news-edit-form .form-select {
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.news-edit-form .form-control:focus,
.news-edit-form .form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.news-edit-form .form-text {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

.news-edit-form .badge {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  margin: 0.125rem;
}

.news-edit-form .btn {
  padding: 0.5rem 1.5rem;
  font-weight: 500;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
}

.news-edit-form .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.news-edit-form textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* تحسين التحقق من صحة البيانات */
.news-edit-form .form-control:invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.news-edit-form .form-control:valid {
  border-color: #198754;
}

/* تحسين مظهر حقول الأرقام */
.news-edit-form input[type="number"] {
  max-width: 120px;
}

.news-edit-form input[type="number"]:invalid {
  background-color: #f8d7da;
}

.news-edit-form input[type="datetime-local"] {
  max-width: 200px;
}

/* تحسين مظهر الحقول المركزة */
.news-edit-form .text-center input,
.news-edit-form .text-center select {
  display: inline-block;
  width: auto;
  min-width: 150px;
}

/* تحسين مظهر الحقول متعددة الاختيار */
.news-edit-form select[multiple] {
  min-height: 120px;
}

.news-edit-form select[multiple] option {
  padding: 4px 8px;
  margin: 2px 0;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.news-edit-form select[multiple] option:hover {
  background-color: #f8f9fa;
}

.news-edit-form select[multiple]:focus option:checked {
  background-color: #0d6efd;
  color: white;
}

/* تحسين مظهر حقول التحقق */
.news-edit-form .form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.news-edit-form .form-check-input {
  margin: 0;
  transform: scale(1.1);
}

.news-edit-form .form-check-label {
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

/* تحسين مظهر الرسائل المساعدة */
.news-edit-form .form-text {
  font-size: 0.8rem;
  margin-top: 0.25rem;
  display: block;
  color: #6c757d;
}

/* تحسين مظهر الحقول المركزة */
.news-edit-form .d-flex.justify-content-center input,
.news-edit-form .d-flex.justify-content-center select {
  max-width: 300px;
}

/* نظام النجوم للتقييم */
.star-rating-input {
  display: flex;
  gap: 5px;
  font-size: 1.5rem;
  margin: 10px 0;
}

.star-rating-input i {
  cursor: pointer;
  transition: all 0.2s ease;
  color: #ddd;
}

.star-rating-input i.fas.text-warning {
  color: #ffc107 !important;
}

.star-rating-input i:hover {
  transform: scale(1.2);
}

.star-rating-input i.far:hover {
  color: #ffc107;
}

.star-rating-input i.fas:hover {
  color: #ff8c00;
}

/* تحسين مظهر نظام النجوم في الواجهة */
.news-card .star-rating {
  display: flex;
  gap: 2px;
  font-size: 1rem;
}

.news-card .star-rating i {
  color: #ffc107;
}

.news-card .star-rating i.far {
  color: #ddd;
}

/* نظام إدارة الكيانات والتصنيفات */
.entity-badges, .category-badges, .country-badges, .province-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.entity-badge, .category-badge, .country-badge, .province-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.entity-badge:hover, .category-badge:hover, .country-badge:hover, .province-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.entity-list, .category-list, .country-list, .province-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background-color: #f8f9fa;
}

.entity-item, .category-item, .country-item, .province-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #dee2e6;
  transition: all 0.2s ease;
}

.entity-item:last-child, .category-item:last-child,
.country-item:last-child, .province-item:last-child {
  border-bottom: none;
}

.entity-item.available:hover, .category-item.available:hover,
.country-item.available:hover, .province-item.available:hover {
  background-color: rgba(13, 110, 253, 0.1);
}

.entity-item.selected, .category-item.selected,
.country-item.selected, .province-item.selected {
  background-color: rgba(25, 135, 84, 0.1);
  opacity: 0.7;
}

.entity-item.available .btn, .category-item.available .btn,
.country-item.available .btn, .province-item.available .btn {
  opacity: 0.8;
}

.entity-item.available .btn:hover, .category-item.available .btn:hover,
.country-item.available .btn:hover, .province-item.available .btn:hover {
  opacity: 1;
}

.entity-item.selected .btn, .category-item.selected .btn,
.country-item.selected .btn, .province-item.selected .btn {
  display: none;
}

/* تحسين مظهر الأيقونات في العناصر */
.entity-item i, .category-item i, .country-item i, .province-item i {
  width: 16px;
  text-align: center;
  margin-left: 0.25rem;
}

/* تحسين مظهر الأزرار الصغيرة */
.entity-item .btn-sm, .category-item .btn-sm,
.country-item .btn-sm, .province-item .btn-sm {
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
}

/* تحسين مظهر النصوص التوضيحية */
.selected-entities small, .selected-categories small,
.selected-countries small, .selected-provinces small,
.available-entities small, .available-categories small,
.available-countries small, .available-provinces small {
  font-weight: 500;
  color: #6c757d;
}

/* تحسين التباعد */
.mb-4 .selected-entities, .mb-4 .selected-categories,
.mb-4 .selected-countries, .mb-4 .selected-provinces {
  margin-bottom: 1rem !important;
}

.mb-4 .available-entities, .mb-4 .available-categories,
.mb-4 .available-countries, .mb-4 .available-provinces {
  margin-top: 1rem !important;
}

/* تحسين الاستجابة */
@media (max-width: 768px) {
  .entity-badges, .category-badges, .country-badges, .province-badges {
    gap: 0.25rem;
  }

  .entity-badge, .category-badge, .country-badge, .province-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .entity-item, .category-item, .country-item, .province-item {
    padding: 0.375rem 0.5rem;
  }
}

/* تحسين مظهر النموذج العام */
.news-edit-form {
  font-family: 'Cairo', sans-serif;
  line-height: 1.6;
}

.news-edit-form .card {
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  border: 1px solid #e9ecef;
}

.news-edit-form .card-header {
  border-radius: 12px 12px 0 0 !important;
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
  font-weight: 600;
  padding: 1.25rem 1.5rem;
}

.news-edit-form .card-body {
  padding: 2rem 1.5rem;
}

.news-edit-form .card.mb-4 {
  margin-bottom: 2rem !important;
}

/* تحسين مظهر الأيقونات */
.news-edit-form .card-header i {
  margin-left: 0.5rem;
  opacity: 0.9;
}

/* تحسين مظهر الحقول في الشبكة */
.news-edit-form .row .col-md-6 {
  margin-bottom: 1rem;
}

.news-edit-form .row .col-md-6:last-child {
  margin-bottom: 0;
}

/* تحسين مظهر التنبيهات */
.news-edit-form .alert {
  border-radius: 8px;
  border: none;
  font-weight: 500;
}

/* تحسين مظهر الأزرار */
.news-edit-form .btn {
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.news-edit-form .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.news-edit-form .btn-success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  border: none;
}

.news-edit-form .btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  border: none;
}

.news-edit-form .btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* تحسين مظهر الحقول عند التركيز */
.news-edit-form .form-control:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
  transform: scale(1.01);
}

/* تحسين مظهر textarea */
.news-edit-form textarea.form-control {
  border-radius: 8px;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.news-edit-form textarea.form-control:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* تحسين مظهر القسم الأخير */
.news-edit-form .card:last-child {
  border-top: 4px solid #28a745;
  background: linear-gradient(135deg, #f8fff8 0%, #ffffff 100%);
}

.news-edit-form .card:last-child .card-body {
  background: linear-gradient(135deg, #f8fff8 0%, #ffffff 100%);
  border-radius: 0 0 12px 12px;
}

/* تحسين مظهر الأقسام المختلفة */
.news-edit-form .bg-primary .card-header {
  background: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%) !important;
  color: white;
}

.news-edit-form .bg-success .card-header {
  background: linear-gradient(135deg, #198754 0%, #0f5132 100%) !important;
  color: white;
}

.news-edit-form .bg-info .card-header {
  background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%) !important;
  color: white;
}

.news-edit-form .bg-warning .card-header {
  background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
  color: black;
}

.news-edit-form .bg-secondary .card-header {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
  color: white;
}

.news-edit-form .bg-dark .card-header {
  background: linear-gradient(135deg, #212529 0%, #000000 100%) !important;
  color: white;
}

/* تحسين مظهر التحكم في النماذج */
.news-edit-form .form-check {
  padding: 0.5rem 0;
}

.news-edit-form .form-check-input {
  width: 1.2rem;
  height: 1.2rem;
  margin-left: -1.5rem;
}

.news-edit-form .form-check-label {
  margin-left: 0.5rem;
  font-weight: 500;
}

/* تحسين مظهر أزرار التحكم النهائية */
.news-edit-form .card:last-child {
  border-top: 3px solid #28a745;
}

.news-edit-form .card:last-child .card-body {
  background: linear-gradient(135deg, #f8fff8 0%, #ffffff 100%);
}

/* ========================================
   DEBUGGING AND TROUBLESHOOTING
   ======================================== */

/* Visual debugging (uncomment to debug) */
/*
#news-grid {
  background: linear-gradient(90deg,
    rgba(255, 0, 0, 0.1) 0px,
    rgba(255, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent calc(100% / 3 - 1px),
    rgba(0, 255, 0, 0.1) calc(100% / 3 - 1px),
    rgba(0, 255, 0, 0.1) calc(100% / 3),
    transparent calc(100% / 3),
    transparent calc(2 * 100% / 3 - 1px),
    rgba(0, 0, 255, 0.1) calc(2 * 100% / 3 - 1px),
    rgba(0, 0, 255, 0.1) calc(2 * 100% / 3),
    transparent calc(2 * 100% / 3)
  );
}

.news-card {
  border: 2px solid red !important;
}

.news-grid-item {
  border: 2px solid blue !important;
}
*/

/* Force browser reflow to prevent layout issues */
#news-grid {
  contain: layout style paint;
}

/* Ensure no unexpected margins or padding */
* {
  box-sizing: border-box;
}

#news-grid,
#news-grid * {
  box-sizing: border-box;
}
