/**
 * Elcogen Text Image Widget Styles
 *
 * Responsive text-image layout with flexbox
 * Mobile: Image always on top, text below
 * Desktop: Image position based on user selection
 *
 * @package Elcogen_Elementor_Widgets
 * @since 1.0.0
 */

/* ========================================
   CONTAINER STYLES
   ======================================== */

.elcogen-text-image {
	width: 100%;
	position: relative;
}

/* Higher specificity to override Elementor defaults */
.elementor-widget-elcogen-text-image .elcogen-text-image__container,
.elcogen-text-image__container {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center;
	width: 100%;
	gap: var(--spacing-baseline-40);
}

/* ========================================
   COLUMN STYLES
   ======================================== */

/* Higher specificity for columns */
.elementor-widget-elcogen-text-image .elcogen-text-image__text-column,
.elementor-widget-elcogen-text-image .elcogen-text-image__image-column,
.elcogen-text-image__text-column,
.elcogen-text-image__image-column {
	flex: 1 1 auto !important;
	box-sizing: border-box;
	min-width: 0; /* Prevents flex item from overflowing */
	max-width: 50%; /* Ensures each column takes exactly 50% minus gap */
}

/* ========================================
   TEXT CONTENT STYLES
   ======================================== */

.elcogen-text-image__text-content {
	width: 100%;
	font-family: var(--font-family-body), -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: var(--font-size-body-large);
	line-height: var(--line-height-body-large);
	color: var(--color-text-primary);
}

/* Reset margins for WYSIWYG content */
.elcogen-text-image__text-content > *:first-child {
	margin-top: 0;
}

.elcogen-text-image__text-content > *:last-child {
	margin-bottom: 0;
}

/* Paragraph spacing */
.elcogen-text-image__text-content p {
	margin: 0 0 1em 0;
}

.elcogen-text-image__text-content p:last-child {
	margin-bottom: 0;
}

/* Heading styles */
.elcogen-text-image__text-content h1,
.elcogen-text-image__text-content h2,
.elcogen-text-image__text-content h3,
.elcogen-text-image__text-content h4,
.elcogen-text-image__text-content h5,
.elcogen-text-image__text-content h6 {
	font-family: var(--font-family-headings), -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	margin-top: 0;
	margin-bottom: 0.5em;
}

/* List styles */
.elcogen-text-image__text-content ul,
.elcogen-text-image__text-content ol {
	padding-left: 1.5em;
	margin: 0 0 1em 0;
}

.elcogen-text-image__text-content li {
	margin-bottom: 0.5em;
}

.elcogen-text-image__text-content li:last-child {
	margin-bottom: 0;
}

/* Link styles */
.elcogen-text-image__text-content a {
	color: #0073aa;
	text-decoration: none;
	transition: var(--transition-color);
}

.elcogen-text-image__text-content a:hover {
	color: #005177;
	text-decoration: underline;
}

/* Blockquote styles */
.elcogen-text-image__text-content blockquote {
	margin: 1em 0;
	padding: 1em;
	border-left: 4px solid var(--color-text-primary);
	font-style: italic;
	background: var(--color-background-light);
}

/* Strong and emphasis */
.elcogen-text-image__text-content strong {
	font-weight: var(--font-weight-bold);
}

.elcogen-text-image__text-content em {
	font-style: italic;
}

/* ========================================
   IMAGE STYLES
   ======================================== */

.elcogen-text-image__image {
	width: 100%;
	line-height: 0; /* Remove extra space below image */
	overflow: hidden; /* Prevent any image overflow */
}

.elcogen-text-image__image img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	object-fit: contain; /* Maintain aspect ratio within bounds */
}

.elcogen-text-image__image a {
	display: block;
	line-height: 0;
}

/* ========================================
   RESPONSIVE STYLES - MOBILE
   ======================================== */

@media (max-width: 48rem) {

	/* Force stacking on mobile */
	.elcogen-text-image__container {
		flex-direction: column !important;
	}

	.elcogen-text-image__text-column,
	.elcogen-text-image__image-column {
		flex: 0 0 100% !important;
		max-width: 100% !important;
	}

	/* Image ALWAYS on top on mobile - override inline order styles */
	.elcogen-text-image__image-column {
		order: 1 !important;
		margin-bottom: var(--spacing-baseline-24);
	}

	.elcogen-text-image__text-column {
		order: 2 !important;
	}

	/* Mobile typography adjustments */
	.elcogen-text-image__text-content {
		font-size: var(--font-size-body-medium);
		line-height: var(--line-height-body-medium);
	}

}

/* ========================================
   RESPONSIVE STYLES - DESKTOP & TABLET
   ======================================== */

/* Desktop layout is defined in default styles above with @media (min-width: 48.0625rem) */
/* The order property for left/right positioning is set inline in PHP */
/* Mobile overrides below force image-on-top regardless of inline styles */

/* ========================================
   ELEMENTOR EDITOR STYLES
   ======================================== */

.elementor-editor-active .elcogen-text-image {
	min-height: 3.125rem;
}

/* Ensure proper spacing in editor */
.elementor-editor-active .elcogen-text-image__container {
	min-height: inherit;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus styles for links */
.elcogen-text-image__text-content a:focus,
.elcogen-text-image__image a:focus {
	outline: 0.125rem solid #0073aa;
	outline-offset: 0.125rem;
}

/* Screen reader only text */
.elcogen-text-image .sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {

	.elcogen-text-image__container {
		display: block;
	}

	.elcogen-text-image__text-column,
	.elcogen-text-image__image-column {
		width: 100%;
		max-width: 100%;
		page-break-inside: avoid;
	}

}
