@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --en-red: #e93314;
  --en-red-dark: #c42810;
  --en-black: #111827;
  --en-bg: #f5f6f8;
  --en-card: #ffffff;
  --en-border: #e5e7eb;
  --en-muted: #6b7280;
  --en-success: #059669;
  --en-warning: #d97706;
  --en-draft: #6b7280;
  --en-breaking: #dc2626;
  --en-radius: 12px;
  --en-shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 8px 24px rgba(17, 24, 39, .04);
}

html, body, .app {
  font-family: 'Inter', 'Cairo', system-ui, sans-serif !important;
  background: var(--en-bg) !important;
  color: var(--en-black);
}

.app-header {
  background: #fff !important;
  border-bottom: 1px solid var(--en-border) !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}

.app-sidebar, .app-sidebar-content, #sidebar {
  background: #0f172a !important;
}

.app-sidebar .menu-link,
.app-sidebar .menu-text,
.app-sidebar .menu-header {
  color: #cbd5e1 !important;
}

.app-sidebar .menu-item.active > .menu-link,
.app-sidebar .menu-link:hover {
  background: rgba(233, 51, 20, .14) !important;
  color: #fff !important;
}

.app-sidebar .menu-item.active > .menu-link .menu-icon,
.app-sidebar .menu-item.active > .menu-link .menu-text {
  color: #fff !important;
}

.brand-logo img {
  max-height: 34px;
}

.page-header {
  font-weight: 700 !important;
  letter-spacing: -.02em;
}

.card {
  border: 1px solid var(--en-border) !important;
  border-radius: var(--en-radius) !important;
  box-shadow: var(--en-shadow) !important;
  background: var(--en-card) !important;
}

.btn-theme, .btn-primary {
  background: var(--en-red) !important;
  border-color: var(--en-red) !important;
  color: #fff !important;
  border-radius: 8px !important;
  font-weight: 600;
}

.btn-theme:hover, .btn-primary:hover {
  background: var(--en-red-dark) !important;
  border-color: var(--en-red-dark) !important;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-published { background: #d1fae5; color: var(--en-success); }
.badge-draft { background: #e5e7eb; color: var(--en-draft); }
.badge-scheduled { background: #fef3c7; color: var(--en-warning); }
.badge-breaking { background: #fee2e2; color: var(--en-breaking); }

.en-stat-card {
  border-radius: var(--en-radius);
  border: 1px solid var(--en-border);
  background: #fff;
  box-shadow: var(--en-shadow);
  padding: 1.1rem 1.2rem;
  min-height: 120px;
  position: relative;
  overflow: hidden;
}

.en-stat-card .label { color: var(--en-muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.en-stat-card .value { font-size: 2rem; font-weight: 700; margin-top: .25rem; color: var(--en-black); }
.en-stat-card .hint { color: var(--en-muted); font-size: 12px; margin-top: .35rem; }
.en-stat-card.accent-red { border-top: 3px solid var(--en-red); }
.en-stat-card.accent-green { border-top: 3px solid var(--en-success); }
.en-stat-card.accent-amber { border-top: 3px solid var(--en-warning); }
.en-stat-card.accent-slate { border-top: 3px solid #334155; }

.en-filters-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245,246,248,.92);
  backdrop-filter: blur(8px);
  padding: .75rem 0;
  margin-bottom: .75rem;
  border-bottom: 1px solid var(--en-border);
}

.table-container {
  overflow-x: auto;
}

#datatableDefault thead th {
  background: #f8fafc !important;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

#datatableDefault tbody tr:hover {
  background: #fff7f5 !important;
}

.article-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  background: #e5e7eb;
}

.en-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--en-muted);
}

.en-empty-state i { font-size: 2rem; color: var(--en-red); margin-bottom: .75rem; }

#en-global-loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .28);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

#en-global-loader.show { display: flex; }

#en-global-loader .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #fff;
  border-top-color: var(--en-red);
  border-radius: 50%;
  animation: en-spin .8s linear infinite;
}

@keyframes en-spin { to { transform: rotate(360deg); } }

.en-toast-wrap {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 360px;
}

.en-toast {
  background: #111827;
  color: #fff;
  padding: .75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--en-shadow);
  font-size: 14px;
  animation: en-slide .2s ease;
}

.en-toast.success { background: var(--en-success); }
.en-toast.error { background: var(--en-breaking); }
.en-toast.info { background: #1e293b; }

@keyframes en-slide {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.media-grid-item {
  position: relative;
  border: 1px solid var(--en-border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  aspect-ratio: 1;
}

.media-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-grid-item:hover {
  outline: 2px solid var(--en-red);
}

.media-grid-item .name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  color: #fff;
  font-size: 11px;
  padding: 1.2rem .4rem .35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .en-filters-sticky { position: static; }
  .en-stat-card .value { font-size: 1.5rem; }
  .table-container { margin: 0 -0.5rem; }
  .en-sticky-save-bar { flex-wrap: wrap; gap: .5rem; }
  .en-header-center { display: none !important; }
  .en-header-right { gap: .5rem; }
  .en-header-user-text { display: none; }
}
.en-form-hint {
  font-size: 12px;
  color: var(--en-muted);
  margin-top: .25rem;
}
.en-arabic-section .form-control,
.en-arabic-section .note-editor { direction: rtl; text-align: right; }
.en-arabic-badge {
  display: inline-block;
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: .5rem;
  font-weight: 600;
}

/* Sticky save bar */
.en-sticky-save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--en-border);
  backdrop-filter: blur(8px);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.app-content { padding-bottom: 5rem !important; }
.en-sticky-save-bar .hint { color: var(--en-muted); font-size: 13px; }
.en-sticky-save-bar kbd {
  background: #f1f5f9;
  border: 1px solid var(--en-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}

/* Media picker modals above sticky save bar */
.modal { z-index: 1060 !important; }
.modal-backdrop { z-index: 1055 !important; }

/* Category picker (legacy container) */
.en-category-toolbar .form-check { margin-bottom: .35rem; }

/* Dashboard stat loading */
.en-stat-card.is-loading .value { opacity: .5; }
.en-stat-skeleton {
  display: inline-block;
  width: 60px;
  height: 28px;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: en-shimmer 1.2s infinite;
  border-radius: 6px;
}
@keyframes en-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Publishing toggles grid */
.en-toggle-grid .row { padding: .35rem 0; }
.en-toggle-grid hr { margin: .35rem 0; opacity: .15; }
.en-toggle-grid .form-check-input {
  width: 2.5rem;
  height: 1.25rem;
  cursor: pointer;
}
.en-toggle-grid .form-check-input:checked {
  background-color: var(--en-red) !important;
  border-color: var(--en-red) !important;
}
.en-toggle-grid .row:hover { background: #fafafa; border-radius: 8px; }

/* Media preview grid (article forms) */
#selectedImagesPreview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}
#selectedImagesPreview .image-preview {
  position: relative;
  aspect-ratio: 1;
}
#selectedImagesPreview .image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
#selectedImagesPreview .remove-file {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  font-size: 12px;
}
#thumbnailPreview {
  max-width: 160px;
  border-radius: 8px;
  margin-top: .5rem;
  border: 1px solid var(--en-border);
}

/* Filter chips */
.en-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .65rem;
  background: #fff;
  border: 1px solid var(--en-border);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.en-filter-chip:has(input:checked) {
  border-color: var(--en-red);
  background: rgba(233, 51, 20, .06);
}
.en-filter-chip input {
  margin: 0;
  accent-color: var(--en-red);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Category articles tab */
.en-category-articles-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: .75rem;
  background: #f8fafc;
  border-radius: var(--en-radius);
  border: 1px solid var(--en-border);
}

/* ===== Header layout (fix cramped spacing) ===== */
.en-app-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem !important;
  padding: 0 1.25rem !important;
  min-height: 60px !important;
}
.en-app-header .menu { display: contents !important; }
.en-header-left {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.en-header-left .brand { display: flex; align-items: center; }
.en-header-left .brand-logo { padding: .25rem 0 !important; margin-right: .5rem; }
.en-header-center {
  flex: 1 1 auto;
  max-width: 420px;
  min-width: 180px;
}
.en-header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
  margin-left: auto;
}
.en-header-search {
  position: relative;
  width: 100%;
}
.en-header-search .en-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--en-muted);
  font-size: 13px;
  pointer-events: none;
  z-index: 2;
}
.en-header-search input {
  width: 100%;
  padding: .5rem 1rem .5rem 2.25rem !important;
  border: 1px solid var(--en-border) !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  background: #f8fafc !important;
  height: 38px;
}
.en-header-search input:focus {
  background: #fff !important;
  border-color: rgba(233, 51, 20, .45) !important;
  box-shadow: 0 0 0 3px rgba(233, 51, 20, .1) !important;
}
.en-header-quicklinks { gap: .5rem !important; }
.en-header-divider {
  width: 1px;
  height: 28px;
  background: var(--en-border);
}
.en-header-user {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .4rem .85rem;
  background: #f8fafc;
  border: 1px solid var(--en-border);
  border-radius: 10px;
}
.en-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(233, 51, 20, .1);
  color: var(--en-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.en-header-user-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.en-header-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--en-black);
}
.en-header-user .role-badge {
  align-self: flex-start;
  background: rgba(233, 51, 20, .1);
  color: var(--en-red);
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.en-logout-btn {
  border-radius: 10px !important;
  padding: .45rem .75rem !important;
  white-space: nowrap;
}

/* ===== Sidebar spacing & active state ===== */
.app-sidebar .menu { padding: .75rem 0 1.5rem !important; }
.app-sidebar .menu-header {
  padding: 1rem 1.25rem .5rem !important;
  font-size: 11px !important;
  letter-spacing: .08em !important;
  text-transform: uppercase !important;
  opacity: .55 !important;
}
.app-sidebar .menu-divider {
  margin: .65rem 1rem !important;
  border-color: rgba(255,255,255,.08) !important;
}
.app-sidebar .menu-item { margin: 2px .65rem !important; }
.app-sidebar .menu-link {
  padding: .72rem 1rem !important;
  border-radius: 10px !important;
  gap: .65rem !important;
  transition: background .15s ease, color .15s ease;
}
.app-sidebar .menu-icon {
  width: 34px !important;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 8px !important;
  background: rgba(255,255,255,.06) !important;
  font-size: 15px !important;
}
.app-sidebar .menu-item.active > .menu-link {
  background: rgba(233, 51, 20, .18) !important;
  box-shadow: inset 3px 0 0 var(--en-red);
}
.app-sidebar .menu-item.active > .menu-link .menu-icon {
  background: rgba(233, 51, 20, .25) !important;
  color: #fff !important;
}
.app-sidebar .menu-link:hover .menu-icon {
  background: rgba(255,255,255,.12) !important;
}
.app-sidebar .menu-text { font-size: 14px !important; font-weight: 500 !important; }

/* ===== Article tab steps ===== */
.en-article-tabs {
  display: flex;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--en-border);
  border-radius: var(--en-radius);
  padding: .35rem;
  gap: .35rem;
  margin-bottom: 1.25rem;
  border-bottom: none;
}
.en-article-tabs .nav-item { flex: 1 1 auto; min-width: 120px; }
.en-article-tabs .nav-link {
  width: 100%;
  text-align: center;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  margin-bottom: 0 !important;
  border-bottom: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .7rem .85rem !important;
}
.en-article-tabs .nav-link.active {
  background: var(--en-red) !important;
  color: #fff !important;
  border-color: var(--en-red) !important;
  box-shadow: 0 2px 8px rgba(233, 51, 20, .25);
}
.en-article-tabs .nav-link.active .en-tab-step {
  background: rgba(255,255,255,.25);
  color: #fff;
}
.en-article-tabs .nav-link.is-complete:not(.active) {
  color: var(--en-success);
  background: rgba(5, 150, 105, .08);
}
.en-tab-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== Category search chips (article form) ===== */
.en-category-toolbar {
  background: #f8fafc;
  border: 1px solid var(--en-border);
  border-radius: 10px;
  padding: .85rem;
  margin-bottom: .85rem;
}
.en-category-toolbar #categorySearchInput {
  border-radius: 8px;
  padding: .55rem .85rem;
  border: 1px solid var(--en-border);
  background: #fff;
}
.en-category-toolbar #categorySearchInput:focus {
  border-color: rgba(233, 51, 20, .4);
  box-shadow: 0 0 0 3px rgba(233, 51, 20, .08);
}
.en-category-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .5rem;
  max-height: 320px !important;
  padding: .65rem !important;
  background: #fff !important;
}
.en-category-chip {
  position: relative;
  margin: 0 !important;
  padding: .65rem .75rem .65rem 2.35rem !important;
  border: 1.5px solid var(--en-border) !important;
  border-radius: 10px !important;
  background: #fafafa;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  user-select: none;
}
.en-category-chip:hover {
  border-color: rgba(233, 51, 20, .35) !important;
  background: #fff;
}
.en-category-chip.is-selected {
  border-color: var(--en-red) !important;
  background: rgba(233, 51, 20, .06) !important;
  box-shadow: 0 0 0 1px rgba(233, 51, 20, .15);
}
.en-category-chip .form-check-input {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.1rem;
  height: 1.1rem;
  margin: 0 !important;
  border: 2px solid #cbd5e1;
  cursor: pointer;
}
.en-category-chip .form-check-input:checked {
  background-color: var(--en-red) !important;
  border-color: var(--en-red) !important;
}
.en-category-chip .form-check-label {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  padding-left: 0 !important;
  color: var(--en-black);
}
.en-category-chip.is-selected .form-check-label {
  color: var(--en-red-dark);
  font-weight: 600;
}
#categorySelectedCount {
  font-weight: 600;
  color: var(--en-red);
}

/* ===== Bool badges (categories etc.) ===== */
.en-bool-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.en-bool-yes { background: #d1fae5; color: #047857; }
.en-bool-no { background: #f1f5f9; color: #64748b; }

/* ===== Admin list tables (categories, settings) ===== */
.en-admin-table thead th {
  background: #f8fafc !important;
  color: #475569 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  padding: .85rem 1rem !important;
  border-bottom: 1px solid var(--en-border) !important;
  white-space: nowrap;
}
.en-admin-table tbody td {
  padding: .85rem 1rem !important;
  vertical-align: middle !important;
  border-bottom: 1px solid #f1f5f9 !important;
}
.en-admin-table tbody tr:hover { background: #fff7f5 !important; }
.en-admin-table .en-order-badge {
  display: inline-flex;
  min-width: 2rem;
  justify-content: center;
  padding: .2rem .5rem;
  background: #f1f5f9;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
}
.en-settings-name {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 600;
  color: var(--en-black);
}
.en-settings-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(233, 51, 20, .08);
  color: var(--en-red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.en-settings-value {
  color: var(--en-muted);
  font-size: 13px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.en-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.en-list-toolbar .form-control,
.en-list-toolbar .form-select {
  max-width: 280px;
  border-radius: 10px;
}

