:root {
  --farm-ui-accent: #1b4332;
  --farm-ui-accent-dark: #081c15;
  --farm-ui-accent-soft: #d8f3dc;
  --farm-ui-golden: #d4a373;
  --farm-ui-earth: #faedcd;
  --farm-ui-text: #1f2937;
  --farm-ui-muted: #6b7280;
  --farm-ui-border: #e4e9f1;
  --farm-ui-border-strong: #d8e2ee;
  --farm-ui-surface: #ffffff;
  --farm-ui-surface-soft: #f7fafc;
  --farm-ui-sidebar: #fbfcfd;
  --farm-ui-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
}

body {
  font-family: 'Tajawal', 'Cairo', sans-serif;
  background:
    radial-gradient(circle at top, rgba(27, 67, 50, 0.05), transparent 28%),
    linear-gradient(180deg, #fdfefd 0%, #f4f7f4 100%);
  color: var(--farm-ui-text);
}

[dir="rtl"] body {
  direction: rtl;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(1px);
  display: none;
  z-index: 1030;
}

.overlay.show {
  display: block;
}

.sidebar {
  width: 268px;
  background: var(--farm-ui-sidebar);
  transition: width 0.3s, left 0.3s, right 0.3s;
  border-right: 1px solid var(--farm-ui-border);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  padding-top: 92px;
  z-index: 1030;
  overflow-y: auto;
  scrollbar-width: thin;
}

[dir="rtl"] .sidebar {
  left: auto !important;
  right: 0 !important;
  border-right: 0;
  border-left: 1px solid var(--farm-ui-border);
}

.sidebar .logo-area {
  position: absolute;
  top: 0;
  left: 0;
  right: auto;
  height: 92px;
  width: 100%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 18px 14px;
  color: var(--farm-ui-text);
  border-bottom: 1px solid var(--farm-ui-border);
}

.sidebar-brand {
  max-width: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--farm-ui-text);
  padding: 10px 12px;
  border-radius: 18px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.sidebar-brand:hover {
  background: rgba(17, 163, 106, 0.05);
  transform: translateY(-1px);
}

.sidebar-brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #e8edf4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
  flex: 0 0 50px;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-brand-text strong {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--farm-ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-text small {
  font-size: 0.75rem;
  color: var(--farm-ui-accent);
  margin-top: 2px;
}

.sidebar-brand-logo {
  max-width: 38px;
  max-height: 38px;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

[dir="rtl"] .sidebar .logo-area {
  left: auto !important;
  right: 0 !important;
  padding-left: 16px;
  padding-right: 16px;
}

.sidebar .nav {
  padding: 14px 12px 20px;
  gap: 4px;
}

.sidebar .nav-link {
  color: #5f6f82;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.98rem;
  font-weight: 600;
  gap: 12px;
  white-space: nowrap;
  margin: 0;
  width: 100%;
  overflow: hidden; /* Restored to prevent rendering glitches like stray brackets */
  text-align: right;
  box-sizing: border-box;
  border: none !important;
  border-radius: 0 !important;
}

.sidebar-nav-form {
  width: 100%;
}

.sidebar-nav-form .nav-link {
  cursor: pointer;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  color: var(--farm-ui-accent);
  background-color: #ffffff;
  border-color: #e7eef5;
  transition: all 0.2s ease-in-out;
}

.collapse {
  transition: height 0.3s ease-in-out !important;
}

.sidebar .nav-link .ti {
  font-size: 20px;
  flex: 0 0 20px;
}

.sidebar .nav-text,
.logo-text {
  transition: opacity 0.2s;
}

.sidebar .nav-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sidebar.collapsed {
  width: 78px;
}

.sidebar.collapsed .logo-area {
  height: 78px;
  padding: 12px 8px;
}

.sidebar.collapsed {
  padding-top: 78px;
}

.sidebar.collapsed .nav-link {
  margin: 0;
  background-color: transparent;
  padding: 8px 0;
  width: 100%;
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-chevron,
.sidebar.collapsed .collapse {
  display: none !important;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.sidebar.collapsed .sidebar-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.sidebar.collapsed .sidebar-brand-logo {
  max-width: 28px;
  max-height: 28px;
  width: 28px;
  height: 28px;
}

.topbar {
  height: 78px;
  margin-left: 268px;
  background: rgba(255, 255, 255, 0.88) !important;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--farm-ui-border) !important;
}

[dir="rtl"] .topbar {
  margin-left: 0;
  margin-right: 268px;
  direction: rtl;
}

.topbar.full {
  margin-left: 78px;
}

[dir="rtl"] .topbar.full {
  margin-left: 0;
  margin-right: 78px;
}

.content {
  margin-left: 268px;
  padding-top: 102px !important;
  padding-bottom: 2rem !important;
}

[dir="rtl"] .content {
  margin-left: 0;
  margin-right: 268px;
  direction: rtl;
}

.content.full {
  margin-left: 78px;
}

[dir="rtl"] .content.full {
  margin-left: 0;
  margin-right: 78px;
}

.avatar {
  position: relative;
  display: inline-block;
  width: 3rem;
  height: 3rem;
}

.avatar-sm {
  width: 2rem;
  height: 2rem;
}

.avatar-md {
  width: 2.5rem;
  height: 2.5rem;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-icon {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  font-size: 0.92969rem;
  font-weight: 400;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
}

.btn-icon.btn-sm {
  font-size: 0.875rem;
  width: 2.1875rem;
  height: 2.1875rem;
}

.topbar-back-btn {
  min-height: 46px;
  padding: 0.7rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--farm-ui-border-strong);
  background: #ffffff;
  color: #52627d;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.topbar-back-btn {
  display: none !important;
}

.admin-page-back {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 40px;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  border: 1px solid #cfd8ea;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: #4a67a1;
  box-shadow: 0 10px 24px rgba(65, 84, 128, 0.08);
  transition: all 0.2s ease;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.88rem;
  direction: rtl;
}

.admin-page-back:hover {
  background: linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
  color: #2f4d8f;
  border-color: #b9c9e7;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(65, 84, 128, 0.12);
}

.admin-page-back .ti {
  font-size: 1.1rem;
}

[dir="rtl"] .admin-page-back .ti {
  transform: scaleX(-1);
}

.admin-page-back-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  direction: ltr;
}

.admin-page-back-wrap .btn {
  min-height: 40px;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(65, 84, 128, 0.08);
}

.admin-page-header {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 1rem !important;
  margin-bottom: 1.25rem !important;
}

.admin-page-header-main {
  min-width: 0;
  margin-inline-end: auto !important;
}

.admin-table-card {
  overflow: hidden;
}

.admin-table-card .admin-table-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 1.35rem 1.35rem 0.35rem;
  margin-bottom: 0.35rem;
  direction: ltr;
}

.admin-table-card .admin-table-card-toolbar .btn,
.admin-table-card .admin-table-card-toolbar a {
  min-height: 46px;
  padding: 0.75rem 1.2rem;
  border-radius: 16px;
  font-weight: 700;
}

.admin-table-card .admin-table-card-toolbar .btn.btn-icon,
.admin-table-card .admin-table-card-toolbar a.btn.btn-icon {
  width: auto;
  height: auto;
  min-width: 140px;
  padding: 0.8rem 1.35rem;
  justify-content: center;
  border-radius: 14px;
}

.admin-table-card .admin-table-card-toolbar .btn.btn-icon .ti,
.admin-table-card .admin-table-card-toolbar a.btn.btn-icon .ti {
  font-size: 1.05rem;
}

.btn.btn-iconized,
a.btn.btn-iconized {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  box-shadow: none;
}

.btn.btn-iconized .ti,
a.btn.btn-iconized .ti {
  font-size: 0.95rem;
}

.table td .d-flex.justify-content-center.gap-1,
.table td .d-inline-flex.gap-2 {
  gap: 0.45rem !important;
  flex-wrap: nowrap;
}

.table td .btn.btn-sm,
.table td a.btn.btn-sm {
  min-height: 38px;
  min-width: 38px;
  border-radius: 10px;
  padding: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
}

.table td .btn-outline-primary,
.table td .btn-outline-info,
.table td .btn-outline-danger,
.table td .btn-outline-warning,
.table td .btn-outline-secondary {
  background: #fff;
  border-width: 1px;
}

.table td .btn-outline-primary {
  color: #0c8a59;
  border-color: #bfe7d2;
}

.table td .btn-outline-primary:hover {
  background: #edf9f3;
  color: #0c8a59;
  border-color: #9bdec0;
}

.table td .btn-outline-info {
  color: #2563eb;
  border-color: #cfe0ff;
}

.table td .btn-outline-info:hover {
  background: #f4f8ff;
  color: #2563eb;
  border-color: #b8d0fb;
}

.table td .btn-outline-danger {
  color: #dc2626;
  border-color: #f3c5c5;
}

.table td .btn-outline-danger:hover {
  background: #fff5f5;
  color: #dc2626;
  border-color: #eaa5a5;
}

.table td .btn-outline-warning {
  color: #b7791f;
  border-color: #f5ddb4;
}

.table td .btn-outline-warning:hover {
  background: #fff8ec;
  color: #b7791f;
  border-color: #efcf93;
}

.table td .btn-outline-secondary {
  color: #64748b;
  border-color: #d9e1ea;
}

.table td .btn-outline-secondary:hover {
  background: #f8fafc;
  color: #475569;
  border-color: #c9d4e0;
}

.topbar-back-btn:hover {
  background: #ffffff;
  color: var(--farm-ui-accent);
  border-color: #cfe1d8;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.topbar-back-btn .ti {
  font-size: 1.15rem;
}

[dir="rtl"] .topbar-back-btn .ti {
  transform: scaleX(-1);
}

.icon-md {
  width: 2.5rem;
  height: 2.5rem;
  line-height: 2.5rem;
}

.icon-shape {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  vertical-align: middle;
}

.branding-card {
  background: #ffffff;
  border: 1px solid var(--farm-ui-border);
  border-radius: 24px;
  padding: 1.25rem;
  box-shadow: var(--farm-ui-shadow);
}

.branding-preview {
  min-height: 180px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: radial-gradient(circle at top, rgba(13, 110, 253, 0.08), transparent 55%), #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.branding-preview img {
  max-width: 100%;
  max-height: 90px;
  object-fit: contain;
}

.branding-preview-favicon img {
  max-height: 64px;
}

.branding-preview-loader img {
  max-height: 72px;
}

.loader-brand-image {
  max-width: 120px;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.mt-6 {
  margin-top: 4rem !important;
}

.ms-n2 {
  margin-left: -0.5rem !important;
}

[dir="rtl"] .ms-n2 {
  margin-left: 0 !important;
  margin-right: -0.5rem !important;
}

[dir="rtl"] .sidebar .nav-link,
[dir="rtl"] .sidebar .logo-area,
[dir="rtl"] .list-group-item,
[dir="rtl"] .dropdown-item,
[dir="rtl"] .table,
[dir="rtl"] .card-header,
[dir="rtl"] .card-body,
[dir="rtl"] .form-label,
[dir="rtl"] .form-control,
[dir="rtl"] .form-select,
[dir="rtl"] p,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] td,
[dir="rtl"] th,
[dir="rtl"] small,
[dir="rtl"] label {
  text-align: right;
}

[dir="rtl"] .sidebar .nav-link,
[dir="rtl"] .sidebar .logo-area,
[dir="rtl"] .sidebar-brand,
[dir="rtl"] .list-group-item,
[dir="rtl"] .topbar .dropdown-item {
  flex-direction: row;
}

[dir="rtl"] .sidebar .nav-link {
  justify-content: flex-start;
  text-align: right;
}

[dir="rtl"] .topbar .list-unstyled {
  justify-content: flex-start;
}

[dir="rtl"] .sidebar .sidebar-nav-form .nav-link {
  direction: rtl;
}

[dir="rtl"] .sidebar.collapsed .nav-link {
  justify-content: center;
  flex-direction: row;
  direction: ltr;
}

[dir="rtl"] .topbar .dropdown-menu,
[dir="rtl"] .dropdown-menu-end {
  right: auto !important;
  left: 0 !important;
}

[dir="rtl"] .topbar .navbar,
[dir="rtl"] .card-header,
[dir="rtl"] .table,
[dir="rtl"] .list-group-item,
[dir="rtl"] .row,
[dir="rtl"] .col,
[dir="rtl"] main {
  direction: rtl;
}

@media (max-width: 992px) {
  .sidebar {
    left: -240px;
    right: auto;
  }

  [dir="rtl"] .sidebar {
    left: auto !important;
    right: -240px !important;
  }

  .sidebar.mobile-show {
    left: 0;
    right: auto;
  }

  [dir="rtl"] .sidebar.mobile-show {
    left: auto !important;
    right: 0 !important;
  }

  .topbar {
    margin-left: 0 !important;
    width: 100% !important;
  }

  [dir="rtl"] .topbar {
    margin-right: 0 !important;
  }

  .content {
    margin-left: 0 !important;
  }

  [dir="rtl"] .content {
    margin-right: 0 !important;
  }
}

.transition-all {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-translate-y:hover {
  transform: translateY(-6px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1) !important;
}

.nav-chevron {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.8rem !important;
  will-change: transform;
}

[aria-expanded="true"] .nav-chevron {
  transform: rotate(180deg);
}

.sidebar .collapse .nav-link {
  border-inline-start: 0;
  margin: 2px 0;
  padding-inline-start: 18px;
  font-size: 0.92rem;
  background: transparent;
  box-shadow: none;
}

.sidebar .collapse .nav-link.active {
  background-color: var(--farm-ui-accent-soft);
  color: var(--farm-ui-accent);
  border-color: transparent;
}

.fs-7 {
  font-size: 0.75rem !important;
}

/* Smoother sidebar transitions */
.sidebar .nav-link .nav-text {
  transition: opacity 0.2s ease-in-out;
}

.sidebar .nav-link .ti:not(.nav-chevron) {
  transition: transform 0.2s ease-in-out;
}

.sidebar .nav-link:hover .ti:not(.nav-chevron) {
  transform: scale(1.1);
}

.min-h-45 { min-height: 45px; }

/* Custom Tag Input Styling */
.tag-input-container {
    padding: 0.375rem 0.75rem;
    cursor: text;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.tag-input-container:focus-within {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.tag-input-container select {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: auto !important;
    flex-grow: 1;
    cursor: pointer;
    font-size: 0.875rem;
    color: #6c757d;
}

.tag-input-container select:focus {
    outline: none !important;
}

/* Compact Chips */
.method-chip {
    font-size: 0.75rem !important;
    font-weight: 500;
    padding: 3px 10px !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background-color: #198754 !important;
    color: #fff !important;
    border-radius: 5px !important;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.method-chip .btn-close {
    width: 10px !important;
    height: 10px !important;
    padding: 0 !important;
    margin: 0 !important;
    filter: invert(1) grayscale(100%) brightness(200%);
    background-size: 10px !important;
    min-height: auto !important;
    min-width: auto !important;
    background-color: transparent !important;
    opacity: 0.8;
}

.method-chip .btn-close:hover {
    opacity: 1;
}

/* Premium Toastr Styling */
#toast-container {
    top: 20px !important;
}

#toast-container > .toast {
    background-image: none !important;
    padding: 16px 20px 16px 52px !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2) !important;
    border-radius: 50px !important; /* Pill shape */
    opacity: 1 !important;
    width: auto !important;
    min-width: 280px;
    margin: 0 auto 10px auto !important;
    display: flex;
    align-items: center;
}

[dir="rtl"] #toast-container > .toast {
    padding: 16px 52px 16px 20px !important;
}

#toast-container > .toast-success {
    background-color: #198754 !important;
}

#toast-container > .toast-error {
    background-color: #dc3545 !important;
}

#toast-container > .toast:before {
    position: absolute;
    font-family: "tabler-icons" !important;
    font-size: 22px;
    line-height: 1;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    opacity: 1;
}

#toast-container > .toast-success:before {
    content: "\ea5e"; /* ti-check */
    left: 18px;
}

[dir="rtl"] #toast-container > .toast-success:before {
    right: 18px;
    left: auto;
}

#toast-container > .toast-error:before {
    content: "\f62a"; /* ti-x */
    left: 18px;
}

[dir="rtl"] #toast-container > .toast-error:before {
    right: 18px;
    left: auto;
}

#toast-container .toast-message {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

#toast-container .toast-progress {
    background-color: rgba(255, 255, 255, 0.4);
    height: 4px;
    opacity: 1;
    bottom: 0;
    top: auto;
}

#toast-container .toast-close-button {
    display: none !important; /* Clean look */
}
