
.jalali-anchor{ position: relative; }

/*
  Modern Jalali Date & Date-Range Picker (Airbnb-like)
  - Popover is positioned via JS (fixed) to avoid clipping in cards/sticky containers.
  - On mobile it becomes a bottom sheet.
*/

.jalali-pop{
  position: fixed;
  z-index: 1080;
  background: var(--surface);
  border: 1px solid rgba(2,6,23,.10);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 12px;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  animation: jpIn .16s ease both;
}

.jalali-pop.jp-sheet{
  left: 12px !important;
  right: 12px !important;
  bottom: 12px !important;
  top: auto !important;
  width: auto !important;
  border-radius: 26px;
  box-shadow: 0 30px 90px rgba(2,6,23,.22);
}

@keyframes jpIn{
  from{ opacity:0; transform: translateY(-6px) scale(.99); }
  to{ opacity:1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce){
  .jalali-pop{ animation: none; }
  .jp-btn, .jp-day{ transition: none; }
}

.jp-top{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  position: sticky;
  top: 0;
  padding: 6px 0;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(12px);
  z-index: 2;
}

.jp-title{
  display:flex;
  align-items:center;
  gap: 8px;
  font-weight: 900;
}

.jp-actions{ display:flex; align-items:center; gap: 6px; flex-wrap: wrap; }

.jp-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 6px;
  padding: .42rem .6rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.72);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  user-select: none;
}

.jp-btn:hover{ transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.jp-btn:active{ transform: translateY(0); }

.jp-btn--primary{
  border: 0;
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 12px 30px rgba(79,70,229,.18);
}

.jp-note{
  font-size: .85rem;
  color: var(--muted);
  margin-top: 6px;
}

.jp-months{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 992px){
  .jp-months{ grid-template-columns: 1fr 1fr; }
}

.jp-month{
  border: 1px solid rgba(2,6,23,.08);
  border-radius: 20px;
  padding: 10px;
  background: rgba(255,255,255,.72);
}

.jp-month-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.jp-month-name{ font-weight: 900; letter-spacing: -.2px; }

.jp-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.jp-weekday{
  text-align:center;
  font-size: .78rem;
  color: var(--muted);
  padding: .2rem 0;
}

.jp-day{
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(2,6,23,.08);
  background: rgba(255,255,255,.75);
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  font-weight: 800;
}

.jp-day:hover{ transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.jp-day.is-out{
  opacity: .28;
  pointer-events: none;
}

.jp-day.is-disabled{
  opacity: .35;
  pointer-events: none;
  filter: grayscale(.2);
}

.jp-day.is-today{
  border-color: rgba(79,70,229,.45);
  background: var(--grad-primary-soft);
}

.jp-day.is-start,
.jp-day.is-end{
  border: 0;
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 16px 40px rgba(79,70,229,.18);
}

.jp-day.is-inrange{
  background: var(--grad-primary-soft);
  border-color: rgba(79,70,229,.18);
}

.jp-footer{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  margin-top: 10px;
}

.jp-pill{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: .35rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.7);
  font-size: .85rem;
  color: var(--muted);
}

.jp-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.18);
  z-index: 1070;
  backdrop-filter: blur(2px);
  animation: jpFade .15s ease both;
}

@keyframes jpFade{
  from{ opacity:0; }
  to{ opacity:1; }
}

/* Stage 5 calendar visibility and stacking fixes */
.jalali-pop{
  z-index: 6200 !important;
  background: #ffffff !important;
  border-color: #dfe3ef !important;
  box-shadow: 0 30px 90px rgba(20, 28, 55, .28) !important;
}
.jp-backdrop{z-index:6100 !important;background:rgba(15,23,42,.28)!important}
.jp-top{background:rgba(255,255,255,.96)!important}
.jp-month{background:#fff!important;border-color:#e4e7f0!important}
.jp-day{
  background:#fff!important;
  color:#263044!important;
  -webkit-text-fill-color:#263044!important;
  border-color:#e3e6ef!important;
}
.jp-day:hover:not(.is-disabled):not(.is-out){
  border-color:#9a70bd!important;
  background:#f3f1ff!important;
  color:#4B226E!important;
  -webkit-text-fill-color:#4B226E!important;
}
.jp-day.is-today:not(.is-start):not(.is-end){
  border:2px solid #7443A8!important;
  background:#fff!important;
  color:#4B226E!important;
  -webkit-text-fill-color:#4B226E!important;
  box-shadow:inset 0 0 0 2px rgba(116,67,168,.08)!important;
}
.jp-day.is-inrange:not(.is-start):not(.is-end){
  background:#eadff0!important;
  border-color:#d2bddf!important;
  color:#4B226E!important;
  -webkit-text-fill-color:#4B226E!important;
  box-shadow:none!important;
}
.jp-day.is-start,
.jp-day.is-end{
  background:#7443A8!important;
  background-image:linear-gradient(135deg,#7443A8,#5A2D82)!important;
  border-color:#5A2D82!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
  box-shadow:0 8px 24px rgba(116,67,168,.38)!important;
  outline:3px solid rgba(116,67,168,.16)!important;
  outline-offset:1px;
}
.jp-day.is-start::after,.jp-day.is-end::after{
  content:"";position:absolute;width:6px;height:6px;border-radius:50%;background:#fff;bottom:4px;
}
.jp-day{position:relative}
.jp-day.is-disabled,.jp-day.is-out{
  color:#aeb5c3!important;
  -webkit-text-fill-color:#aeb5c3!important;
  background:#f7f8fb!important;
}
@media(max-width:575.98px){
  .jalali-pop.jp-sheet{z-index:6200!important;max-height:min(82vh,720px);padding-bottom:max(14px,env(safe-area-inset-bottom))}
  .jp-backdrop{z-index:6100!important}
}

/* Stage 6 calendar palette */
.jalali-picker,.jalali-picker *{--jp-primary:#7443A8;--jp-cyan:#6BC7D6;--jp-yellow:#F4C430}
.jalali-day.is-range-start,.jalali-day.is-range-end,.jalali-picker [data-range-start],.jalali-picker [data-range-end]{background:linear-gradient(135deg,#7443A8,#5A2D82)!important;color:#fff!important;box-shadow:0 0 0 3px rgba(107,199,214,.36),0 8px 16px rgba(116,67,168,.24)!important}
.jalali-day.is-in-range,.jalali-picker [data-in-range]{background:#eadff0!important;color:#4B226E!important}
.jalali-day.is-today{border-color:#F4C430!important;box-shadow:inset 0 0 0 1px #F4C430!important}
