/* Card Slider Block Styles */

/* Block Container */
.wp-block-pinkrebel-card-slider {
	margin: var(--wp--preset--spacing--40, 2rem) 0;
}

/* Slider Container */
.card-slider {
	position: relative;
    visibility: visible !important;
}

/* Splide Track and List */
.card-slider .splide__track {
	overflow: visible;
}

.card-slider .splide__list {
	display: flex;
	align-items: stretch;
}

/* Slide Container - Updated for single slide support */
.card-slider .splide__slide {
	display: flex;
	flex-direction: column;
	min-width: 0; /* Allow Splide to control width */
}

/* Card Item */
.card-item {
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--wp--preset--color--secondary);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0);
	overflow: hidden;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	text-decoration: none !important;
	color: inherit;
}

.card-item img {
	transform: scale(1);
	transition: transform 0.3s ease;
}

.card-item:hover img {
	transform: scale(1.05);
	text-decoration: none !important;
}

/* Card Image */
.card-image-container {
	position: relative;
	width: 100%;
	height: 342px;
	overflow: hidden;
	background-color: #f5f5f5;
}

.card-image {
	width: 100%;
	height: 100% !important;
	object-fit: cover;
	object-position: center;
}


/* Editor Image Controls */
.wp-block-editor .card-image-container {
	position: relative;
}

.wp-block-editor .card-image-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 200px;
	background-color: #f0f0f0;
	border: 2px dashed #ccc;
}

.wp-block-editor .placeholder-text {
	color: #999;
	font-style: italic;
}

.wp-block-editor .card-link-indicator {
	margin-top: 0.5rem;
	padding: 0.25rem 0.5rem;
	background-color: #e0f2fe;
	color: #0277bd;
	border-radius: 4px;
	font-size: 0.875rem;
	display: inline-block;
}

/* Card Content */
.card-content {
	padding: 1.5rem;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.card-title {
	margin: 0 0 1rem 0;
	font-size: var(--wp--preset--font-size--xx-large);
	font-weight: 600;
	line-height: 1.3;
	color: var(--wp--preset--color--font);
}

.card-description {
	margin: 0;
	flex: 1;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--wp--preset--color--font);
}

/* Editor Controls */
.wp-block-editor .card-link-controls {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid #e0e0e0;
}

/* Navigation Arrows */
.card-slider .splide__arrows {
	position: relative;
	display: flex;
	justify-content: flex-end;
	gap: 12px;
	margin-top: 2rem;
	z-index: 2;
}

.card-slider .splide__arrow {
	position: static;
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background: unset;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.3s ease;
	opacity: 1;
	transform: none;
}

.card-slider .splide__arrow:hover {
	background: #ffffff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.card-slider .splide__arrow:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

.card-slider .splide__arrow svg {
	width: 24px;
	height: 20px;
	fill: #544842;
}

/* Empty slide handling */
.card-slider .splide__slide:empty,
.card-slider .splide__slide .card-item:empty,
.card-slider .splide__slide .card-content:empty {
	margin-bottom: 0;
}

.card-slider .splide__slide .card-content:empty + * {
	margin-top: 0;
}

/* Remove bottom margin from card title when there's no description or when description is empty */
.card-title:last-child,
.card-title + .card-description:empty {
	margin-bottom: 0;
    line-height: 1;
}

.card-title + .card-description:empty {
	display: none;
}

/* Grid Layout (when not enough cards for slider) */
.card-slider.is-grid .splide__list {
	gap: var(--gap, 2rem);
}

.card-slider.is-grid .splide__slide {
	flex: 1;
	min-width: 0;
}

.card-slider.is-grid .splide__arrows {
	display: none;
}

/* Let Splide handle all width calculations naturally */
.card-slider .splide__slide {
	display: flex;
	flex-direction: column;
	min-width: 0; /* Allow Splide to control width */
}

/* Better handling for single slide display */
.card-slider.splide--slide .splide__slide {
	width: auto; /* Let Splide control width */
}

/* Let Splide handle explicit width calculations */
.card-slider .splide__list[style*="width"] .splide__slide {
	flex: none; /* Don't flex, use explicit width from Splide */
}

/* Fallback for CSS-only layout when slidesToShow = 1 */
.card-slider:not(.splide--slide) .splide__list {
	display: flex;
	gap: var(--gap, 2rem);
}

.card-slider:not(.splide--slide) .splide__slide {
	flex: 1;
	min-width: 0;
}

/* Editor Splide Integration */
.wp-block-editor .card-slider.splide {
	/* Ensure proper visibility */
	visibility: visible !important;
	opacity: 1 !important;
}

.wp-block-editor .card-slider .splide__track {
	/* Prevent WordPress editor from interfering */
	pointer-events: auto !important;
}

.wp-block-editor .card-slider .splide__slide {
	/* Ensure slides are interactive in editor */
	pointer-events: auto !important;
}

/* Sidebar Card Management */
.sidebar-card-item {
	margin-bottom: 1.5rem;
	padding: 1rem;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	background: #f9f9f9;
}

.sidebar-item-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid #e0e0e0;
}

.sidebar-image-preview {
	margin-bottom: 1rem;
}

.sidebar-image-preview img {
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-image-controls {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}

.add-card-button {
	width: 100%;
	margin-top: 1rem;
}

/* Force re-render on image changes */
.wp-block-editor .card-item {
	transition: all 0.2s ease;
}

/* Responsive Design */
@media (max-width: 1100px) {
	.card-image-container {
		height: 300px;
	}
	
	.card-content {
		padding: 1.25rem;
	}
	
	.card-slider .splide__arrows {
		margin-top: 1.5rem;
		gap: 8px;
	}
	
	.card-slider .splide__arrow {
		width: 40px;
		height: 40px;
	}
	
	.card-slider .splide__arrow svg {
		width: 20px;
		height: 16px;
	}
}

@media (max-width: 481px) {
	.card-image-container {
		height: 300px;
	}
	
	.card-content {
		padding: 1rem;
	}
	
}

/* Editor-specific styles for image editing */
.wp-block-editor .image-edit-wrapper {
	position: relative;
	overflow: hidden;
	cursor: pointer;
	display: block;
	width: 100%;
	height: 100%;
}

.wp-block-editor .image-edit-wrapper .card-image {
	width: 100%;
	height: auto;
	display: block;
}

.wp-block-editor .image-edit-wrapper::after {
	content: '✏️';
	position: absolute;
	top: 8px;
	right: 8px;
	background: rgba(0, 0, 0, 0.8);
	color: white;
	border-radius: 50%;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
	z-index: 3;
}

.wp-block-editor .image-edit-wrapper:hover::after {
	opacity: 1;
}

.wp-block-editor .image-edit-overlay {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100% !important;
	height: 100% !important;
	background: transparent !important;
	border: none !important;
	padding: 0 !important;
	margin: 0 !important;
	cursor: pointer !important;
	z-index: 2 !important;
	opacity: 0 !important;
	display: block !important;
}

.wp-block-editor .add-image-button {
	background: var(--wp--preset--color--primary, #007cba);
	color: white;
	border: 2px dashed rgba(255, 255, 255, 0.5);
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	transition: all 0.3s ease;
	font-size: 14px;
	padding: 20px;
	text-align: center;
}

.wp-block-editor .add-image-button:hover {
	background: var(--wp--preset--color--primary-dark, #005a87);
	border-color: rgba(255, 255, 255, 0.8);
	transform: scale(1.02);
}

.wp-block-editor .add-image-button .dashicons {
	font-size: 32px;
	width: 32px;
	height: 32px;
	margin-bottom: 8px;
}

.wp-block-editor .add-image-button .placeholder-text {
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	font-size: 12px;
}

/* Simple placeholder for no image */
.wp-block-editor .card-image-placeholder {
	background: #f0f0f0;
	color: #666;
	border: 2px dashed #ccc;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	text-align: center;
}

.wp-block-editor .card-image-placeholder .placeholder-text {
	font-size: 14px;
	font-style: italic;
}

/* Hide editor preview indicator on frontend */
body:not(.wp-admin) .has-fade-in-animation::before {
    display: none !important;
}

/* Auto-hover animation styles for card slider */
.has-auto-hover-animation .card-item.auto-hover-active img{
	transform: scale(1.05);
}

/* Ensure smooth transition back to normal state */
.has-auto-hover-animation .card-item {
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Editor preview indicator for auto-hover */
.wp-block-editor .has-auto-hover-animation::before {
	content: '🎨 Auto-hover enabled';
	position: absolute;
	top: -20px;
	left: 0;
	font-size: 10px;
	color: #666;
	background: rgba(156, 39, 176, 0.1);
	padding: 2px 6px;
	border-radius: 3px;
	pointer-events: none;
	z-index: 1;
}
