/*
 * sileo برای دلارکس — همان styles.css کتابخانه‌ی sileo (github.com/hiaaryan/sileo، MIT) با سه تفاوت:
 * راست‌به‌چپ و فونت Estedad، جای پایین وسط با فاصله‌ی امن گوشی، و رنگ/منحنیِ جایگزین برای مرورگرهای قدیمی‌تر.
 */

/* -------------------------------- Variables ------------------------------- */

:root {
  /* جایگزین برای مرورگری که linear() ندارد؛ پایین‌تر با @supports همان منحنی فنری اصلی می‌نشیند */
  --sileo-spring-easing: cubic-bezier(0.22, 1.25, 0.36, 1);
  --sileo-duration: 600ms;
  --sileo-height: 40px;
  --sileo-width: 350px;

  --sileo-state-success: #22c55e;
  --sileo-state-loading: #737373;
  --sileo-state-error: #ef4444;
  --sileo-state-warning: #eab308;
  --sileo-state-info: #0ea5e9;
  --sileo-state-action: #3b82f6;
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --sileo-spring-easing: linear(
      0, 0.002 0.6%, 0.007 1.2%, 0.015 1.8%, 0.026 2.4%, 0.041 3.1%, 0.06 3.8%, 0.108 5.3%, 0.157 6.6%, 0.214 8%,
      0.467 13.7%, 0.577 16.3%, 0.631 17.7%, 0.682 19.1%, 0.73 20.5%, 0.771 21.8%, 0.808 23.1%, 0.844 24.5%,
      0.874 25.8%, 0.903 27.2%, 0.928 28.6%, 0.952 30.1%, 0.972 31.6%, 0.988 33.1%, 1.01 35.7%, 1.025 38.5%,
      1.034 41.6%, 1.038 45%, 1.035 50.1%, 1.012 64.2%, 1.003 73%, 0.999 83.7%, 1
    );
  }
}

@supports (color: oklch(0 0 0)) {
  :root {
    --sileo-state-success: oklch(0.723 0.219 142.136);
    --sileo-state-loading: oklch(0.556 0 0);
    --sileo-state-error: oklch(0.637 0.237 25.331);
    --sileo-state-warning: oklch(0.795 0.184 86.047);
    --sileo-state-info: oklch(0.685 0.169 237.323);
    --sileo-state-action: oklch(0.623 0.214 259.815);
  }
}

/* پیام‌های سرور (flash) تا sileo بخواندشان دیده نمی‌شوند */
.flash-msg[data-autohide]:not([data-sileo-toast]) { display: none !important; }

/* ---------------------------------- Toast --------------------------------- */

[data-sileo-toast] {
  position: relative;
  display: block;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  box-shadow: none;
  outline: none;
  width: var(--sileo-width);
  height: var(--_h, var(--sileo-height));
  opacity: 0;
  transform: translateZ(0) scale(0.95);
  transform-origin: center;
  contain: layout style;
  overflow: visible;
  font-family: inherit;
  direction: rtl;
  -webkit-tap-highlight-color: transparent;
}

[data-sileo-toast][data-state="loading"] {
  cursor: default;
}

[data-sileo-toast][data-ready="true"] {
  opacity: 1;
  transform: translateZ(0) scale(1);
  transition:
    transform calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
    opacity calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
    margin-bottom calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
    margin-top calc(var(--sileo-duration) * 0.66) var(--sileo-spring-easing),
    height var(--sileo-duration) var(--sileo-spring-easing);
}

/* Entry animation direction */
[data-sileo-viewport][data-position^="top"] [data-sileo-toast]:not([data-ready="true"]) {
  transform: translateY(-6px) scale(0.95);
}

[data-sileo-viewport][data-position^="bottom"] [data-sileo-toast]:not([data-ready="true"]) {
  transform: translateY(6px) scale(0.95);
}

/* Exit */
[data-sileo-toast][data-ready="true"][data-exiting="true"] {
  opacity: 0;
  pointer-events: none;
}

[data-sileo-viewport][data-position^="top"] [data-sileo-toast][data-ready="true"][data-exiting="true"] {
  transform: translateY(-6px) scale(0.95);
}

[data-sileo-viewport][data-position^="bottom"] [data-sileo-toast][data-ready="true"][data-exiting="true"] {
  transform: translateY(6px) scale(0.95);
}

/* ------------------------------- SVG Canvas ------------------------------- */

[data-sileo-canvas] {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  transform: translateZ(0);
  contain: layout style;
  overflow: visible;
}

[data-sileo-canvas][data-edge="top"] {
  bottom: 0;
  transform: scaleY(-1) translateZ(0);
}

[data-sileo-canvas][data-edge="bottom"] {
  top: 0;
}

[data-sileo-svg] {
  display: block;
  overflow: visible;
}

/* --------------------------------- Header --------------------------------- */

[data-sileo-header] {
  position: absolute;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 0.5rem;
  height: var(--sileo-height);
  box-sizing: border-box;
  overflow: hidden;
  left: var(--_px, 0px);
  transform: var(--_ht);
  max-width: var(--_pw);
}

[data-sileo-toast][data-ready="true"] [data-sileo-header] {
  transition:
    transform var(--sileo-duration) var(--sileo-spring-easing),
    left var(--sileo-duration) var(--sileo-spring-easing),
    max-width var(--sileo-duration) var(--sileo-spring-easing);
}

[data-sileo-header][data-edge="top"] {
  bottom: 0;
}

[data-sileo-header][data-edge="bottom"] {
  top: 0;
}

/* Header inner morphing */
[data-sileo-header-stack] {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
}

[data-sileo-header-inner] {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  opacity: 1;
  filter: blur(0px);
  transform: translateZ(0);
}

[data-sileo-header-inner][data-layer="current"] {
  position: relative;
  z-index: 1;
  animation: sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both;
}

[data-sileo-header-inner][data-layer="current"]:not(:only-child),
[data-sileo-header-inner][data-exiting="true"] {
  will-change: opacity, filter;
}

[data-sileo-header-inner][data-layer="prev"] {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

[data-sileo-header-inner][data-exiting="true"] {
  animation: sileo-header-exit calc(var(--sileo-duration) * 0.7) ease forwards;
}

/* ---------------------------------- Badge --------------------------------- */

[data-sileo-badge] {
  display: flex;
  height: 24px;
  width: 24px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: 2px;
  box-sizing: border-box;
  border-radius: 9999px;
  color: var(--sileo-tone, currentColor);
  background-color: var(--sileo-tone-bg, transparent);
}

[data-sileo-badge] svg {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------------------------------- Title --------------------------------- */

[data-sileo-title] {
  font-size: 0.825rem;
  line-height: 1rem;
  font-weight: 500;
  color: var(--sileo-tone, currentColor);
}

/* ------------------------------ State Colors ------------------------------ */

[data-sileo-badge][data-state],
[data-sileo-title][data-state],
[data-sileo-button][data-state] {
  --_c: var(--sileo-state-success);
}

[data-sileo-badge][data-state="loading"],
[data-sileo-title][data-state="loading"],
[data-sileo-button][data-state="loading"] {
  --_c: var(--sileo-state-loading);
}

[data-sileo-badge][data-state="error"],
[data-sileo-title][data-state="error"],
[data-sileo-button][data-state="error"] {
  --_c: var(--sileo-state-error);
}

[data-sileo-badge][data-state="warning"],
[data-sileo-title][data-state="warning"],
[data-sileo-button][data-state="warning"] {
  --_c: var(--sileo-state-warning);
}

[data-sileo-badge][data-state="info"],
[data-sileo-title][data-state="info"],
[data-sileo-button][data-state="info"] {
  --_c: var(--sileo-state-info);
}

[data-sileo-badge][data-state="action"],
[data-sileo-title][data-state="action"],
[data-sileo-button][data-state="action"] {
  --_c: var(--sileo-state-action);
}

[data-sileo-badge][data-state],
[data-sileo-title][data-state] {
  --sileo-tone: var(--_c);
  --sileo-tone-bg: rgba(128, 128, 128, 0.2);
}

@supports (background: color-mix(in oklch, red 20%, transparent)) {
  [data-sileo-badge][data-state],
  [data-sileo-title][data-state] {
    --sileo-tone-bg: color-mix(in oklch, var(--_c) 20%, transparent);
  }
}

/* --------------------------------- Content -------------------------------- */

[data-sileo-content] {
  position: absolute;
  left: 0;
  z-index: 10;
  width: 100%;
  pointer-events: none;
  opacity: var(--_co, 0);
}

[data-sileo-content]:not([data-visible="true"]) {
  content-visibility: hidden;
}

[data-sileo-toast][data-ready="true"] [data-sileo-content] {
  transition: opacity calc(var(--sileo-duration) * 0.08) ease calc(var(--sileo-duration) * 0.04);
}

[data-sileo-content][data-edge="top"] {
  top: 0;
}

[data-sileo-content][data-edge="bottom"] {
  top: var(--sileo-height);
}

[data-sileo-content][data-visible="true"] {
  pointer-events: auto;
}

[data-sileo-toast][data-ready="true"] [data-sileo-content][data-visible="true"] {
  transition: opacity calc(var(--sileo-duration) * 0.6) ease calc(var(--sileo-duration) * 0.3);
}

[data-sileo-description] {
  width: 100%;
  box-sizing: border-box;
  text-align: right;
  direction: rtl;
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  white-space: normal;
  overflow-wrap: anywhere;
  /* در اصل contain + content-visibility: auto برای کارایی؛ با متن فارسیِ چندخطی ارتفاع توضیح را فقط به‌اندازه‌ی
     padding گزارش می‌کرد و بدنه کوتاه می‌ماند (متن روی قرص می‌افتاد) */
}

/* --------------------------------- Button --------------------------------- */

[data-sileo-button] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  height: 1.75rem;
  padding: 0 0.625rem;
  margin-top: 0.75rem;
  border-radius: 9999px;
  border: 0;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  color: var(--sileo-btn-color, currentColor);
  background-color: var(--sileo-btn-bg, transparent);
  transition: background-color 150ms ease;
}

[data-sileo-button]:hover {
  background-color: var(--sileo-btn-bg-hover, transparent);
}

[data-sileo-button][data-state] {
  --sileo-btn-color: var(--_c);
  --sileo-btn-bg: rgba(128, 128, 128, 0.15);
  --sileo-btn-bg-hover: rgba(128, 128, 128, 0.25);
}

@supports (background: color-mix(in oklch, red 20%, transparent)) {
  [data-sileo-button][data-state] {
    --sileo-btn-bg: color-mix(in oklch, var(--_c) 15%, transparent);
    --sileo-btn-bg-hover: color-mix(in oklch, var(--_c) 25%, transparent);
  }
}

/* -------------------------------- Animations ------------------------------ */

[data-sileo-icon="spin"] {
  animation: sileo-spin 1s linear infinite;
}

@keyframes sileo-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes sileo-header-enter {
  from {
    opacity: 0;
    filter: blur(6px);
  }
  to {
    opacity: 1;
    filter: blur(0px);
  }
}

@keyframes sileo-header-exit {
  from {
    opacity: 1;
    filter: blur(0px);
  }
  to {
    opacity: 0;
    filter: blur(6px);
  }
}

/* -------------------------------- Viewports ------------------------------- */

[data-sileo-viewport] {
  position: fixed;
  z-index: 10050;                 /* بالای منو، پنجره‌ها و نوار پایین پرونده‌ی تماس */
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  pointer-events: none;
  max-width: calc(100vw - 1.5rem);
  contain: layout style;
  font-family: inherit;
  direction: rtl;
}

[data-sileo-viewport][data-position^="top"] [data-sileo-toast]:not([data-ready="true"]) {
  margin-bottom: calc(-1 * (var(--sileo-height) + 0.75rem));
}

[data-sileo-viewport][data-position^="bottom"] [data-sileo-toast]:not([data-ready="true"]) {
  margin-top: calc(-1 * (var(--sileo-height) + 0.75rem));
}

/* Vertical edge */
[data-sileo-viewport][data-position^="top"] {
  top: 0;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  flex-direction: column-reverse;
}

[data-sileo-viewport][data-position^="bottom"] {
  bottom: 0;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  flex-direction: column;
}

/* Horizontal alignment */
[data-sileo-viewport][data-position$="left"] {
  left: 0;
  align-items: flex-start;
}

[data-sileo-viewport][data-position$="right"] {
  right: 0;
  align-items: flex-end;
}

[data-sileo-viewport][data-position$="center"] {
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

/* گوشی: بالای نوار ثابت پایین پرونده‌ی تماس (تماس / ثبت تماس) */
@media (max-width: 640px) {
  body:has(.cc-mbar) [data-sileo-viewport][data-position^="bottom"] {
    bottom: 76px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  [data-sileo-toast][data-ready="true"]:hover,
  [data-sileo-toast][data-ready="true"][data-exiting="true"] {
    will-change: transform, opacity, height;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-sileo-viewport],
  [data-sileo-viewport] *,
  [data-sileo-viewport] *::before,
  [data-sileo-viewport] *::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
  }
}

/* --------------------------------- Themes -------------------------------- */

[data-sileo-viewport][data-theme="dark"] [data-sileo-description] {
  color: rgba(0, 0, 0, 0.5);
}

[data-sileo-viewport][data-theme="light"] [data-sileo-description] {
  color: rgba(255, 255, 255, 0.5);
}
