/* ===== تصميم UI – تطبيق حرفي من مجلد ui ===== */
/* متوافق مع الهوية الإماراتية (#0A2240, #977124, #364B9B) */

:root {
  --ui-primary: #0A2240;
  --ui-primary-light: #364B9B;
  --ui-accent: #977124;
  --ui-surface-card: var(--materio-paper, #fff);
  --ui-text-color: var(--materio-text, #1a1d21);
  --ui-text-secondary: var(--materio-text-muted, #717474);
  --ui-title-gradient: linear-gradient(90deg, var(--ui-primary) -130.03%, var(--ui-surface-card) 36.54%);
  --layout-section-transition-duration: 0.2s;
}

/* ===== الشريط العلوي – تصميم محدّث ===== */
.layout-navbar {
  block-size: 4.5rem !important;
  min-height: 4.5rem !important;
  padding: 0 1.5rem !important;
  background: linear-gradient(180deg, var(--ui-surface-card) 0%, rgba(255, 255, 255, 0.98) 100%) !important;
  box-shadow: 0 2px 12px rgba(10, 34, 64, 0.06), 0 1px 0 rgba(10, 34, 64, 0.04) !important;
  border-bottom: 1px solid rgba(10, 34, 64, 0.06) !important;
  overflow: visible !important;
}

.navbar-inner,
.navbar-actions,
.user-menu-wrapper,
.theme-configurator-wrapper {
  overflow: visible !important;
  position: relative;
  z-index: 100;
}

.theme-palette-btn,
.user-menu-btn {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* لا نضيف padding-top للـ layout-page لأن الهيدر sticky وليس fixed - كان يسبب فراغاً أبيض فوق الهيدر */

.layout-page {
  overflow: visible !important;
}

/* منع القائمة الجانبية من اعتراض النقرات عند إغلاقها (موبايل فقط) */
@media (max-width: 1199.98px) {
  .layout-menu.menu-vertical:not(.show) {
    pointer-events: none !important;
  }
}

/* رفع z-index للهيدر ليكون فوق المحتوى */
.layout-navbar {
  z-index: 1000 !important;
}

/* هيكل الهيدر الداخلي */
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1.25rem;
  min-width: 0;
  flex-wrap: nowrap;
}

/* قسم الشعار والعنوان */
.navbar-brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex-shrink: 0;
}

.navbar-menu-toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 0.75rem;
  border: 1px solid rgba(10, 34, 64, 0.12);
  background: rgba(10, 34, 64, 0.04);
  color: var(--ui-primary);
  transition: all 0.2s ease;
}

.navbar-menu-toggle:hover {
  background: rgba(10, 34, 64, 0.08);
  border-color: rgba(10, 34, 64, 0.2);
}

.navbar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  padding: 0.4rem 0.875rem;
  border-radius: 1rem;
  background: var(--ui-primary);
  transition: background 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.navbar-brand-link:hover {
  background: rgba(10, 34, 64, 0.92);
  transform: translateY(-1px);
}

.navbar-brand-logo {
  height: 2rem;
  width: auto;
  max-width: 6rem;
  object-fit: contain;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.navbar-brand-text {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 10rem;
}

/* مركز الهيدر – عنوان الصفحة */
.navbar-center {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.navbar-page-title-wrapper {
  padding: 0.4rem 0.875rem;
  border-inline-start: 3px solid var(--ui-primary);
  border-radius: 0 0.5rem 0.5rem 0;
  background: rgba(10, 34, 64, 0.03);
  max-width: 100%;
  overflow: hidden;
}

[dir="rtl"] .navbar-page-title-wrapper {
  border-inline-start: none;
  border-inline-end: 3px solid var(--ui-primary);
  border-radius: 0.5rem 0 0 0.5rem;
}

.navbar-page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ui-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* منطقة الإجراءات */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
}

.navbar-action-buttons {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.navbar-action-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ui-text-secondary);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.navbar-action-btn:hover {
  background: rgba(10, 34, 64, 0.06);
  color: var(--ui-primary);
  border-color: rgba(10, 34, 64, 0.1);
}

.navbar-action-btn .bi {
  font-size: 1.25rem;
}

/* ThemeConfigurator داخل الهيدر */
.navbar-action-buttons .theme-configurator-wrapper .theme-palette-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ui-text-secondary);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.navbar-action-buttons .theme-configurator-wrapper .theme-palette-btn:hover {
  background: rgba(10, 34, 64, 0.06);
  color: var(--ui-primary);
}

.navbar-action-buttons .theme-configurator-wrapper .theme-palette-btn .bi {
  font-size: 1.25rem;
}

/* إخفاء نص "الألوان" في الهيدر – عرض الأيقونة فقط لتوفير المساحة */
.navbar-action-buttons .theme-configurator-wrapper .theme-palette-btn span:not(.bi) {
  display: none !important;
}

.navbar-action-separator {
  width: 1px;
  height: 1.5rem;
  background: rgba(10, 34, 64, 0.12);
  flex-shrink: 0;
}

/* إخفاء عنوان الصفحة على الشاشات المتوسطة لتجنب التداخل */
@media (min-width: 992px) and (max-width: 1199px) {
  .navbar-center {
    display: none;
  }
}

/* زر قائمة المستخدم */
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.625rem 0.3rem 0.875rem;
  border-radius: 2rem;
  border: 1px solid rgba(10, 34, 64, 0.12);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ui-text-color);
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(10, 34, 64, 0.04);
  flex-shrink: 0;
}

.user-menu-btn:hover {
  background: #fff;
  border-color: rgba(10, 34, 64, 0.18);
  box-shadow: 0 2px 8px rgba(10, 34, 64, 0.08);
}

.user-avatar .bi {
  font-size: 1.5rem;
  color: var(--ui-primary);
  flex-shrink: 0;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  text-align: right;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ui-text-color);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
}

.user-role {
  font-size: 0.6875rem;
  color: var(--ui-text-secondary);
  font-weight: 500;
}

.user-chevron {
  font-size: 0.625rem;
  color: var(--ui-text-secondary);
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.user-menu-wrapper {
  position: relative;
}


/* القائمة المنسدلة للمستخدم */
.user-dropdown {
  position: fixed !important;
  top: 4.5rem !important;
  inset-inline-end: 1rem !important;
  inset-inline-start: auto !important;
  min-width: 260px;
  background: #fff;
  border: 1px solid rgba(10, 34, 64, 0.1);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(10, 34, 64, 0.12), 0 2px 8px rgba(10, 34, 64, 0.06);
  z-index: 9999;
  animation: userDropdownFade 0.2s ease-out;
  overflow: hidden;
  display: none !important;
}

.user-dropdown.show {
  display: block !important;
}

.user-dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: transparent;
  cursor: default;
  display: none !important;
}

.user-dropdown-backdrop.show {
  display: block !important;
}

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

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(10, 34, 64, 0.04) 0%, transparent 100%);
}

.user-dropdown-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--ui-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-dropdown-avatar .bi {
  font-size: 1.5rem;
}

.user-dropdown-info {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.user-dropdown-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ui-text-color);
  line-height: 1.3;
}

.user-dropdown-role {
  font-size: 0.8125rem;
  color: var(--ui-text-secondary);
  margin-top: 0.125rem;
}

.user-dropdown-divider {
  height: 1px;
  background: rgba(10, 34, 64, 0.08);
  margin: 0 1rem;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem;
  color: var(--ui-text-color);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  cursor: pointer;
  transition: background 0.15s ease;
}

.user-dropdown-item:hover {
  background: rgba(10, 34, 64, 0.06);
}

.user-dropdown-item.text-danger {
  color: var(--materio-danger, #7a2530);
}

.user-dropdown-item.text-danger:hover {
  background: rgba(122, 37, 48, 0.08);
}

.user-dropdown-item .bi {
  font-size: 1.125rem;
  opacity: 0.85;
}

/* موبايل */
@media (max-width: 991px) {
  .navbar-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .navbar-brand-text {
    display: none !important;
  }

  .navbar-page-title-wrapper {
    display: none;
  }

  .navbar-center {
    flex: none;
  }

  .layout-navbar {
    background: var(--ui-primary) !important;
    padding: 0 1rem !important;
  }

  .navbar-brand-link {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.4rem 0.75rem;
  }

  .navbar-brand-link:hover {
    background: rgba(255, 255, 255, 0.22);
  }

  .navbar-brand-logo {
    filter: brightness(0) invert(1);
  }

  .navbar-action-btn,
  .navbar-action-buttons .theme-configurator-wrapper .theme-palette-btn {
    color: rgba(255, 255, 255, 0.9) !important;
  }

  .navbar-action-btn:hover,
  .navbar-action-buttons .theme-configurator-wrapper .theme-palette-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
  }

  .navbar-action-separator {
    background: rgba(255, 255, 255, 0.25);
  }

  .user-menu-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
  }

  .user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
  }

  .user-avatar .bi {
    color: rgba(255, 255, 255, 0.95);
  }

  .user-name,
  .user-role {
    color: rgba(255, 255, 255, 0.95);
  }

  .user-chevron {
    color: rgba(255, 255, 255, 0.8);
  }
}

@media (max-width: 576px) {
  .navbar-action-buttons .navbar-action-btn {
    display: none;
  }
}


/* ===== الشريط الجانبي – ضيق قليلاً (secondary-color, border-radius, menu pills) ===== */
.layout-menu.menu-vertical {
  background-color: var(--ui-primary) !important;
  border-inline-end: none !important;
  width: 18rem !important;
  min-height: 90vh !important;
  border-radius: 0 0 1.25rem 1.25rem !important;
  box-shadow: 0 4px 14px rgba(10, 34, 64, 0.15) !important;
}

.menu .app-brand {
  border-bottom-color: rgba(255, 255, 255, 0.15) !important;
  padding: 0.875rem 1rem !important;
}

.menu .app-brand .app-brand-logo-img {
  filter: brightness(0) invert(1);
}

.menu .app-brand .app-brand-link {
  color: rgba(255, 255, 255, 0.95);
}

.menu-inner {
  padding: 0.75rem 0.875rem 0 0.875rem !important;
}

.menu-item .menu-link {
  color: rgba(255, 255, 255, 0.9) !important;
  border-radius: 50px !important;
  padding: 0.45rem 0.75rem !important;
  margin: 0.125rem 0.375rem !important;
  font-size: 0.9375rem !important;
}

.menu-item .menu-link:hover,
.menu-item .menu-link:focus {
  color: #fff !important;
  background-color: rgba(54, 74, 155, 0.5) !important;
}

.menu-item.active .menu-link,
.menu-item .menu-link.active {
  background: var(--ui-primary-light) !important;
  color: #fff !important;
  font-weight: 700 !important;
}

.menu-header {
  padding: 0.75rem 1rem 0.25rem !important;
}

.menu-header .menu-header-text {
  color: rgba(255, 255, 255, 0.6) !important;
  font-size: 0.857rem !important;
  text-transform: uppercase !important;
  font-weight: 700 !important;
}

/* ===== منطقة المحتوى الرئيسي – padding 9.25rem 2rem كما في UI ===== */
.layout-page .content-wrapper {
  padding: 0 2rem 2rem !important;
}

.container-xxl {
  padding-inline: 2rem !important;
}

@media (min-width: 992px) {
  .container-xxl {
    padding-inline: 2rem !important;
  }
}

/* ===== حاوية الجداول – border-radius 24px ===== */
.data-table-container {
  background: var(--ui-surface-card);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--materio-border, rgba(10, 34, 64, 0.08));
  box-shadow: var(--materio-shadow-sm, 0 1px 3px rgba(10, 34, 64, 0.06));
}

.data-table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 34, 64, 0.3) var(--ui-surface-card);
  padding: 0.25rem;
}

.data-table-scroll::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.data-table-scroll::-webkit-scrollbar-track {
  background: var(--ui-surface-card);
}

.data-table-scroll::-webkit-scrollbar-thumb {
  background: rgba(10, 34, 64, 0.4);
  border-radius: 4px;
}

/* ===== جدول البيانات – رأس بلون primary وزوايا 20px ===== */
.data-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--ui-primary);
}

.data-table th {
  padding: 14px 12px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: #fff;
  white-space: nowrap;
  text-align: right;
}

[dir="rtl"] .data-table th {
  text-align: right !important;
}

/* زوايا رأس الجدول – مطابقة لـ UI مع دعم RTL */
.data-table thead th:first-child {
  border-start-start-radius: 20px;
  border-end-start-radius: 20px;
}

.data-table thead th:last-child {
  border-start-end-radius: 20px;
  border-end-end-radius: 20px;
}

[dir="rtl"] .data-table thead th:first-child {
  border-top-left-radius: 0;
  border-top-right-radius: 20px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 20px;
}

[dir="rtl"] .data-table thead th:last-child {
  border-top-left-radius: 20px;
  border-top-right-radius: 0;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 0;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(10, 34, 64, 0.12);
  transition: background-color 0.12s ease;
}

.data-table tbody tr:hover {
  background: rgba(10, 34, 64, 0.04);
}

.data-table tbody tr > td {
  padding: 1rem;
  white-space: nowrap;
  color: var(--ui-text-color);
  text-align: right;
}

/* ===== أزرار الإجراءات – pill style (border-radius 60px) ===== */
.btn-action-add,
.btn-action-filter,
.btn-action-search {
  border-radius: 60px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 50px;
  flex: 1 1 0%;
  border: 1px solid rgba(22, 22, 22, 0.4);
  font-weight: 500;
  color: var(--ui-text-color);
  font-size: 0.875rem;
  line-height: 1.25;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  padding: 0.5rem 1rem;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
}

.btn-action-add:hover,
.btn-action-filter:hover,
.btn-action-search:hover {
  background: rgba(10, 34, 64, 0.06);
  border-color: var(--ui-primary);
  color: var(--ui-primary);
}

.btn-action-add.primary,
.btn-action-add.btn-primary,
a.btn-action-add.primary {
  background: var(--ui-primary);
  color: #fff;
  border-color: var(--ui-primary);
}

.btn-action-add.primary:hover,
a.btn-action-add.primary:hover {
  background: rgba(10, 34, 64, 0.9);
  color: #fff;
  border-color: var(--ui-primary);
}

@media (min-width: 640px) {
  .btn-action-add,
  .btn-action-filter,
  .btn-action-search {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 11px;
    padding-bottom: 11px;
  }
}

@media (min-width: 1536px) {
  .btn-action-add,
  .btn-action-filter,
  .btn-action-search {
    font-size: 1rem;
    line-height: 1.25;
    padding-top: 14px;
    padding-bottom: 14px;
  }
}

/* ===== حقل البحث – pill style ===== */
.search-input {
  width: 100%;
  height: 50px;
  padding: 10px 16px 10px 46px;
  border: 1px solid rgba(22, 22, 22, 0.4);
  border-radius: 60px;
  font-weight: 500;
  color: var(--ui-text-color);
  background-color: transparent;
  font-size: 0.875rem;
  line-height: 1.25;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

[dir="rtl"] .search-input {
  padding: 10px 46px 10px 16px;
}

.search-input:focus {
  border-color: var(--ui-primary);
  box-shadow: 0 0 0 3px rgba(10, 34, 64, 0.1);
  outline: none;
}

@media (min-width: 1280px) {
  .search-input {
    font-size: 1rem;
    line-height: 1.25;
  }
}

/* ===== تدرج العنوان – للفلتر والنوافذ المنبثقة ===== */
.bg-title-gradient {
  background: var(--ui-title-gradient);
}

/* ===== فاصل عمودي بين الأزرار ===== */
.action-separator {
  width: 2px;
  height: 14px;
  background: var(--ui-primary);
  flex-shrink: 0;
  margin-inline: 0.25rem;
}

/* ===== تطبيق data-table على AppTable عند استخدام data-table-wrapper ===== */
.data-table-wrapper .table,
.data-table-wrapper .materio-table {
  border: none !important;
  margin: 0 !important;
}

.data-table-wrapper .table thead th,
.data-table-wrapper .materio-table thead th {
  background: var(--ui-primary) !important;
  color: #fff !important;
  border: none !important;
  padding: 14px 12px !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
}

.data-table-wrapper .table tbody td,
.data-table-wrapper .materio-table tbody td {
  padding: 1rem !important;
}

.data-table-wrapper .table tbody tr,
.data-table-wrapper .materio-table tbody tr {
  border-bottom: 1px solid rgba(10, 34, 64, 0.12) !important;
}

.data-table-wrapper .table tbody tr:hover,
.data-table-wrapper .materio-table tbody tr:hover {
  background: rgba(10, 34, 64, 0.04) !important;
}

/* ===== أزرار الجداول الدائرية ===== */
.btn-table-action {
  min-width: 2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-table-action.primary {
  background: var(--ui-primary);
  color: #fff;
  border: none;
}

.btn-table-action.primary:hover {
  background: rgba(10, 34, 64, 0.9);
  color: #fff;
}

.btn-table-action.outline {
  background: rgba(10, 34, 64, 0.2);
  color: var(--ui-primary);
  border: none;
}

.btn-table-action.outline:hover {
  background: rgba(10, 34, 64, 0.3);
}

@media (min-width: 1536px) {
  .btn-table-action {
    min-width: 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ===== صفحة القائمة – تخطيط الرأس مطابق لـ UI ===== */
.page-list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
}

@media (min-width: 1536px) {
  .page-list-header {
    padding: 1.5rem 0;
  }
}

.page-list-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .page-list-actions {
    gap: 1rem;
  }
}

/* ===== عنوان الصفحة – خط عريض بلون primary كما في UI ===== */
.page-title.materio-page-title,
h1.page-title {
  font-size: 2rem !important;
  font-weight: 700 !important;
  color: var(--ui-primary) !important;
}

@media (min-width: 1536px) {
  .page-title.materio-page-title,
  h1.page-title {
    font-size: 2rem !important;
  }
}

/* ===== البطاقات – زوايا 24px وظل ناعم ===== */
.card.materio-card {
  border-radius: 1.5rem !important;
  box-shadow: 0 1px 3px rgba(10, 34, 64, 0.06) !important;
}

.card.materio-card .card-header {
  border-radius: 1.5rem 1.5rem 0 0 !important;
}

/* ===== أزرار الفلتر داخل البطاقة – pill style ===== */
.filter-buttons-rtl .btn,
.page-filter-card .btn {
  border-radius: 1.125rem !important;
  font-weight: 600 !important;
  padding: 0.5rem 1.25rem !important;
}
