/* ========== پایه ========== */

#app-root {
  min-height: 100vh;
  display: flex; /* اختیاری: کمک به مرکزسازی صفحات auth */
  flex-direction: column;
}

body {
  font-family:
    "Vazirmatn",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-feature-settings: "ss01";
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

/* ========== اسکرول‌بار سفارشی ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 20px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
.dark ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ========== صفحات و انیمیشن‌ها ========== */
.page-section {
  display: none;
  animation: fadeIn 0.35s ease-out;
}
.page-section.active {
  display: block;
}

/* ========== کارت و هاور ========== */
.card-hover {
  transition: all 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 35px -8px rgba(0, 0, 0, 0.12),
    0 4px 18px -4px rgba(0, 0, 0, 0.06);
}

/* ========== توست (اعلان) ========== */
.toast-enter {
  animation: slideInLeft 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.toast-exit {
  animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

/* ========== آیتم فعال نویگیشن ========== */
.nav-item-active {
  position: relative;
  color: #965035 !important;
  background-color: #fdf6f2 !important;
}
.dark .nav-item-active {
  color: #e8b094 !important;
  background-color: rgba(61, 31, 20, 0.3) !important;
}
.nav-item-active::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  border-radius: 0 8px 8px 0;
  background: #c87a58;
}

/* ========== نویگیشن موبایل ========== */
/* موبایل: منوی پایین همیشه دیده شود، سایدبار دسکتاپ مخفی */
@media (max-width: 767.98px) {
  .mobile-bottom-nav {
    display: flex !important;
  }
  /* سایدبار فقط وقتی با JS باز شود دیده می‌شود */
  .sidebar-desktop {
    display: none;
  }
}
/* دسکتاپ */
@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none !important;
  }
  .sidebar-desktop {
    display: flex;
  }
}

/* ========== صفحات احراز هویت ========== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background-color: #fdfbf8;
}
.dark .auth-page {
  background-color: #1c1e22;
}

/* ========== اسکرول‌بار داخل باکس‌ها ========== */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 10px;
}
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: #475569;
}

/* رفع مشکل قرار گرفتن تقویم شمسی زیر مودال */
/* حل مشکل مخفی شدن تقویم زیر مودال‌ها */

/* ==========================================
   شخصی‌سازی ظاهر تقویم شمسی (لایت مود)
========================================== */
jdp-container,
.jdp-container {
  z-index: 999999 !important;
  font-family: inherit !important; /* ارث‌بری فونت زیبای پروژه شما */
  border-radius: 1rem !important; /* گوشه‌های گرد هماهنگ با مودال‌ها */
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
  border: 1px solid #e5e7eb !important; /* border-gray-200 */
  overflow: hidden;

  /* رنگ‌های تم لایت (می‌توانید کدهای رنگ Accent خود را اینجا جایگزین کنید) */
  --color-primary: #3b82f6 !important; /* رنگ اصلی: آبی (accent-500) */
  --color-secondary: #eff6ff !important; /* پس‌زمینه روز انتخاب شده: آبی خیلی روشن */
  --color-bg-today: #f3f4f6 !important; /* پس‌زمینه روز جاری: gray-100 */
}

/* ==========================================
   استایل‌های مخصوص صفحه چاپ (Print / PDF)
========================================== */
#printArea {
  display: none; /* در حالت عادی روی سایت مخفی است */
}

@media print {
  /* مخفی کردن کل سایت */
  body * {
    visibility: hidden;
  }

  /* نمایش فقط ناحیه چاپ */
  #printArea,
  #printArea * {
    visibility: visible;
  }

  #printArea {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 2rem !important;
    background-color: white !important;
    color: black !important;
  }

  /* جلوگیری از تیره افتادن کاغذ در دارک مود */
  html,
  body {
    background-color: white !important;
  }
}


/* ========== جلوگیری از اسکرول افقی کل صفحه ========== */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

#pageContent {
  max-width: 100%;
  overflow-x: hidden;
}

/* ========== منوی پایین موبایل (همه صفحات یکسان) ========== */
.mobile-bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 45 !important;
  display: none; /* پیش‌فرض؛ با media روشن می‌شود */
}

@media (max-width: 767.98px) {
  .mobile-bottom-nav {
    display: flex !important;
  }
  .sidebar-desktop {
    display: none; /* فقط با JS باز می‌شود */
  }
  main.flex-1 {
    padding-bottom: 5.5rem !important;
  }
}

@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none !important;
  }
  .sidebar-desktop {
    display: flex;
  }
}


/* ========== کارت‌های موبایل costs / charges ========== */
#costsCards article,
#chargesCards article {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
#costsCards article:active,
#chargesCards article:active {
  transform: scale(0.995);
}


/* ========== سایدبار دسکتاپ جمع‌شونده ========== */
@media (min-width: 768px) {
  .sidebar-desktop {
    overflow-x: hidden;
  }

  .sidebar-desktop.is-collapsed {
    width: 4.5rem; /* 72px */
    overflow-x: hidden;
  }

  .sidebar-desktop.is-collapsed .sidebar-brand,
  .sidebar-desktop.is-collapsed .sidebar-label,
  .sidebar-desktop.is-collapsed .sidebar-section-title {
    display: none !important;
    width: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
  }

  .sidebar-desktop.is-collapsed #sidebarNav {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .sidebar-desktop.is-collapsed #sidebarNav button {
    justify-content: center;
    padding: 0.75rem 0.5rem;
    gap: 0 !important;
  }

  .sidebar-desktop.is-collapsed #sidebarNav button span {
    display: none !important;
  }

  .sidebar-desktop.is-collapsed #sidebarNav .sidebar-section-title,
  .sidebar-desktop.is-collapsed hr {
    display: none !important;
  }

  /* هدر لوگو در حالت جمع */
  .sidebar-desktop.is-collapsed > .border-b {
    padding: 0.75rem 0.5rem;
  }
  .sidebar-desktop.is-collapsed > .border-b > .flex {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  /* پروفایل پایین */
  .sidebar-desktop.is-collapsed .border-t .sidebar-label {
    display: none !important;
  }
  .sidebar-desktop.is-collapsed .border-t .flex.items-center {
    justify-content: center;
  }
  .sidebar-desktop.is-collapsed .border-t {
    padding: 0.75rem 0.5rem;
  }

  /* آیکون دکمه جمع/باز */
  .sidebar-desktop.is-collapsed .sidebar-collapse-icon {
    transform: rotate(180deg);
  }

  /* فاصله محتوای اصلی */
  #appMainContent.sidebar-is-collapsed {
    margin-right: 4.5rem !important;
  }
}


/* ========== اسکرول امن جدول‌ها (تبلت / دسکتاپ باریک) ========== */
.table-scroll-wrap {
  position: relative;
}
.table-scroll-wrap::after {
  content: "";
  pointer-events: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 28px;
  background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
  opacity: 0.9;
  z-index: 2;
}
.dark .table-scroll-wrap::after {
  background: linear-gradient(to right, rgba(0,0,0,0.35), transparent);
}
.table-scroll-area {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
/* ستون اول چسبان تا کاربر بداند جدول ادامه دارد */
.sticky-col {
  position: sticky;
  right: 0;
  z-index: 1;
  box-shadow: -6px 0 8px -6px rgba(0,0,0,0.08);
}
.dark .sticky-col {
  box-shadow: -6px 0 8px -6px rgba(0,0,0,0.35);
}
thead .sticky-col {
  z-index: 2;
  background: inherit;
}


/* ========== انتخاب ساختمان (شکیل در همه ابعاد) ========== */
.building-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 100%;
}
.building-select-wrap > span {
  font-size: 0.8125rem;
  color: #6b7280;
  white-space: nowrap;
}
.dark .building-select-wrap > span {
  color: #9ca3af;
}
select.building-select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 11rem;
  max-width: 100%;
  padding: 0.55rem 2.25rem 0.55rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid #e5e7eb;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.65rem center;
  background-size: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  outline: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  cursor: pointer;
}
.dark select.building-select {
  border-color: #374151;
  background-color: #1f2937;
  color: #f9fafb;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.65rem center;
  background-size: 1rem;
}
select.building-select:hover {
  border-color: #d1d5db;
}
.dark select.building-select:hover {
  border-color: #4b5563;
}
select.building-select:focus {
  border-color: #4d958e;
  box-shadow: 0 0 0 3px rgba(77, 149, 142, 0.2);
}
@media (max-width: 639px) {
  .building-select-wrap {
    width: 100%;
  }
  select.building-select {
    width: 100%;
    min-width: 0;
  }
}


/* ========== دراپ‌داون سفارشی ساختمان ========== */
select.building-select.cs-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  clip: rect(0 0 0 0);
}
.cs-wrap {
  position: relative;
  display: inline-block;
  min-width: min(18rem, 100%);
  max-width: 100%;
  vertical-align: middle;
}
.cs-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.95rem;
  border-radius: 0.9rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-align: right;
}
.dark .cs-trigger {
  background: #1f2937;
  border-color: #374151;
}
.cs-trigger:hover {
  border-color: #cbd5e1;
}
.dark .cs-trigger:hover {
  border-color: #4b5563;
}
.cs-wrap.cs-open .cs-trigger {
  border-color: #4d958e;
  box-shadow: 0 0 0 3px rgba(77, 149, 142, 0.18);
}
.cs-trigger-text {
  font-size: 0.875rem;
  font-weight: 700;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dark .cs-trigger-text {
  color: #f9fafb;
}
.cs-trigger-text.cs-placeholder {
  color: #9ca3af;
  font-weight: 600;
}
.cs-chevron {
  width: 1.1rem;
  height: 1.1rem;
  color: #9ca3af;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.cs-wrap.cs-open .cs-chevron {
  transform: rotate(180deg);
  color: #4d958e;
}
.cs-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  left: 0;
  z-index: 50;
  border-radius: 0.9rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 12px 40px -12px rgba(0,0,0,0.18), 0 4px 12px -4px rgba(0,0,0,0.08);
  overflow: hidden;
  animation: csPop 0.16s ease-out;
}
.dark .cs-panel {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 12px 40px -12px rgba(0,0,0,0.5);
}
@keyframes csPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.cs-options {
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.4rem;
}
.cs-option {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: right;
  padding: 0.7rem 0.85rem;
  border-radius: 0.7rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  transition: background 0.12s ease, color 0.12s ease;
  outline: none;
}
.dark .cs-option {
  color: #e5e7eb;
}
.cs-option:hover:not(:disabled) {
  background: #f3f4f6;
}
.dark .cs-option:hover:not(:disabled) {
  background: #374151;
}
.cs-option-active {
  background: #f0f6f5 !important;
  color: #2a504c !important;
}
.dark .cs-option-active {
  background: rgba(61, 122, 116, 0.25) !important;
  color: #a9d1cd !important;
}
.cs-option-muted,
.cs-option:disabled {
  color: #9ca3af !important;
  cursor: default;
  font-weight: 500;
}
.cs-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 639px) {
  .cs-wrap {
    display: block;
    width: 100%;
    min-width: 0;
  }
}
