/* =============================================================================
   500 Designs — Tabs Widget
   Prefix: d500-tabs
   ============================================================================= */

/* ── Container ──────────────────────────────────────────────────────────────── */
.d500-tabs {
	display: flex;
	flex-direction: column;
	width: 100%;
}

.d500-tabs--position-left,
.d500-tabs--position-right {
	flex-direction: row;
	align-items: flex-start;
}

.d500-tabs--position-bottom {
	flex-direction: column-reverse;
}

.d500-tabs--position-right {
	flex-direction: row-reverse;
}

/* ── Controls Bar ────────────────────────────────────────────────────────────── */
.d500-tabs__controls {
	display: flex;
	flex-wrap: nowrap;
	margin: 0;
	padding: 0;
	list-style: none;
}

.d500-tabs--position-top .d500-tabs__controls,
.d500-tabs--position-bottom .d500-tabs__controls {
	flex-direction: row;
	flex-shrink: 0;
}

.d500-tabs--position-left .d500-tabs__controls,
.d500-tabs--position-right .d500-tabs__controls {
	flex-direction: column;
	flex-shrink: 0;
}

/* Scrolling navigation (overflow scroll) */
.d500-tabs--scrolling-nav .d500-tabs__controls {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none; /* Firefox */
}

.d500-tabs--scrolling-nav .d500-tabs__controls::-webkit-scrollbar {
	display: none; /* Chrome/Safari */
}

/* ── Control Item ────────────────────────────────────────────────────────────── */
.d500-tabs__control {
	cursor: pointer;
	outline: none;
	user-select: none;
	flex-shrink: 0;
	min-width: 0;     /* allow flex item to shrink below content size */
	max-width: 100%;  /* hard stop — never wider than the container */
	/* Tabs Alignment: stretch — CSS custom property set on the controls bar
	   and inherited here so each tab grows equally (horizontal = equal width,
	   vertical = equal height) without affecting other alignment values. */
	flex-grow: var(--d500-tabs-item-grow, 0);
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.d500-tabs__control.is-active {
	cursor: default;
}

.d500-tabs__control-inner {
	display: flex;
	align-items: center;
	white-space: nowrap;
	width: 100%;
	height: 100%;  /* fill the control vertically so content centres in stretch mode */
	min-width: 0;  /* allow inner flex items to shrink */
}

/* Icon positions */
.d500-tabs__control--icon-top .d500-tabs__control-inner {
	flex-direction: column;
	align-items: center;
}

.d500-tabs__control--icon-right .d500-tabs__control-inner {
	flex-direction: row-reverse;
}

/* ── Icon / Image ────────────────────────────────────────────────────────────── */
.d500-tabs__label-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 1em;
	line-height: 1;
	color: inherit;
}

.d500-tabs__label-icon svg {
	display: block;
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.d500-tabs__label-icon i {
	display: block;
	color: inherit;
}

/* Default icon spacing — target the state wrapper (the actual flex item) */
.d500-tabs__control--icon-left .d500-tabs__icon-state  { margin-right: 8px; }
.d500-tabs__control--icon-right .d500-tabs__icon-state { margin-left: 8px; }
.d500-tabs__control--icon-top .d500-tabs__icon-state   { margin-bottom: 6px; }

.d500-tabs__label-image {
	display: block;
	max-width: 100%;
	height: auto;
}

/* ── Content Wrapper ─────────────────────────────────────────────────────────── */
.d500-tabs__contents {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	/* JS sets min-height for animated effects */
}

/* ── Content Panels: Effect = none ───────────────────────────────────────────── */
.d500-tabs--effect-none .d500-tabs__content {
	display: none;
}

.d500-tabs--effect-none .d500-tabs__content.is-active {
	display: block;
}

/* ── Content Panels: All animated effects ────────────────────────────────────── */
/*
 * All animated effects share the same base: panels are position:absolute so
 * they overlap. The JS measures the active panel height and sets min-height
 * on the contents wrapper to prevent collapse.
 */
.d500-tabs--effect-fade .d500-tabs__content,
.d500-tabs--effect-zoom-in .d500-tabs__content,
.d500-tabs--effect-zoom-out .d500-tabs__content,
.d500-tabs--effect-move-up .d500-tabs__content,
.d500-tabs--effect-fall-perspective .d500-tabs__content {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	z-index: 1;
	display: block; /* Override the default — use opacity/visibility to hide */
}

.d500-tabs--effect-fade .d500-tabs__content.is-active,
.d500-tabs--effect-zoom-in .d500-tabs__content.is-active,
.d500-tabs--effect-zoom-out .d500-tabs__content.is-active,
.d500-tabs--effect-move-up .d500-tabs__content.is-active,
.d500-tabs--effect-fall-perspective .d500-tabs__content.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	z-index: 2;
}

/* ── Fade ────────────────────────────────────────────────────────────────────── */
.d500-tabs--effect-fade .d500-tabs__content {
	transition: opacity 0.35s ease, visibility 0.35s ease;
}

/* ── Zoom In ─────────────────────────────────────────────────────────────────── */
.d500-tabs--effect-zoom-in .d500-tabs__content {
	transform: scale(0.9);
	transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
}

.d500-tabs--effect-zoom-in .d500-tabs__content.is-active {
	transform: scale(1);
}

/* ── Zoom Out ────────────────────────────────────────────────────────────────── */
.d500-tabs--effect-zoom-out .d500-tabs__content {
	transform: scale(1.1);
	transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
}

.d500-tabs--effect-zoom-out .d500-tabs__content.is-active {
	transform: scale(1);
}

/* ── Move Up ─────────────────────────────────────────────────────────────────── */
.d500-tabs--effect-move-up .d500-tabs__content {
	transform: translateY(25px);
	transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
}

.d500-tabs--effect-move-up .d500-tabs__content.is-active {
	transform: translateY(0);
}

/* ── Expand ──────────────────────────────────────────────────────────────────── */
/*
 * Expand uses normal flow (no position:absolute).
 * All panels are display:block with height:0 and overflow:hidden.
 * JS animates height to scrollHeight on open, then sets 'auto'.
 */
.d500-tabs--effect-expand .d500-tabs__content {
	display: block;
	overflow: hidden;
	height: 0;
	opacity: 1;
	visibility: visible;
	pointer-events: none;
	position: static;
	transition: height 0.4s ease;
}

.d500-tabs--effect-expand .d500-tabs__content.is-active {
	pointer-events: auto;
	/* height managed by JS: scrollHeight on open → auto after transition */
}

/* ── Fall Perspective ────────────────────────────────────────────────────────── */
.d500-tabs--effect-fall-perspective .d500-tabs__contents {
	perspective: 1200px;
}

.d500-tabs--effect-fall-perspective .d500-tabs__content {
	transform: rotateX(-20deg) translateY(-20px);
	transform-origin: top center;
	transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
}

.d500-tabs--effect-fall-perspective .d500-tabs__content.is-active {
	transform: rotateX(0deg) translateY(0);
}

/* ── Template edit cover (editor mode only) ──────────────────────────────────── */
.d500-tabs__edit-cover {
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.5);
	padding: 6px 12px;
	margin-top: 8px;
	border-radius: 3px;
}

.d500-tabs__edit-cover a {
	color: #fff;
	text-decoration: none;
	font-size: 13px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.d500-tabs__edit-cover a:hover {
	text-decoration: underline;
}

/* ── No template message ─────────────────────────────────────────────────────── */
.d500-tabs__no-template {
	padding: 20px;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 4px;
	color: #856404;
	font-size: 14px;
}

/* ── Accessibility focus ─────────────────────────────────────────────────────── */
.d500-tabs__control:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ── Slider scrolling nav ────────────────────────────────────────────────────── */
.d500-tabs--scroll-slider .d500-tabs__swiper-wrapper {
	position: relative;
	display: flex;
	align-items: center;
	overflow: hidden;
	flex: 1 1 auto;
}

.d500-tabs--scroll-slider .d500-tabs__controls {
	display: flex;
	flex-wrap: nowrap;
	overflow: hidden;
	flex: 1 1 auto;
	scroll-behavior: smooth;
}

/* Nav buttons */
.d500-tabs__nav-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px;
	line-height: 1;
	color: inherit;
	font-size: 18px;
	transition: color 0.2s ease;
}

.d500-tabs--nav-outside {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* ── Icon Normal / Active states ─────────────────────────────────────────────── */
/* Both state wrappers are proper flex items */
.d500-tabs__icon-state {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

/* Active icon hidden by default */
.d500-tabs__icon-state--active {
	display: none;
}

/* When tab is active AND has an active icon: swap them */
.d500-tabs__control--has-active-icon.is-active .d500-tabs__icon-state--normal {
	display: none;
}

.d500-tabs__control--has-active-icon.is-active .d500-tabs__icon-state--active {
	display: inline-flex;
}

/* ── Tab extra content, shortcode, button ────────────────────────────────────── */
/* Hidden by default to prevent FOUC — JS shows them for the active tab */
.d500-tabs__control .d500-tabs__label-desc,
.d500-tabs__control .d500-tabs__tab-content,
.d500-tabs__control .d500-tabs__tab-shortcode,
.d500-tabs__control .d500-tabs__tab-btn,
.d500-tabs__control .d500-tabs__tab-gallery {
	display: none;
}

.d500-tabs__tab-content {
	white-space: normal;
	overflow-wrap: break-word;
	word-break: break-word;
	max-width: 100%;
}

.d500-tabs__tab-shortcode {
	white-space: normal;
	overflow-wrap: break-word;
	word-break: break-word;
	max-width: 100%;
}

.d500-tabs__tab-btn {
	display: inline-block;
	text-decoration: none;
	cursor: pointer;
	transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* ── Expandable description ───────────────────────────────────────────────────── */
.d500-tabs__label-desc--expandable {
	display: none;
	overflow-wrap: break-word;
	word-break: break-word;
	max-width: 100%;
}

/* Gallery: only shown on explicit tab click, never on init/auto-switch */
.d500-tabs__gallery--on-click {
	display: none;
}

/* ── Label Group (Tab Icon Before + Label + Description) ─────────────────────── */
.d500-tabs__label-group {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
}

.d500-tabs__label-stack {
	display: flex;
	flex-direction: column;
	white-space: normal;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;  /* contain all children within the stack */
}

.d500-tabs__label-group-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 1em;
	line-height: 1;
	color: inherit;
	align-self: center;
}

.d500-tabs__label-group-icon svg {
	display: block;
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.d500-tabs__label-group-icon i {
	display: block;
	color: inherit;
}

.d500-tabs__label-group-icon--image {
	display: block;
	max-width: 100%;
	height: auto;
}

.d500-tabs__label-desc {
	white-space: normal;
	overflow-wrap: break-word;
	word-break: break-word;
	max-width: 100%;
}

/* When icon position is top, stack the label group vertically */
.d500-tabs__control--icon-top .d500-tabs__label-group {
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

/* Label text align — independent of icon position */
.d500-tabs--label-align-left .d500-tabs__label-stack {
	text-align: left;
	align-items: flex-start;
}
.d500-tabs--label-align-center .d500-tabs__label-stack {
	text-align: center;
	align-items: center;
}
.d500-tabs--label-align-right .d500-tabs__label-stack {
	text-align: right;
	align-items: flex-end;
}

/* For icon-top: also align the label-group column so the image follows the text */
.d500-tabs--label-align-left .d500-tabs__control--icon-top .d500-tabs__label-group {
	align-items: flex-start;
}
.d500-tabs--label-align-center .d500-tabs__control--icon-top .d500-tabs__label-group {
	align-items: center;
}
.d500-tabs--label-align-right .d500-tabs__control--icon-top .d500-tabs__label-group {
	align-items: flex-end;
}

/* ── Mobile Select (dropdown) ────────────────────────────────────────────────── */
.d500-tabs__mobile-select {
	display: none;
}

/* Active state toggled by JS based on stack_breakpoint setting */
.d500-tabs--mobile-select-active .d500-tabs__mobile-select {
	display: block;
	width: 100%;
	padding: 8px 12px;
	font-size: inherit;
	font-family: inherit;
	color: inherit;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 4px;
	cursor: pointer;
	margin-bottom: 12px;
}

.d500-tabs--mobile-select-active .d500-tabs__controls,
.d500-tabs--mobile-select-active .d500-tabs__swiper-wrapper {
	display: none;
}

/* Override ALL effect styles — use simple show/hide in mobile select mode */
.d500-tabs--mobile-select-active .d500-tabs__content {
	display: none !important;
	position: static !important;
	opacity: 1 !important;
	visibility: visible !important;
	transform: none !important;
	height: auto !important;
	overflow: visible !important;
	pointer-events: auto !important;
}

.d500-tabs--mobile-select-active .d500-tabs__content.is-active {
	display: block !important;
}

/* Force column layout and full-width content wrapper */
.d500-tabs--mobile-select-active {
	flex-direction: column !important;
}

.d500-tabs--mobile-select-active .d500-tabs__contents {
	width: 100% !important;
	min-height: 0 !important;
	flex: 1 1 auto;
}

/* ── AJAX Loader ─────────────────────────────────────────────────────────────── */
.d500-tabs__loader {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	font-size: 24px;
	color: inherit;
}

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

.d500-tabs__loader .eicon-loading {
	display: inline-block;
	animation: d500-spin 1s linear infinite;
}

/* ── Responsive position (tablet) ────────────────────────────────────────────── */
@media (max-width: 1024px) {
	.d500-tabs--position-tablet-top,
	.d500-tabs--position-tablet-bottom {
		flex-direction: column;
		align-items: stretch;
	}
	.d500-tabs--position-tablet-bottom {
		flex-direction: column-reverse;
	}
	.d500-tabs--position-tablet-left,
	.d500-tabs--position-tablet-right {
		flex-direction: row;
		align-items: flex-start;
	}
	.d500-tabs--position-tablet-right {
		flex-direction: row-reverse;
	}
	.d500-tabs--position-tablet-top .d500-tabs__controls,
	.d500-tabs--position-tablet-bottom .d500-tabs__controls {
		flex-direction: row;
		flex-shrink: 0;
	}
	.d500-tabs--position-tablet-left .d500-tabs__controls,
	.d500-tabs--position-tablet-right .d500-tabs__controls {
		flex-direction: column;
		flex-shrink: 0;
	}
}

/* ── Mobile accordion layout (JS adds this class at MOBILE_BP) ───────────────── */
.d500-tabs--accordion-active .d500-tabs__controls {
	flex-direction: column;
	width: 100%;
}

.d500-tabs--accordion-active .d500-tabs__control {
	width: 100%;
}

/* Reset animated-effect positioning in accordion mode.
 * Animated effects set position:absolute via CSS class selectors.
 * JS only clears inline styles, so we must override the CSS rules here
 * to prevent panels (and images inside them) from being position:absolute
 * in the accordion/mobile layout. */
.d500-tabs--accordion-active .d500-tabs__content {
	position: static !important;
	opacity: 1 !important;
	visibility: visible !important;
	transform: none !important;
	pointer-events: auto !important;
	width: 100% !important;
	z-index: auto !important;
}

/* ── Responsive position (mobile) ────────────────────────────────────────────── */
@media (max-width: 767px) {
	.d500-tabs--position-mobile-top,
	.d500-tabs--position-mobile-bottom {
		flex-direction: column;
		align-items: stretch;
	}
	.d500-tabs--position-mobile-bottom {
		flex-direction: column-reverse;
	}
	.d500-tabs--position-mobile-left,
	.d500-tabs--position-mobile-right {
		flex-direction: row;
		align-items: flex-start;
	}
	.d500-tabs--position-mobile-right {
		flex-direction: row-reverse;
	}
	.d500-tabs--position-mobile-top .d500-tabs__controls,
	.d500-tabs--position-mobile-bottom .d500-tabs__controls {
		flex-direction: column;
		flex-shrink: 0;
		width: 100%;
	}
	.d500-tabs--position-mobile-top .d500-tabs__control,
	.d500-tabs--position-mobile-bottom .d500-tabs__control {
		width: 100%;
	}
	.d500-tabs--position-mobile-left .d500-tabs__controls,
	.d500-tabs--position-mobile-right .d500-tabs__controls {
		flex-direction: column;
		flex-shrink: 0;
	}
}

/* =============================================================================
   Gallery
   ============================================================================= */
.d500-tabs__tab-gallery {
	width: 100%;
}

.d500-tabs__gallery-grid {
	display: grid;
	gap: 8px;
}

.d500-tabs__gallery-grid--cols-1 { grid-template-columns: 1fr; }
.d500-tabs__gallery-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.d500-tabs__gallery-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.d500-tabs__gallery-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
.d500-tabs__gallery-grid--cols-5 { grid-template-columns: repeat(5, 1fr); }
.d500-tabs__gallery-grid--cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Slider (1 column, no scrollbar, drag/swipe) */
.d500-tabs__gallery-grid--slider {
	display: flex;
	flex-wrap: nowrap;
	overflow-x: scroll;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
	cursor: grab;
	user-select: none;
}

.d500-tabs__gallery-grid--slider::-webkit-scrollbar { display: none; }

.d500-tabs__gallery-grid--slider.is-dragging {
	cursor: grabbing;
	scroll-snap-type: none;
}

.d500-tabs__gallery-grid--slider .d500-tabs__gallery-item {
	flex: 0 0 100%; /* overridden by inline style when peek/width is set */
	scroll-snap-align: start;
	min-width: 0;
}

.d500-tabs__gallery-grid--slider .d500-tabs__gallery-item img {
	width: 100%;
	height: auto;
	display: block;
}

.d500-tabs__gallery-item {
	overflow: hidden;
	line-height: 0;
}

.d500-tabs__gallery-item img {
	width: 100%;
	height: auto;
	display: block;
	transition: opacity 0.2s ease;
}

.d500-tabs__gallery-item img[data-lightbox="true"] {
	cursor: zoom-in;
}

.d500-tabs__gallery-item img[data-lightbox="true"]:hover {
	opacity: 0.82;
}

/* Lightbox */
.d500-tabs__lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.92);
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.d500-tabs__lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.d500-tabs__lightbox img {
	max-width: 90vw;
	max-height: 86vh;
	object-fit: contain;
	display: block;
	transition: opacity 0.18s ease;
}

.d500-tabs__lightbox img.is-loading { opacity: 0; }

.d500-tabs__lightbox-close {
	position: fixed;
	top: 14px;
	right: 18px;
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	background: none;
	border: none;
	padding: 4px 8px;
	opacity: 0.75;
	transition: opacity 0.15s;
	z-index: 1000000;
}

.d500-tabs__lightbox-close:hover { opacity: 1; }

.d500-tabs__lightbox-prev,
.d500-tabs__lightbox-next {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	color: #fff;
	font-size: 32px;
	line-height: 1;
	cursor: pointer;
	background: rgba(0, 0, 0, 0.35);
	border: none;
	padding: 14px 18px;
	opacity: 0.75;
	transition: opacity 0.15s, background 0.15s;
	z-index: 1000000;
	border-radius: 4px;
}

.d500-tabs__lightbox-prev { left: 10px; }
.d500-tabs__lightbox-next { right: 10px; }

.d500-tabs__lightbox-prev:hover,
.d500-tabs__lightbox-next:hover {
	opacity: 1;
	background: rgba(0, 0, 0, 0.6);
}

.d500-tabs__lightbox-prev.is-hidden,
.d500-tabs__lightbox-next.is-hidden { display: none; }

.d500-tabs__lightbox-counter {
	position: fixed;
	bottom: 14px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.65);
	font-size: 13px;
	z-index: 1000000;
}
