/* ====================================================================
   موکب آیتین — استایل اصلی
   طراحی RTL، ریسپانسیو، با پالت گرم سبز/کرم
   ==================================================================== */

:root {
  --teal-900: #0c4a44;
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-50: #f0fdfa;
  --sand: #f7f3ea;
  --sand-2: #efe7d6;
  --gold: #c79a3a;
  --ink: #1f2a2e;
  --muted: #66767a;
  --line: #e7e2d6;
  --bg: #f4f1ea;
  --card: #ffffff;
  --rose: #e11d48;
  --rose-soft: #fff1f3;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --shadow-sm: 0 1px 3px rgba(15, 60, 55, .08);
  --shadow: 0 8px 30px rgba(15, 60, 55, .10);
  --shadow-lg: 0 20px 50px rgba(15, 60, 55, .18);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

/* عناصری که attribute مخفی دارند همیشه پنهان بمانند (مهم برای مودال/توست) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
}

input, button, select, textarea { font-family: inherit; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, opacity .18s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: linear-gradient(135deg, var(--teal-600), var(--teal-700));
  color: #fff;
  box-shadow: 0 6px 18px rgba(13, 148, 136, .32);
}
.btn-primary:hover { box-shadow: 0 10px 24px rgba(13, 148, 136, .42); }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-soft {
  background: var(--teal-50);
  color: var(--teal-700);
  border: 1px solid #cdeee9;
}
.btn-soft:hover { background: #e2f7f4; }
.btn-ghost {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .2); }
.btn-danger { background: var(--rose-soft); color: var(--rose); border: 1px solid #ffd7de; }
.btn-danger:hover { background: #ffe4e9; }
.btn-mini { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ==================================================================
   صفحه ورود
   ================================================================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(20, 184, 166, .35), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(199, 154, 58, .22), transparent 55%),
    linear-gradient(160deg, var(--teal-900), #0a3a35 55%, #08302c);
}
.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .5;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 410px;
  background: rgba(255, 255, 255, .98);
  border-radius: 24px;
  padding: 38px 32px 28px;
  box-shadow: var(--shadow-lg);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.login-logo {
  width: 78px; height: 78px;
  margin: 0 auto 14px;
  border-radius: 22px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  box-shadow: 0 12px 26px rgba(13, 148, 136, .4);
}
.login-title { text-align: center; font-size: 27px; margin: 4px 0 2px; color: var(--teal-900); }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-error {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid #ffd7de;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
  text-align: center;
}
.login-foot { text-align: center; color: #9aa7ab; font-size: 12.5px; margin: 16px 0 0; }

/* ---------- فیلدها ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.field > span { font-size: 13.5px; font-weight: 600; color: #3c4a4e; }
.field > span small { color: #9aa7ab; font-weight: 500; }
.field .req { color: var(--rose); font-style: normal; }
.field input, .field select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  background: #fcfbf7;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--teal-500);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, .14);
}

/* ==================================================================
   چیدمان برنامه
   ================================================================== */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-900));
  color: #fff;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.4; }
.brand-text strong { font-size: 17px; }
.brand-text span { font-size: 12px; opacity: .82; }
.btn-logout span { display: inline; }

/* ---------- تب‌ها ---------- */
.tabs {
  position: sticky; top: 66px; z-index: 25;
  display: flex; gap: 4px;
  padding: 8px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border: none; cursor: pointer;
  padding: 9px 15px; border-radius: 12px;
  color: var(--muted); font-size: 14.5px; font-weight: 600;
  white-space: nowrap; transition: all .15s;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { background: var(--sand); color: var(--ink); }
.tab.active { background: var(--teal-50); color: var(--teal-700); }

.content { flex: 1; padding: 20px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- پنل‌ها ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.panel-title { margin: 0 0 16px; font-size: 16px; color: var(--teal-900); display: flex; align-items: center; gap: 8px; }
.cards-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }

/* ---------- کارت‌های آمار ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent, var(--teal-500));
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; margin-bottom: 10px;
  background: var(--accent-soft, var(--teal-50));
  color: var(--accent, var(--teal-600));
}
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.stat-value small { font-size: 15px; font-weight: 600; color: var(--muted); }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- نوار ظرفیت ---------- */
.cap-row { margin-bottom: 18px; }
.cap-row:last-child { margin-bottom: 0; }
.cap-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.cap-head b { font-size: 14.5px; }
.cap-head span { font-size: 13px; color: var(--muted); }
.cap-bar { height: 12px; border-radius: 99px; background: var(--sand-2); overflow: hidden; }
.cap-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.cap-fill.male { background: linear-gradient(90deg, var(--teal-500), var(--teal-700)); }
.cap-fill.female { background: linear-gradient(90deg, #e879b9, #c2389a); }
.cap-fill.full { background: linear-gradient(90deg, #fb7185, var(--rose)) !important; }

/* ---------- وعده‌ها در داشبورد ---------- */
.meal-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.meal-line:last-child { border-bottom: none; }
.meal-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.meal-dot { width: 9px; height: 9px; border-radius: 99px; background: var(--gold); }
.meal-nums { display: flex; gap: 14px; font-size: 13.5px; color: var(--muted); }
.meal-nums b { color: var(--ink); font-size: 15px; }
.meal-total-badge {
  background: var(--teal-50); color: var(--teal-700);
  padding: 3px 12px; border-radius: 99px; font-weight: 700; font-size: 14px;
}

/* ---------- فرم ثبت ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field-wide { grid-column: 1 / -1; }
.gender-toggle { display: flex; gap: 8px; }
.g-opt {
  flex: 1; padding: 11px; border: 1.5px solid var(--line); background: #fcfbf7;
  border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--muted);
  transition: all .15s;
}
.g-opt.active { border-color: var(--teal-500); background: var(--teal-50); color: var(--teal-700); }
.reg-actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.reg-hint { font-size: 13px; color: var(--muted); }
.reg-hint b { color: var(--ink); }

/* ---------- نوار ابزار مهمان‌ها ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.search-box {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 14px; flex: 1; min-width: 220px; color: var(--muted);
}
.search-box input { border: none; outline: none; background: transparent; padding: 11px 0; flex: 1; font-size: 15px; color: var(--ink); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--sand); border-radius: 12px; padding: 4px; gap: 2px; }
.seg-opt {
  border: none; background: transparent; cursor: pointer;
  padding: 8px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: all .15s;
}
.seg-opt.active { background: #fff; color: var(--teal-700); box-shadow: var(--shadow-sm); }

/* ---------- لیست مهمان‌ها ---------- */
.guests-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.guest-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); position: relative;
  transition: box-shadow .18s, transform .12s;
}
.guest-card:hover { box-shadow: var(--shadow); }
.guest-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
}
.avatar.male { background: linear-gradient(135deg, var(--teal-500), var(--teal-700)); }
.avatar.female { background: linear-gradient(135deg, #e879b9, #c2389a); }
.guest-name { font-weight: 700; font-size: 15.5px; }
.guest-id { font-size: 12.5px; color: var(--muted); direction: ltr; text-align: right; }
.guest-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.guest-meta .row { display: flex; justify-content: space-between; }
.guest-meta .row b { color: var(--ink); font-weight: 600; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge.present { background: #eafaf0; color: var(--green); }
.badge.left { background: #eef2ff; color: var(--blue); }
.badge.expired { background: var(--sand-2); color: var(--amber); }
.nights-pill { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--amber); font-weight: 600; }
.guest-actions { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.guest-actions .btn { flex: 1; }

.empty {
  text-align: center; padding: 50px 20px; color: var(--muted);
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
  grid-column: 1 / -1;
}
.empty svg { opacity: .4; margin-bottom: 10px; }

/* ---------- لیست غذا ---------- */
.meal-log { display: flex; flex-direction: column; gap: 8px; }
.meal-rec {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--sand); border-radius: 12px;
}
.meal-rec .info { display: flex; align-items: center; gap: 12px; }
.meal-rec .tag { background: #fff; padding: 4px 12px; border-radius: 99px; font-weight: 700; font-size: 13px; color: var(--teal-700); }
.meal-rec .det { font-size: 13px; color: var(--muted); }
.meal-rec .det b { color: var(--ink); }
.mtotal-row { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.mtotal-row:last-child { border: none; }
.mtotal-row .v { font-weight: 700; }
.grand {
  margin-top: 12px; padding: 14px; border-radius: 14px; text-align: center;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-900)); color: #fff;
}
.grand .n { font-size: 30px; font-weight: 800; }
.grand .l { font-size: 13px; opacity: .85; }

/* ---------- گزارش / چاپ ---------- */
.report-actions { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.report-hint { color: var(--muted); font-size: 13.5px; }
.report-content { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-sm); }
.rep-header { text-align: center; border-bottom: 2px solid var(--teal-700); padding-bottom: 16px; margin-bottom: 20px; }
.rep-header h2 { margin: 0 0 4px; color: var(--teal-900); font-size: 24px; }
.rep-header p { margin: 0; color: var(--muted); font-size: 14px; }
.rep-section { margin-bottom: 22px; }
.rep-section h3 { font-size: 16px; color: var(--teal-800); border-right: 4px solid var(--gold); padding-right: 10px; margin: 0 0 12px; }
.rep-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.rep-box { border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.rep-box .n { font-size: 26px; font-weight: 800; color: var(--teal-700); }
.rep-box .l { font-size: 13px; color: var(--muted); }
table.rep-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rep-table th, table.rep-table td { border: 1px solid var(--line); padding: 9px 12px; text-align: center; }
table.rep-table th { background: var(--sand); color: var(--teal-900); font-weight: 700; }
table.rep-table tr:nth-child(even) td { background: #fbfaf6; }
.rep-foot { margin-top: 24px; padding-top: 14px; border-top: 1px dashed var(--line); text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 14px;
  font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 100;
  opacity: 0; transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: linear-gradient(135deg, var(--green), #15803d); }
.toast.error { background: linear-gradient(135deg, var(--rose), #be123c); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12, 40, 36, .5); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: #fff; border-radius: 20px; padding: 24px;
  width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); animation: rise .3s ease;
}
.modal-card h3 { margin: 0 0 18px; color: var(--teal-900); }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------- نمودار روزانه ---------- */
.daily-chart { width: 100%; }
.chart-legend { display: flex; gap: 18px; justify-content: center; margin-top: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ==================================================================
   ریسپانسیو موبایل
   ================================================================== */
@media (max-width: 760px) {
  .content { padding: 14px; }
  .cards-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .filters { justify-content: space-between; }
  .seg { flex: 1; }
  .seg-opt { flex: 1; text-align: center; padding: 9px 6px; }
  .guests-list { grid-template-columns: 1fr; }
  .rep-grid { grid-template-columns: repeat(2, 1fr); }
  .brand-text span { display: none; }
  .tabs { top: 64px; }
}
@media (max-width: 420px) {
  .btn-logout span { display: none; }
  .tab span { font-size: 13px; }
  .stat-value { font-size: 26px; }
}

/* ==================================================================
   چاپ
   ================================================================== */
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; height: auto !important; }

  /* همه‌ی صفحه پنهان، فقط محتوای گزارش چاپ شود */
  .topbar, .tabs, .no-print, .toast, .modal,
  #login-screen, .report-actions { display: none !important; }
  .page { display: none !important; }
  #page-report { display: block !important; }

  /* خنثی کردن چیدمان برای جلوگیری از صفحه‌ی خالی اضافه */
  .app { display: block !important; min-height: 0 !important; }
  .content { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .report-content { border: none !important; box-shadow: none !important; padding: 0 !important; }

  /* جدول‌ها: تکرار سرستون در هر صفحه و نشکستن ردیف‌ها */
  table.rep-table { page-break-inside: auto; width: 100%; border-collapse: collapse; }
  table.rep-table thead { display: table-header-group; }
  table.rep-table tr { page-break-inside: avoid; }
  .rep-section { page-break-inside: auto; margin-bottom: 18px; }
  .rep-section h3, .rep-header { page-break-after: avoid; }

  /* حفظ رنگ‌ها در چاپ */
  .rep-box, table.rep-table th, table.rep-table td { border-color: #999 !important; }
  table.rep-table th { background: #e9efee !important; }
  table.rep-table tr:nth-child(even) td { background: #f3f3f3 !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
