/* Kayren Nest — اپ پرستار در منزل. فقط وقتی clinic_type = nest بارگذاری می‌شود. */

/* ---- رنگ برند: زرشکیِ لوگو (صاحب پروژه، ۱۴۰۵/۰۹/۰۸) — جای آبی/بنفش Onyx، همه‌ی دکمه‌ها و آیتم‌های فعال ---- */
:root {
  --accent: #8A1C36; --accent-strong: #6E1129; --accent-tint: #F7EBEE; --accent-solid: #8A1C36;
  --teal: #8A1C36; --teal-strong: #6E1129; --teal-tint: #F7EBEE;
  --ios-blue: #8A1C36; --ios-purple: #8A1C36; --ios-teal: #8A1C36;
}
[data-theme="dark"] {
  --accent: #D46A82; --accent-strong: #E89AAC; --accent-tint: rgba(212,106,130,.15); --accent-solid: #9B2340;
  --teal: #D46A82; --teal-strong: #E89AAC; --teal-tint: rgba(212,106,130,.15);
  --ios-blue: #B83A57; --ios-purple: #B83A57; --ios-teal: #B83A57;
}

/* ---- نشان بالای صفحه: N لوگو + «Nest» ---- */
.nest-brand-mark { height: 29px; }
.nest-brand-word { letter-spacing: .06em; font-weight: 700; }
@media (max-width: 767px) { .nest-brand-mark { height: 24px; } .nest-brand-word { font-size: 14px; } }
/* حالت تاریک: N سیاه روی زمینه‌ی تیره دیده نمی‌شود؛ سفید می‌شود و زرشکی می‌ماند */
[data-theme="dark"] .nest-brand-mark { filter: invert(1) hue-rotate(180deg); }

/* ---- نوار پایین گوشی (منوی اصلی): داک شیشه‌ای شناور مثل تلگرام (صاحب پروژه، ۱۴۰۵/۰۹/۰۸) ----
   تب فعال پس‌زمینه‌ی خودش را ندارد؛ یک «قرص» (.nest-pill) زیر آن است که با زدن تب یا کشیدن انگشت روی
   داک سُر می‌خورد. --i شماره‌ی تب فعال (کسری هم می‌شود، هنگام کشیدن)، --n تعداد تب‌ها، --s جهت. */
.nest-tabbar { display: none; }
@media (max-width: 767px) {
  .nest-tabbar {
    --s: 1;
    display: flex; gap: 4px; position: fixed; z-index: 40;
    inset-inline: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 5px; border-radius: 26px;
    background: color-mix(in srgb, var(--surface) 76%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 30px rgba(30,36,51,.16), 0 2px 6px rgba(30,36,51,.06);
    transform: translateZ(0);   /* لایه‌ی جدا: آیفون گاهی نوار ثابتِ شیشه‌ای را بعد از کنار رفتن لوگوی شروع نمی‌کشید */
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  }
  [dir="rtl"] .nest-tabbar { --s: -1; }
  .nest-pill {
    position: absolute; z-index: -1; top: 5px; bottom: 5px; inset-inline-start: 5px;
    width: calc((100% - 10px - (var(--n) - 1) * 4px) / var(--n));
    border-radius: 21px; background: rgba(118,118,128,.16);
    translate: calc(var(--i) * (100% + 4px) * var(--s)) 0;
    transition: translate .45s cubic-bezier(.3,1.3,.5,1), scale .25s ease, opacity .2s ease;
  }
  .nest-pill.is-off { opacity: 0; }
  /* تبی که هنوز در حافظه نبود و از سرور می‌آید */
  .nest-tabbar.is-loading .nest-pill { animation: nest-pill-wait .9s ease-in-out infinite; }
  @keyframes nest-pill-wait { 50% { opacity: .45; } }
  /* کشیدن: قرص بی‌تأخیر دنبال انگشت و کمی بزرگ‌تر، مثل ذره‌بین داک تلگرام */
  .nest-tabbar.is-dragging .nest-pill { transition: scale .25s ease; scale: 1.08; }
  .nest-tab {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; border-radius: 21px; font-size: 11px; font-weight: 700; color: var(--text-secondary);
    text-decoration: none; transition: color .2s ease;
    -webkit-tap-highlight-color: transparent; -webkit-user-drag: none;
  }
  .nest-tab svg { width: 23px; height: 23px; transition: transform .25s cubic-bezier(.3,1.5,.5,1); }
  .nest-tab:active svg { transform: scale(.84); }
  .nest-tab.is-active { color: var(--accent); }
  .nest-tab.is-active svg { stroke-width: 2.2; }
  [data-theme="dark"] .nest-tabbar { background: color-mix(in srgb, var(--surface) 72%, transparent); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
  [data-theme="dark"] .nest-pill { background: rgba(255,255,255,.12); }
  /* جا برای نوار شناور، تا آخرین دکمه‌ی صفحه زیرش نرود */
  body:has(.nest-tabbar) { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
}

/* ---- جابه‌جایی بین تب‌ها مثل اپ ----
   main.php پنج صفحه‌ی نوار را از قبل می‌گیرد و @view-transition صفحه‌ی تازه را نرم جای قبلی می‌نشاند.
   داک ثابت می‌ماند، قرص از جای تب قبلی تا تب تازه سُر می‌خورد (لایه‌ی جدا، زیر تب‌ها) و فقط محتوا کوتاه
   محو و ظاهر می‌شود. مرورگری که پشتیبانی نکند: قرص در همان صفحه راه می‌افتد و صفحه‌ی بعد سر جایش باز می‌شود. */
@media (max-width: 767px) {
  .nest-tabbar { view-transition-name: nest-dock; }
  .nest-pill { view-transition-name: nest-pill; }
}
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
::view-transition-group(nest-dock) { animation-duration: .16s; }
::view-transition-group(nest-pill) { animation-duration: .45s; animation-timing-function: cubic-bezier(.3,1.3,.5,1); }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .nest-pill, .nest-tab svg { transition: none !important; }
}

/* ---- نشان Nest روی گوشی در همه‌ی صفحه‌ها ----
   app.css وقتی مسیر ناوبری (crumbs) پر است نشان را پنهان می‌کند، ولی روی گوشی خود مسیر ناوبری
   هیچ‌وقت دیده نمی‌شود؛ پس در صفحه‌های داخلی سربرگ خالی می‌ماند. (صاحب پروژه، ۱۴۰۵/۰۹/۰۸) */
@media (max-width: 767px) {
  .ios-header .crumbs:not([hidden]) + .nest-brand { display: flex; }
}

/* ---- نوار دوره‌ی آزمایشی ---- */
.nest-trial-bar {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: center;
  padding: 7px 16px; font-size: 13px; background: var(--teal-tint); color: var(--teal-strong);
  border-bottom: 1px solid var(--border-light);
}
.nest-trial-link { text-decoration: underline; text-underline-offset: 3px; }

/* ---- اجزای صفحه‌ها ---- */
.nest-page { max-width: 760px; margin: 0 auto; }
.nest-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.nest-title { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); }
.nest-sub { font-size: 13px; color: var(--text-secondary); }
.nest-muted { color: var(--text-muted); }

.nest-days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.nest-days::-webkit-scrollbar { display: none; }
.nest-day {
  flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: var(--radius-md); background: var(--surface);
  border: 1px solid var(--border-light); color: var(--text-secondary); text-decoration: none; font-size: 12px;
  box-shadow: var(--shadow-sm);
}
.nest-day b { font-size: 16px; color: var(--text-primary); }
.nest-day.is-active { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.nest-day.is-active b { color: #fff; }
.nest-day .nest-dot { min-width: 18px; height: 18px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--accent-tint); color: var(--accent-strong); padding: 0 4px; }
.nest-day.is-active .nest-dot { background: rgba(255,255,255,.25); color: #fff; }

.nest-visit { display: flex; flex-direction: column; gap: 10px; }
.nest-visit-top { display: flex; align-items: flex-start; gap: 12px; }
.nest-time { min-width: 56px; font-weight: 800; font-size: 15px; color: var(--accent-strong); direction: ltr; text-align: center; }
.nest-visit-name { font-weight: 700; color: var(--text-primary); }
.nest-address { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; color: var(--text-secondary); line-height: 1.7; }
.nest-address svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; }
.nest-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nest-actions .ios-btn { min-height: 44px; }
.nest-done { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--green-tint); color: var(--green); font-weight: 700; white-space: nowrap; }

.nest-allergy {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--red-tint); color: var(--red); font-weight: 700; font-size: 14px; line-height: 1.7;
}
.nest-allergy svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }

.nest-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 480px) { .nest-stats { grid-template-columns: 1fr 1fr; } .nest-stats > :first-child { grid-column: 1 / -1; } }
.nest-stat { padding: 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.nest-stat span { display: block; font-size: 12px; color: var(--text-secondary); }
.nest-stat b { display: block; font-size: 18px; margin-top: 4px; color: var(--text-primary); }

.nest-list { display: flex; flex-direction: column; }
.nest-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.nest-row:last-child { border-bottom: 0; }
a.nest-row { color: inherit; text-decoration: none; }

.nest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.nest-field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.nest-field .ios-input { width: 100%; }
.nest-section-title { font-weight: 700; margin-bottom: 10px; color: var(--text-primary); }

.nest-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.nest-switch input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent-solid); flex-shrink: 0; }
.nest-low { color: var(--red); font-weight: 700; }

/* ردیف دارو: گوشی دو ستون (نام تمام‌عرض)، دسکتاپ یک خط */
.nest-med-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.nest-med-row > :first-child { grid-column: 1 / 3; }
.nest-med-row > button { grid-column: 3; grid-row: 1; align-self: center; }
@media (min-width: 640px) {
  .nest-med-row { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .nest-med-row > :first-child { grid-column: auto; }
  .nest-med-row > button { grid-column: auto; grid-row: auto; }
}

/* ورودی‌های عددی روی آیفون با فونت کمتر از ۱۶ پیکسل صفحه را بزرگ می‌کنند */
@media (max-width: 767px) { .nest-page .ios-input { font-size: 16px; } }

@media print { .nest-tabbar, .nest-trial-bar { display: none !important; } }

/* تاریخ و ساعت روی گوشی هر کدام یک خط (فیلد تاریخ با دکمه‌ی تقویم در ۱۴۰ پیکسل جا نمی‌شد) */
.nest-grid.wide { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---- دکمه‌ی «برگشت»: قرمز Onyx کنار زرشکی برند شبیه بود؛ ذغالی (رنگ N لوگو) (صاحب پروژه، ۱۴۰۵/۰۹/۰۸) ---- */
.ios-btn-back { color: #2B2F36; }
.ios-btn-back-panel { background: #2B2F36; }
[data-theme="dark"] .ios-btn-back { color: #D7DAE0; }
[data-theme="dark"] .ios-btn-back-panel { background: #4A505C; }

/* ===== صفحه‌ی «اپ را نصب کنید» بعد از ثبت‌نام (nest/_install_gate.php) ===== */
html.nest-gate-open, html.nest-gate-open body { overflow: hidden; }
.nest-gate { position: fixed; inset: 0; z-index: 9999; overflow-y: auto; background: var(--bg, #F4F7F6);
  display: flex; align-items: flex-start; justify-content: center; padding: max(32px, env(safe-area-inset-top)) 16px 32px; }
.nest-gate[hidden] { display: none; }
.nest-gate-box { width: 100%; max-width: 420px; text-align: center; color: var(--text-primary); }
.nest-gate-icon { margin: 8px auto 16px; border-radius: 18px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.nest-gate-title { font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.nest-gate-lead { font-size: 14px; line-height: 1.9; color: var(--text-secondary); margin: 0 0 20px; }
.nest-gate-btn { width: 100%; min-height: 52px; font-size: 17px; }
.nest-gate-steps { list-style: none; margin: 0; padding: 0; text-align: right; display: flex; flex-direction: column; gap: 10px; }
.nest-gate-steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.9; }
.nest-gate-num { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-strong);
  font-weight: 800; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.nest-gate-ico { display: inline-block; width: 20px; height: 20px; vertical-align: -5px; color: var(--accent); }
.nest-gate-done { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 15px; line-height: 1.9; }
.nest-gate-done[hidden] { display: none; }
.nest-gate-done svg { width: 48px; height: 48px; color: #1F8A4C; }
.nest-gate-note { font-size: 12px; line-height: 1.9; color: var(--text-muted); margin: 20px 0 8px; }
.nest-gate-skip { background: none; border: 0; padding: 8px; font-size: 13px; color: var(--text-secondary);
  text-decoration: underline; cursor: pointer; }
[data-theme="dark"] .nest-gate-steps li { border-color: rgba(255,255,255,.08); }

/* ===== لوگوی متحرک هنگام باز شدن اپ (nest/_splash.php)، مثل X و تلگرام =====
   قاب اول باید دقیقاً صفحه‌ی شروع گوشی باشد: زمینه‌ی سفید مانیفست + آیکون هم‌اندازه‌ی آیکون صفحه‌ی شروع اندروید. در حالت تاریک هم سفید، چون صفحه‌ی شروع گوشی سفید است. */
.nest-splash { display: none; }
.nest-splash.is-on {
  --nest-splash-icon: 246px;   /* N = نصف عرض صفحه، مثل آیکون صفحه‌ی شروع اندروید (۲۴۰dp؛ از فیلم گوشی صاحب پروژه اندازه شد) */
  padding-bottom: 28px;         /* صفحه‌ی شروع اندروید وسط کل صفحه است (با نوار وضعیت)؛ اپ زیر نوار وضعیت: ۱۴ پیکسل بالاتر */
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0; z-index: 10000; background: #FFFFFF;
}
.nest-splash-icon { width: var(--nest-splash-icon); height: var(--nest-splash-icon); display: block; will-change: transform, opacity; }
/* بعد از بار شدن صفحه: کمی جمع، بعد بزرگ و محو؛ پرده هم‌زمان کنار می‌رود */
.nest-splash.is-go { animation: nest-splash-out .32s ease-in .26s forwards; }
.nest-splash.is-go .nest-splash-icon { animation: nest-splash-zoom .58s forwards; }
@keyframes nest-splash-zoom {
  0%   { transform: scale(1); animation-timing-function: cubic-bezier(.45,0,.55,1); }
  30%  { transform: scale(.86); opacity: 1; animation-timing-function: cubic-bezier(.6,0,.9,.4); }
  100% { transform: scale(5); opacity: 0; }
}
@keyframes nest-splash-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .nest-splash.is-go .nest-splash-icon { animation: none; }
  .nest-splash.is-go { animation-delay: 0s; }
}
