/* ==========================================================================
   Ultra-Modern Dark UI Theme (Inspired by sleek agenda dashboard mockup)
   RTL & Persian First | Full PWA Responsive
   ========================================================================== */

:root {
  --bg-body: #0b0f19;
  --bg-frame: #121824;
  --bg-card: #182234;
  --bg-card-hover: #1e2b42;
  --bg-pill: #1f2c42;
  --bg-input: #101725;
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-blue: #2563eb;
  --accent-blue-light: #38bdf8;
  --accent-blue-glow: rgba(37, 99, 235, 0.45);
  
  --accent-orange: #f97316;
  --accent-lime: #84cc16;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --dock-width: 80px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-body);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.05) 0%, transparent 45%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.015) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255, 255, 255, 0.015) 25%, transparent 25%);
  background-size: 100% 100%, 100% 100%, 70px 70px, 70px 70px;
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, Tahoma, sans-serif;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

/* اعداد انگلیسی و یکنواخت */
.latin-num {
  font-family: Arial, Helvetica, sans-serif !important;
  direction: ltr;
  display: inline-block;
}

/* اسکرول‌بار دارک اختصاصی */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #0b0f19;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* --------------------------------------------------------------------------
   Right Iconic Sidebar Dock (Desktop)
   -------------------------------------------------------------------------- */
.icon-dock {
  width: var(--dock-width);
  background: #121824;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1040;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.4);
}

.dock-brand {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
  margin-bottom: 28px;
  text-decoration: none;
  transition: transform 0.2s ease;
}
.dock-brand:hover {
  transform: scale(1.05);
}

.dock-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
  flex-grow: 1;
}

.dock-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #1c2536;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-decoration: none;
  position: relative;
}

.dock-btn:hover {
  background: #253349;
  color: #60a5fa;
  transform: translateY(-2px);
}

.dock-btn.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.55);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Tooltip اختصاصی برای آیکون‌های سایدبار دسکتاپ */
.dock-btn[data-title]::after {
  content: attr(data-title);
  position: absolute;
  right: 58px;
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: #1e293b;
  color: #f8fafc;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.15s ease;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1050;
}
.dock-btn:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.dock-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}

.user-avatar-squircle {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Main Content Layout
   -------------------------------------------------------------------------- */
.main-wrapper {
  margin-right: var(--dock-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  transition: margin-right 0.3s ease;
}

/* هدر بالای صفحه */
.top-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.greeting-text h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.5px;
  color: #f8fafc;
}
.greeting-text p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-search {
  position: relative;
  min-width: 260px;
}
.header-search input {
  background: #162032;
  border: 1px solid var(--border-card);
  color: #f8fafc;
  border-radius: 20px;
  padding: 9px 38px 9px 16px;
  font-size: 0.88rem;
  width: 100%;
  transition: all 0.2s ease;
}
.header-search input:focus {
  background: #1c263c;
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.header-search i {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.header-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #162032;
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none;
}
.header-icon-btn:hover {
  background: #1e2b44;
  color: #fff;
}
.header-icon-btn .notify-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  background: var(--accent-orange);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-orange);
}

/* --------------------------------------------------------------------------
   Cards, Panels & Widgets
   -------------------------------------------------------------------------- */
.card, .card-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 20px;
}

.card-footer {
  background: transparent;
  border-top: 1px solid var(--border-subtle);
}

/* نوارهای رنگی شاخص در بالای کارت‌ها (مطابق عکس Scheduled) */
.accent-bar-orange {
  border-top: 4px solid var(--accent-orange) !important;
}
.accent-bar-lime {
  border-top: 4px solid var(--accent-lime) !important;
}
.accent-bar-blue {
  border-top: 4px solid var(--accent-blue-light) !important;
}
.accent-bar-purple {
  border-top: 4px solid var(--accent-purple) !important;
}

/* تگ‌های گرد با نشانگر رنگی */
.tag-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: #101725;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.tag-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.tag-dot.orange::before { background: var(--accent-orange); box-shadow: 0 0 6px var(--accent-orange); }
.tag-dot.lime::before { background: var(--accent-lime); box-shadow: 0 0 6px var(--accent-lime); }
.tag-dot.blue::before { background: var(--accent-blue-light); box-shadow: 0 0 6px var(--accent-blue-light); }
.tag-dot.emerald::before { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }

/* دکمه‌های مدرن */
.btn {
  border-radius: 12px;
  font-weight: 500;
  padding: 0.55rem 1.15rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* اصلاح استایل‌های Bootstrap برای تم دارک */
.bg-light {
  background-color: #121927 !important;
  color: var(--text-primary) !important;
}

.bg-white {
  background-color: var(--bg-card) !important;
}

.border {
  border-color: var(--border-subtle) !important;
}

.border-bottom {
  border-bottom-color: var(--border-subtle) !important;
}

.border-top {
  border-top-color: var(--border-subtle) !important;
}

.nav-pills .nav-link {
  color: var(--text-secondary);
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-pills .nav-link.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.nav-pills.bg-light {
  background-color: #101725 !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
  color: #fff;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #1d4ed8 100%);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
  color: #fff;
}

.btn-outline-light {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
}
.btn-outline-light:hover {
  background: #1e2b44;
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* فرم‌ها و اینپوت‌های دارک */
.form-control, .form-select {
  background-color: var(--bg-input) !important;
  border: 1px solid #253349 !important;
  color: #f8fafc !important;
  border-radius: 12px;
  padding: 0.65rem 0.95rem;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
  outline: none;
}

.form-control::placeholder {
  color: #64748b;
}

.input-group-text {
  background-color: #1a2538 !important;
  border: 1px solid #253349 !important;
  color: var(--text-secondary) !important;
  border-radius: 12px;
}

/* جدول‌های دارک */
.table {
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.06);
}
.table > :not(caption) > * > * {
  background-color: transparent;
  color: #e2e8f0;
  border-bottom-color: rgba(255, 255, 255, 0.06);
  padding: 0.85rem 1rem;
}
.text-muted, [data-bs-theme="dark"] .text-muted, body .text-muted {
  color: #94a3b8 !important;
}
.table-hover > tbody > tr:hover > * {
  background-color: rgba(255, 255, 255, 0.035);
  color: #fff;
}
.table-light, thead.table-light th {
  background-color: #131c2c !important;
  color: var(--text-secondary) !important;
  font-size: 0.82rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* --------------------------------------------------------------------------
   Modals (طراحی الهام گرفته از پاپ‌آپ Brainstorm Session در تصویر)
   -------------------------------------------------------------------------- */
.modal-content {
  background: #141d2c !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 24px !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8) !important;
  color: #f8fafc !important;
}

.modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 18px 24px;
}
.modal-title {
  font-weight: 700;
  font-size: 1.15rem;
}
.modal-body {
  padding: 24px;
}
.modal-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 16px 24px;
}

.btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* --------------------------------------------------------------------------
   Mobile Floating Bottom Navigation Bar (PWA Mobile Dock)
   -------------------------------------------------------------------------- */
.mobile-dock {
  display: none;
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  height: 66px;
  background: rgba(18, 24, 38, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px;
  z-index: 1030;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
}

.mobile-dock-item {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-decoration: none;
  font-size: 1.25rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.mobile-dock-item span {
  display: none;
}

.mobile-dock-item:hover, .mobile-dock-item:active {
  color: #60a5fa;
}

.mobile-dock-item.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5);
  transform: translateY(-2px);
}

.mobile-top-bar {
  display: none;
}

/* تقویم جلالی با استایل دارک */
.jdp-container {
  background: #141d2c !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 20px !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6) !important;
}
.jdp-container .jdp-icon-plus, .jdp-container .jdp-icon-minus {
  filter: invert(1) !important;
}
.jdp-container .jdp-day {
  color: #cbd5e1 !important;
}
.jdp-container .jdp-day:hover {
  background: #1e2b44 !important;
}
.jdp-container .jdp-day.selected {
  background: #2563eb !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.6) !important;
}

/* دکمه نصب PWA بنر */
.pwa-install-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 18px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.15);
}

/* --------------------------------------------------------------------------
   Responsive Media Queries (< 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .icon-dock {
    display: none;
  }

  .main-wrapper {
    margin-right: 0;
    padding: 16px 14px 96px 14px;
  }

  .mobile-dock {
    display: flex;
  }

  .mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 4px 2px;
  }

  .greeting-text h2 {
    font-size: 1.35rem;
  }

  .header-search {
    min-width: 100%;
    margin-top: 10px;
  }
}

/* --------------------------------------------------------------------------
   Mobile Typography & Layout Optimizations (< 576px)
   -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
  /* تنظیم خودکار سایز هدینگ‌ها و عناوین در گوشی‌های کوچک */
  h3, .h3 {
    font-size: 1.35rem !important;
  }
  h4, .h4 {
    font-size: 1.15rem !important;
  }
  h5, .h5 {
    font-size: 1.02rem !important;
  }

  /* کلاس بهینه برای کنترل اندازه مبالغ مالی بزرگ در کارت‌ها */
  .card-kpi-value, .responsive-kpi-num {
    font-size: clamp(0.88rem, 3.8vw, 1.25rem) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.3;
  }

  /* پدینگ مناسب کارت‌ها در صفحه موبایل */
  .card {
    border-radius: var(--radius-md) !important;
  }
  .card-body, .card.p-3 {
    padding: 0.85rem !important;
  }
  .card-header {
    padding: 0.75rem 0.85rem !important;
  }

  /* یکنواخت‌سازی دکمه‌های عملیاتی بالای صفحات در موبایل */
  .mobile-action-btns {
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
  }
  .mobile-action-btns .btn,
  .mobile-action-btns a.btn {
    flex: 1 1 0 !important;
    white-space: nowrap !important;
    font-size: 0.82rem !important;
    padding: 0.6rem 0.4rem !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 12px !important;
  }

  /* اصلاح هدر جدول‌ها در موبایل جهت جلوگیری از شکست عمودی کلمات */
  .table > :not(caption) > * > * {
    padding: 0.65rem 0.45rem !important;
    font-size: 0.82rem !important;
  }
  .table thead th {
    white-space: nowrap !important;
    font-size: 0.78rem !important;
  }

  /* فیلتر تب‌های وضعیت چک‌ها و بدهی‌ها */
  .nav-pills .nav-link {
    font-size: 0.72rem !important;
    padding: 0.35rem 0.4rem !important;
    white-space: nowrap !important;
  }
}
