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

:root {
  /* رنگ اصلی برند — رز/کورال گرم (اقدام‌ها/دکمه‌ها) */
  --primary: #D6336C;
  --primary-dark: #A72358;
  --primary-light: #FCE8F0;

  /* سبز — همچنان معنای «سالم / مثبت» را می‌دهد، فقط گرم‌تر شد */
  --green: #2F6B45;
  --green-dark: #1F3D2B;
  --green-light: #E8F3EA;
  --green-text: #1F3D2B;

  /* قرمز — هم‌راستا با رنگ «مهر» در طرح جدید */
  --red: #B33A2E;
  --red-light: #FBEAE6;

  --amber: #D97706;
  --amber-light: #FEF3C7;

  /* آبی قبلی → فیروزه‌ای «کلینیک هوشمند» برای خدمات AI/سلامت */
  --blue: #0F766E;
  --blue-light: #E6F5F2;

  --bg: #FBF3E3;
  --surface: #ffffff;
  --surface2: #F6ECD6;
  --border: #F0DEB8;
  --border-strong: #E0C48A;
  --text: #241C10;
  --text-2: #5c4f33;
  --text-3: #a89572;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 14px -8px rgba(150,90,20,.18);
  --shadow-md: 0 10px 26px -12px rgba(150,90,20,.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15.5px; }
body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  font-weight: 450;
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; right: 0;
  z-index: 100;
  overflow-y: auto;
}
.main {
  margin-right: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.content { padding: 1.5rem; flex: 1; }

/* Sidebar */
.sidebar-logo {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}
.logo-text { font-size: 16px; font-weight: 700; color: var(--text); }
.logo-sub { font-size: 10px; color: var(--text-3); }

.nav-section { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.nav-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  padding: .25rem 1rem .5rem;
  letter-spacing: .06em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .6rem 1rem;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  border-radius: 0;
  transition: all .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
  border-left: 3px solid var(--primary);
}
.nav-item i { font-size: 17px; flex-shrink: 0; }
.nav-badge {
  margin-right: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 12px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-3); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { color: var(--primary); font-size: 18px; }

/* Metric Cards */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 1.5rem; }
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.metric-val { font-size: 26px; font-weight: 700; color: var(--text); display: block; }
.metric-lbl { font-size: 12px; color: var(--text-3); margin-top: 2px; display: block; }
.metric-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: .5rem;
}
.mi-green { background: var(--green-light); color: var(--green); }
.mi-red { background: var(--red-light); color: var(--red); }
.mi-amber { background: var(--amber-light); color: var(--amber); }
.mi-blue { background: var(--blue-light); color: var(--blue); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: 'Vazirmatn', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn i { font-size: 16px; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px -4px rgba(214,51,108,.4); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger { background: var(--red); color: white; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-sm i { font-size: 14px; }
.btn-icon {
  width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; color: var(--text-2);
}
.btn-icon:hover { background: var(--surface2); }
.btn-icon i { font-size: 17px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge i { font-size: 11px; }
.badge-green { background: var(--green-light); color: var(--green-text); }
.badge-red { background: var(--red-light); color: #991b1b; }
.badge-amber { background: var(--amber-light); color: #92400e; }
.badge-blue { background: var(--blue-light); color: #1e40af; }
.badge-gray { background: var(--surface2); color: var(--text-2); border: 1px solid var(--border); }

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: .75rem;
}
.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-danger { background: var(--red-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--green-light); color: var(--green-text); border: 1px solid #86efac; }
.alert-warning { background: var(--amber-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--blue-light); color: #1e40af; border: 1px solid #93c5fd; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: 'Vazirmatn', sans-serif;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  direction: rtl;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(214,51,108,.12); }
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; }

/* Table */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: right;
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.table tr:hover td { background: var(--surface2); }
.table tr:last-child td { border-bottom: none; }

/* Progress */
.progress { background: var(--surface2); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--green); transition: width .3s; }

/* AI Badge */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 18px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-icon { font-size: 40px; color: var(--text-3); margin-bottom: .75rem; }
.upload-text { font-size: 14px; color: var(--text-2); }
.upload-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* Notifications */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.notif-title { font-size: 13px; font-weight: 500; color: var(--text); }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
/* ── نوار ناوبری پایین صفحه، فقط موبایل ───────────────────── */
/* توجه: این بلوکِ پایه («عدم نمایش در دسکتاپ») باید همیشه قبل از
   media query‌ای که display:flex را ست می‌کند بیاید، وگرنه چون هر دو
   یک specificity دارند، آخرین قانون در فایل برنده می‌شود و روی موبایل
   هم نوار مخفی می‌ماند. (باگی که قبلاً باعث ناپدید شدن نوار روی موبایل شده بود) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; right: 0; left: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(env(safe-area-inset-bottom, 0px) + 8px);
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -8px 20px -12px rgba(0,0,0,.12);
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  min-width: 54px;
  position: relative;
}
.mobile-nav-item i { font-size: 20px; }
.mobile-nav-item.active { color: var(--primary-dark); }
.mobile-nav-item .mn-badge {
  position: absolute; top: -1px; left: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--surface);
}
.mobile-nav-fab {
  width: 52px; height: 52px; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-top: -26px;
  box-shadow: 0 10px 20px -6px rgba(214,51,108,.55);
  flex-shrink: 0;
}
.mobile-nav-fab i { font-size: 24px; }

@media(max-width:768px) {
  .sidebar { display: none; }
  .main { margin-right: 0; }
  .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; }
  .grid-2 > *, .grid-3 > *, .grid-4 > * { grid-column: auto !important; }
  .content, .card, .metrics, .metric, .grid-2, .grid-3, .grid-4, .page-header {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .content { overflow-x: hidden !important; }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .topbar { padding: 0 1rem; }
  .content { padding: 1rem; padding-bottom: 92px; }
  .mobile-nav { display: flex; }
}

/* ═══════ چت هوش مصنوعی: جعبه‌ی ثابت در صفحه + امکان تمام‌صفحه ═══════════
   قبلاً این جعبه‌ها با height:calc(100vh - 200px) کل صفحه را اشغال می‌کردند
   و روی خیلی از گوشی‌ها (وقتی کیبورد باز می‌شد) نوار تایپ از دید بیرون
   می‌افتاد. الگوی جدید: به‌طور پیش‌فرض یک کارت با ارتفاع ثابت و معقول که
   داخل روند عادی صفحه می‌نشیند (صفحه خودش اسکرول می‌شود، نه جعبه‌ی چت با
   ترفندهای vh) — دقیقاً مثل کارت‌های دیگر سایت. اگر گفتگو طولانی شد، کاربر
   با دکمه‌ی بزرگ‌نمایی می‌تواند جعبه را تمام‌صفحه کند و با ضربدر خارج شود؛
   فقط در همان حالت تمام‌صفحه از assets/js/ai-mobile-fit.js و
   window.visualViewport برای ارتفاع امن روی کیبورد استفاده می‌شود. */
.ai-chat-card {
  display: flex;
  flex-direction: column;
  height: 480px;
  max-height: 65vh;
  padding: 0;
  overflow: hidden;
}
.ai-chat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-chat-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 0;
}
.ai-chat-input-bar {
  border-top: 1px solid var(--border);
  padding: .75rem;
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}
.ai-chat-card-head .btn-icon { width: 28px; height: 28px; }
.ai-chat-card-head .btn-icon i { font-size: 15px; }
/* حالت تمام‌صفحه — فقط وقتی کاربر خودش با دکمه‌ی بزرگ‌نمایی فعالش کند */
.ai-chat-card.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 400;
  width: 100%;
  height: 100vh;
  max-height: none;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}
body.ai-chat-locked { overflow: hidden; }
@media (max-width: 768px) {
  .ai-chat-card { height: 420px; max-height: 60vh; }
}

/* Helpers */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.fw-500 { font-weight: 500; }
.w-full { width: 100%; }
