:root {
  --dastano-like: #ff2f4e;
  --dastano-shadow: 0 24px 80px rgba(16, 24, 40, 0.25);
  --dastano-radius: 20px;
}

/* بخش اصلی استوری‌ها */
#dastano-stories,
.dastano-stories-section {
  position: relative;
  width: 100%;
  margin: 20px auto;
  padding: 10px 0;
  overflow: visible;
  direction: ltr; /* برای سازگاری درگ اسکرول طبیعی */
}

.dastano-stories-header {
  max-width: 1280px;
  margin: 0 auto 12px;
  padding: 0 20px;
  direction: rtl;
}

.dastano-stories-title {
  font-size: 18px;
  font-weight: bold;
  color: #2c3338;
  margin: 0;
}

/* رپ درگ شونده رینگ‌ها */
.dastano-stories-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  -ms-overflow-style: none;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  direction: rtl; /* برای نمایش راست به چپ در زبان فارسی */
}

.dastano-stories-wrap.grabbing {
  cursor: grabbing;
}

.dastano-stories-wrap::-webkit-scrollbar {
  display: none;
}

/* اسکلتون لودینگ پیش‌فرض */
.dastano-stories-loading {
  display: flex;
  gap: 16px;
}

.dastano-story-ring.skeleton {
  opacity: 1;
}

.skeleton-border {
  background: linear-gradient(90deg, #eceff1 25%, #cfd8dc 50%, #eceff1 75%) !important;
  background-size: 200% 100% !important;
  animation: dastano-skeleton 1.5s infinite !important;
}

.skeleton-thumb {
  background: #e2e8f0 !important;
}

.skeleton-title {
  background: linear-gradient(90deg, #eceff1 25%, #cfd8dc 50%, #eceff1 75%) !important;
  background-size: 200% 100% !important;
  animation: dastano-skeleton 1.5s infinite !important;
  height: 12px !important;
  border-radius: 6px !important;
  margin-top: 8px !important;
}

@keyframes dastano-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* حلقه استوری (Story Ring) */
.dastano-story-ring {
  flex: 0 0 auto;
  width: 84px;
  text-align: center;
  transition: transform 0.2s ease;
}

.dastano-story-ring:hover {
  transform: translateY(-2px);
}

.dastano-story-ring .ring-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: block;
  outline: none;
}

/* بورد دایره‌ای رینگ */
.dastano-story-ring .ring-border {
  width: 74px;
  height: 74px;
  margin: 0 auto;
  border-radius: 50%;
  padding: 3px;
  position: relative;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

/* حالت دیده نشده (گرادیان نئونی و پالس) */
.dastano-story-ring:not(.seen) .ring-border {
  background: conic-gradient(#ff007f, #ff5e36, #ff007f);
}

.dastano-story-ring:not(.seen) .ring-border::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 0, 127, 0.4);
  animation: dastano-pulse 1.8s infinite ease-out;
}

@keyframes dastano-pulse {
  0% { opacity: 0.9; transform: scale(0.96); }
  100% { opacity: 0; transform: scale(1.12); }
}

/* حالت دیده شده (خاکستری آرام) */
.dastano-story-ring.seen .ring-border {
  background: #cbd5e1;
}

.dastano-story-ring .ring-thumb {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #fff;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border: 2px solid #fff;
  box-sizing: border-box;
}

/* عنوان زیر استوری */
.dastano-story-ring .ring-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  line-height: 1.3;
  height: 2.6em;
  direction: rtl;
}

/* ==========================================================================
   لایه نمایشگر تمام‌صفحه استوری (Story Overlay & Viewer)
   ========================================================================== */
.dastano-story-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  pointer-events: none;
  transition: background 0.3s ease;
}

.dastano-story-overlay[style*="flex"] {
  pointer-events: auto;
}

.dastano-story-viewer {
  width: min(390px, 92vw);
  height: min(84vh, 760px);
  border-radius: var(--dastano-radius);
  background: #000;
  box-shadow: var(--dastano-shadow);
  position: relative;
  overflow: hidden;
  touch-action: none;
  display: flex;
  flex-direction: column;
}

/* بخش مدیا */
.dastano-story-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 1;
}

.dastano-story-media img,
.dastano-story-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
}

/* نوار پیشرفت چنداسلایدی (Progress Bars) */
.dastano-story-progress-bars {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  flex-direction: row-reverse; /* برای ترتیب فارسی */
}

.dastano-story-progress-segment {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  overflow: hidden;
}

.dastano-story-progress-fill {
  width: 0%;
  height: 100%;
  background: #ffffff;
  border-radius: inherit;
  transition: width 0.08s linear;
  float: left;
}

/* نواحی کلیک اسلاید قبلی و بعدی */
.dastano-story-tap-left,
.dastano-story-tap-right {
  position: absolute;
  top: 55px;
  bottom: 80px;
  width: 35%;
  z-index: 5;
  cursor: pointer;
}

.dastano-story-tap-left { left: 0; }
.dastano-story-tap-right { right: 0; }

/* هدر بالایی استوری */
.dastano-story-top {
  position: absolute;
  top: 26px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 8;
  direction: rtl;
}

.dastano-story-author-ava {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background-color: #333;
  background-position: center;
  background-size: cover;
}

.dastano-story-author {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.dastano-story-author strong {
  font-size: 14px;
  font-weight: 700;
}

.dastano-story-author small {
  font-size: 11px;
  opacity: 0.85;
}

.dastano-story-spacer {
  flex: 1;
}

.dastano-story-icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.dastano-story-icon-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: scale(1.05);
}

/* دکمه شیک تنظیم صدا و پخش خودکار */
.dastano-story-sound-toggle {
  position: absolute;
  top: 68px;
  right: 14px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 12;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  outline: none;
}

.dastano-story-sound-toggle:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.05);
}

.dastano-story-sound-toggle .icon-sound svg {
  display: block;
}

/* بج بی‌صدا / باصدا */
.dastano-story-muted-badge {
  position: absolute;
  top: 72px;
  right: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  display: none;
  z-index: 9;
  backdrop-filter: blur(4px);
}

/* دکمه‌های کناری (لایک، کامنت، محصول) */
.dastano-story-side {
  position: absolute;
  right: 14px;
  bottom: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 8;
}

.dastano-story-side .act {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: none;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(10px);
  outline: none;
  padding: 0;
}

.dastano-story-side .act:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

.dastano-story-side .count {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.dastano-story-side .act.hearted {
  background: rgba(255, 47, 78, 0.25) !important;
}

.dastano-story-side .act.hearted .icon-heart {
  fill: var(--dastano-like) !important;
}

/* انیمیشن پرواز قلب دابل‌تپ */
.dastano-story-heart-fx {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 80px;
  color: #ff2f4e;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 4px 20px rgba(255, 47, 78, 0.5);
}

@keyframes heartPop {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(1); opacity: 0; }
}

/* تولتیپ کلیک محصول */
.dastano-story-prod-tip {
  position: absolute;
  right: 68px;
  bottom: 125px;
  background: #ffffff;
  color: #1e293b;
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9;
  direction: rtl;
  white-space: nowrap;
}

.dastano-story-prod-tip.show {
  opacity: 1;
  transform: translateX(0);
}

/* کپشن استوری */
.dastano-story-caption {
  position: absolute;
  bottom: 48px;
  left: 14px;
  right: 14px;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  direction: rtl;
  z-index: 8;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* اسکراب تایم‌لاین ویدیو */
.dastano-story-scrub {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 8;
  direction: ltr;
}

.dastano-story-elapsed {
  color: #fff;
  font-size: 11px;
  font-family: monospace;
  opacity: 0.9;
}

.dastano-story-seek {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.dastano-story-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

/* ==========================================================================
   پنل نظرات (Comments Drawer)
   ========================================================================== */
.dastano-story-comments-panel {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  z-index: 25;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  direction: rtl;
}

.dastano-story-comments-panel.open {
  transform: translateY(0);
}

.dastano-story-cp-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
}

.dastano-story-cp-header strong {
  font-size: 15px;
}

.dastano-story-cp-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.dastano-story-cp-list {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dastano-story-cp-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  border-radius: 10px;
}

.dastano-story-cp-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.dastano-story-cp-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.dastano-story-cp-name {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.dastano-story-cp-content {
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.4;
}

.dastano-story-cp-replies {
  margin-top: 8px;
  padding-right: 14px;
  border-right: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dastano-story-cp-empty {
  text-align: center;
  color: #94a3b8;
  padding: 30px 0;
  font-size: 13px;
}

.dastano-story-cp-input {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 8px;
}

.dastano-story-cp-input input {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 8px 14px;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.dastano-story-cp-input input::placeholder {
  color: #94a3b8;
}

.dastano-story-cp-input button {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 0 16px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.dastano-story-cp-input button:hover {
  background: #2563eb;
}

/* رسپانسیو */
@media (max-width: 576px) {
  .dastano-story-viewer {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}

/* کلاس‌های کمکی و استایل‌های المنتور */
.dastano-stories-section.dst-hide-titles .ring-title {
  display: none !important;
}

.dastano-stories-section.dst-disable-pulse .ring-border::before {
  display: none !important;
}

/* اعلان شناور داخل پلیر */
.dastano-player-toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.dastano-player-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
