/* ============================================
   استوری و هایلایت اینستاگرام - استایل با پشتیبانی RTL
   ============================================ */

.igs-container {
	--igs-ring-size: 72px;
	--igs-ring-name-size: 12px;
	--igs-ring-border: 3px;
	--igs-ring-gap: 16px;
	--igs-progress-height: 3px;
	--igs-radius: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, "Helvetica Neue", sans-serif;
	max-width: 100%;
	padding: 16px 0;
}

.igs-title {
	margin: 0 0 12px;
	font-size: 1.1rem;
	font-weight: 600;
}

/* بخش‌ها و برچسب ردیف استوری / هایلایت */
.igs-section {
	margin-bottom: 20px;
}
.igs-section:last-child {
	margin-bottom: 0;
}
.igs-section-label {
	margin: 0 0 8px;
	font-size: 13px;
	font-weight: 600;
	color: #262626;
	opacity: 0.85;
}
.igs-section-highlights .igs-section-label {
	margin-top: 4px;
}

.igs-stories-row,
.igs-highlights-row,
.igs-single-row {
	display: flex;
	gap: var(--igs-ring-gap);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 4px 0;
	margin-bottom: 16px;
	align-items: flex-start;
}

.igs-stories-row:last-child,
.igs-highlights-row:last-child,
.igs-single-row:last-child {
	margin-bottom: 0;
}

.igs-stories-row::-webkit-scrollbar,
.igs-highlights-row::-webkit-scrollbar,
.igs-single-row::-webkit-scrollbar {
	display: none;
}

/* دایره استوری / هایلایت */
.igs-story-ring,
.igs-highlight-ring {
	--size: var(--igs-ring-size);
	flex: 0 0 var(--size);
	width: var(--size);
	min-height: calc(var(--size) + 22px);
	border: none;
	background: transparent;
	cursor: pointer;
	padding: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.igs-story-ring:hover,
.igs-highlight-ring:hover {
	transform: scale(1.08);
}
.igs-highlight-ring:hover {
	background: transparent !important;
}

.igs-story-ring:active,
.igs-highlight-ring:active {
	transform: scale(0.98);
}

.igs-ring-outer {
	display: block;
	width: var(--igs-ring-size);
	height: var(--igs-ring-size);
	flex-shrink: 0;
	border-radius: 50%;
	overflow: hidden;
	box-sizing: border-box;
}

.igs-ring-img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background-size: cover;
	background-position: center;
	background-color: #333;
	box-sizing: border-box;
	display: block;
}

.igs-story-ring .igs-ring-outer {
	padding: var(--igs-ring-border);
	background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}
.igs-story-ring .igs-ring-outer .igs-ring-img {
	border: 2px solid #fff;
}

/* اولین استوری: بوردر گرادیانی متحرک */
.igs-story-ring.igs-first-story .igs-ring-outer {
	background: linear-gradient(90deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888, #f09433);
	background-size: 200% 100%;
	animation: igs-gradient-flow 2.5s linear infinite;
}
@keyframes igs-gradient-flow {
	0% { background-position: 0% 50%; }
	100% { background-position: 200% 50%; }
}
.igs-story-ring.igs-first-story:hover .igs-ring-outer {
	animation-duration: 1.5s;
}

.igs-highlight-ring .igs-ring-outer {
	border: var(--igs-ring-border) solid #ddd;
}
.igs-highlight-ring .igs-ring-outer .igs-ring-img {
	border: none;
}

.igs-ring-name {
	font-size: var(--igs-ring-name-size);
	color: #262626;
	max-width: var(--igs-ring-size);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: center;
	line-height: 1.2;
}

/* راست‌چین: جهت اسکرول و چیدمان */
.igs-container.igs-rtl .igs-stories-row,
.igs-container.igs-rtl .igs-highlights-row,
.igs-container.igs-rtl .igs-single-row {
	direction: rtl;
}

.igs-container.igs-rtl .igs-ring-name {
	direction: rtl;
}

/* ========== مودال ویور ========== */
.igs-viewer {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: #000;
	display: none;
	align-items: center;
	justify-content: center;
	touch-action: none;
}

.igs-viewer.igs-open {
	display: flex;
	flex-direction: column;
}

.igs-viewer.igs-rtl {
	direction: rtl;
}

/* wrapper برای سوایپ: نوار پیشرفت + استیج با هم جابه‌جا می‌شوند */
.igs-viewer-inner {
	position: relative;
	width: 100%;
	max-width: 420px;
	display: flex;
	flex-direction: column;
	align-items: center;
	will-change: transform;
	perspective: 1200px;
}

/* استیج سه‌بعدی برای ورق زدن استوری */
.igs-viewer-stage {
	position: relative;
	width: 100%;
	max-width: 420px;
	height: 0;
	padding-bottom: calc(16 / 9 * 100%); /* aspect-ratio 9/16 */
	flex-shrink: 0;
	perspective: 1400px;
	transform-style: preserve-3d;
	overflow: hidden;
}

/* هر «ورق» استوری */
.igs-viewer-face {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	backface-visibility: hidden;
}

.igs-viewer-face.igs-next {
	visibility: hidden;
	pointer-events: none;
}

.igs-viewer-face .igs-viewer-content {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	max-width: none;
	border-radius: var(--igs-radius);
	overflow: hidden;
	background: #000;
	transform-style: preserve-3d;
	backface-visibility: hidden;
	opacity: 1;
}

/* نوار پیشرفت بالای هر استوری */
.igs-progress-wrap {
	position: relative;
	left: 0;
	right: 0;
	width: 100%;
	height: var(--igs-progress-height);
	display: flex;
	gap: 4px;
	padding: 12px 8px 0;
	z-index: 2;
	flex-shrink: 0;
}

.igs-rtl .igs-progress-wrap {
	left: 0;
	right: 0;
}

.igs-progress-seg {
	flex: 1;
	height: 100%;
	background: rgba(255,255,255,0.35);
	border-radius: 2px;
	overflow: hidden;
}

.igs-progress-seg-fill {
	height: 100%;
	width: 0;
	background: #fff;
	border-radius: 2px;
	transition: width 0.1s linear;
}

.igs-progress-seg.igs-active .igs-progress-seg-fill {
	width: 100%;
	transition: width var(--igs-duration, 5s) linear;
}

.igs-progress-seg.igs-done .igs-progress-seg-fill {
	width: 100%;
}

/* محتوای استوری */
.igs-viewer-content {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: 100%;
	aspect-ratio: 9/16;
	margin: auto;
	border-radius: var(--igs-radius);
	overflow: hidden;
	background: #000;
}

.igs-viewer-media {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.25s ease;
}

.igs-viewer-media.igs-transition-out {
	opacity: 0;
	pointer-events: none;
}

.igs-viewer-media img,
.igs-viewer-media video {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

/* دکمه بی‌صدا / با صدا برای ویدیو */
.igs-viewer-mute {
	position: absolute;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 3;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(0,0,0,0.5);
	color: #fff;
	cursor: pointer;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, transform 0.2s;
}
.igs-viewer-mute.igs-visible {
	display: flex;
}

/* دکمه‌های ناوبری چپ و راست */
.igs-viewer-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 3;
	width: 48px;
	height: 48px;
	border: none;
	border-radius: 50%;
	background: rgba(255,255,255,0.9);
	color: #262626;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, transform 0.2s, opacity 0.2s;
	opacity: 0.85;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.igs-viewer-nav:hover {
	background: rgba(255,255,255,1);
	opacity: 1;
	transform: translateY(-50%) scale(1.1);
}
.igs-viewer-nav:active {
	transform: translateY(-50%) scale(0.95);
}
.igs-viewer-nav svg {
	width: 24px;
	height: 24px;
	stroke-width: 2.5;
}
.igs-viewer-nav-prev {
	left: 16px;
}
.igs-viewer-nav-next {
	right: 16px;
}
.igs-rtl .igs-viewer-nav-prev {
	left: auto;
	right: 16px;
}
.igs-rtl .igs-viewer-nav-next {
	right: auto;
	left: 16px;
}
.igs-viewer-mute:hover {
	background: rgba(0,0,0,0.7);
	transform: translateX(-50%) scale(1.05);
}
.igs-viewer-mute svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
}

/* لینک کلیک‌پذیر روی کل صفحه */
.igs-viewer-link {
	position: absolute;
	inset: 0;
	z-index: 1;
	cursor: pointer;
}

.igs-viewer-close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 36px;
	height: 36px;
	border: none;
	background: rgba(0,0,0,0.4);
	color: #fff;
	border-radius: 50%;
	cursor: pointer;
	z-index: 3;
	font-size: 20px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.igs-rtl .igs-viewer-close {
	right: auto;
	left: 12px;
}

.igs-viewer-close:hover {
	background: rgba(0,0,0,0.6);
}

/* ناحیه تپ چپ/راست برای قبلی/بعدی (در RTL معکوس می‌شود با JS) */
.igs-tap-area {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 33%;
	z-index: 2;
	cursor: pointer;
}

.igs-tap-prev {
	left: 0;
}

.igs-tap-next {
	right: 0;
}

.igs-rtl .igs-tap-prev {
	left: auto;
	right: 0;
}

.igs-rtl .igs-tap-next {
	right: auto;
	left: 0;
}

/* انیمیشن ورود مودال */
.igs-viewer.igs-open .igs-viewer-content {
	animation: igs-viewer-in 0.3s ease;
}
@keyframes igs-viewer-in {
	from { opacity: 0; transform: scale(0.95); }
	to { opacity: 1; transform: scale(1); }
}

@media (max-width: 480px) {
	.igs-container {
		--igs-ring-size: 64px;
	}
}

/* ========== حالت دسکتاپ ========== */
.igs-viewer.igs-desktop {
	background: rgba(0, 0, 0, 0.85);
	backdrop-filter: blur(8px);
}

.igs-viewer-desktop-wrapper {
	display: flex;
	width: 100%;
	height: 100%;
	align-items: center;
	justify-content: center;
	gap: 20px;
	padding: 40px;
}

.igs-viewer-center {
	position: relative;
	flex: 0 0 auto;
	width: 420px;
	max-width: calc(100vw - 400px);
	height: calc(100vh - 80px);
	max-height: 747px;
	display: flex;
	flex-direction: column;
	background: #000;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.igs-viewer-side {
	flex: 0 0 180px;
	height: calc(100vh - 80px);
	max-height: 560px;
	border-radius: 8px;
	overflow: hidden;
	opacity: 0.6;
	transition: opacity 0.3s, transform 0.3s;
	cursor: pointer;
	background: #1a1a1a;
	display: flex;
	align-items: center;
	justify-content: center;
}

.igs-viewer-side:hover {
	opacity: 0.8;
	transform: scale(1.02);
}

.igs-viewer-side-prev {
	order: 1;
}

.igs-viewer-center {
	order: 2;
}

.igs-viewer-side-next {
	order: 3;
}

.igs-rtl .igs-viewer-side-prev {
	order: 3;
}

.igs-rtl .igs-viewer-side-next {
	order: 1;
}

.igs-viewer-side-content {
	width: 100%;
	height: 100%;
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.igs-viewer-side-preview {
	width: 100%;
	aspect-ratio: 9/16;
	border-radius: 8px;
	overflow: hidden;
	background: #2a2a2a;
	display: flex;
	align-items: center;
	justify-content: center;
}

.igs-viewer-side-preview img,
.igs-viewer-side-preview video {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.igs-viewer-side-name {
	margin-top: 12px;
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	text-align: center;
	opacity: 0.9;
}

.igs-viewer-header {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10;
	padding: 16px;
	display: flex;
	justify-content: flex-end;
	background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.igs-viewer-desktop-wrapper .igs-viewer-close {
	position: static;
	width: 32px;
	height: 32px;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s;
}

.igs-viewer-desktop-wrapper .igs-viewer-close:hover {
	background: rgba(255, 255, 255, 0.3);
}

.igs-viewer-progress-bars {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 11;
	padding: 12px 16px 0;
	display: flex;
	gap: 4px;
	background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 100%);
}

.igs-viewer-progress-bar {
	flex: 1;
	height: 2px;
	background: rgba(255, 255, 255, 0.3);
	border-radius: 1px;
	overflow: hidden;
	position: relative;
}

.igs-viewer-progress-bar.igs-active {
	background: rgba(255, 255, 255, 0.5);
}

.igs-viewer-progress-bar-fill {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 0%;
	background: #fff;
	border-radius: 1px;
	transition: width 0.1s linear;
}

.igs-viewer-desktop-wrapper .igs-viewer-stage {
	position: relative;
	width: 100%;
	flex: 1;
	overflow: hidden;
}

.igs-viewer-desktop-wrapper .igs-viewer-content {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	max-width: none;
	border-radius: 0;
	overflow: hidden;
	background: #000;
}

/* کنترل‌های گوشه بالا راست - دسکتاپ */
.igs-viewer-header-controls {
	display: flex;
	gap: 8px;
	align-items: center;
}

.igs-viewer-pause-play-desktop,
.igs-viewer-mute-desktop {
	width: 36px;
	height: 36px;
	border: none;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, transform 0.2s;
	backdrop-filter: blur(8px);
}

.igs-viewer-pause-play-desktop:hover,
.igs-viewer-mute-desktop:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: scale(1.1);
}

.igs-viewer-pause-play-desktop svg,
.igs-viewer-mute-desktop svg {
	width: 18px;
	height: 18px;
}

/* کنترل‌های گوشه بالا راست - موبایل */
.igs-viewer-header-mobile {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10;
	padding: 12px;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.igs-viewer-header-mobile .igs-viewer-close {
	position: static;
	width: 32px;
	height: 32px;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s;
}

.igs-viewer-header-mobile .igs-viewer-close:hover {
	background: rgba(255, 255, 255, 0.3);
}

.igs-viewer-header-mobile-controls {
	display: flex;
	gap: 8px;
	align-items: center;
}

.igs-viewer-pause-play-mobile,
.igs-viewer-mute-mobile {
	width: 36px;
	height: 36px;
	border: none;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, transform 0.2s;
	backdrop-filter: blur(8px);
}

.igs-viewer-pause-play-mobile:hover,
.igs-viewer-mute-mobile:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: scale(1.1);
}

.igs-viewer-pause-play-mobile svg,
.igs-viewer-mute-mobile svg {
	width: 18px;
	height: 18px;
}

.igs-viewer-progress-bars-mobile {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 11;
	padding: 48px 12px 0;
	display: flex;
	gap: 4px;
	background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 100%);
}

.igs-viewer-progress-bar-mobile {
	flex: 1;
	height: 2px;
	background: rgba(255, 255, 255, 0.3);
	border-radius: 1px;
	overflow: hidden;
	position: relative;
}

.igs-viewer-progress-bar-mobile.igs-active {
	background: rgba(255, 255, 255, 0.5);
}

.igs-viewer-progress-bar-fill-mobile {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 0%;
	background: #fff;
	border-radius: 1px;
	transition: width 0.1s linear;
}

.igs-viewer-desktop-wrapper .igs-viewer-mute {
	position: static;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transform: none;
	transition: transform 0.2s;
}

.igs-viewer-desktop-wrapper .igs-viewer-mute:hover {
	transform: scale(1.1);
}

.igs-viewer-desktop-wrapper .igs-viewer-mute svg {
	width: 18px;
	height: 18px;
}

.igs-viewer-desktop-wrapper .igs-viewer-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, transform 0.2s;
	backdrop-filter: blur(8px);
}

.igs-viewer-desktop-wrapper .igs-viewer-nav:hover {
	background: rgba(255, 255, 255, 0.25);
	transform: translateY(-50%) scale(1.1);
}

.igs-viewer-desktop-wrapper .igs-viewer-nav:active {
	transform: translateY(-50%) scale(0.95);
}

.igs-viewer-desktop-wrapper .igs-viewer-nav-prev {
	left: 16px;
}

.igs-viewer-desktop-wrapper .igs-viewer-nav-next {
	right: 16px;
}

.igs-rtl .igs-viewer-desktop-wrapper .igs-viewer-nav-prev {
	left: auto;
	right: 16px;
}

.igs-rtl .igs-viewer-desktop-wrapper .igs-viewer-nav-next {
	right: auto;
	left: 16px;
}

.igs-viewer-desktop-wrapper .igs-viewer-nav svg {
	width: 20px;
	height: 20px;
	stroke-width: 2.5;
}

@media (max-width: 1024px) {
	.igs-viewer-desktop-wrapper {
		padding: 20px;
		gap: 12px;
	}
	
	.igs-viewer-side {
		flex: 0 0 120px;
		max-height: 400px;
	}
	
	.igs-viewer-center {
		width: 360px;
		max-width: calc(100vw - 280px);
	}
}

@media (max-width: 767px) {
	.igs-viewer.igs-desktop {
		display: none !important;
	}
}
