/**
 * masterE Group Buying — Frontend Styles
 *
 * Base styles for both Elementor widgets and the create-group popup form.
 * All Elementor styling controls (colors, fonts, borders, shadows, padding)
 * are applied via inline CSS generated by Elementor — these are only defaults
 * and structural rules.
 *
 * RTL overrides: mgb-frontend-rtl.css (loaded automatically for RTL locales).
 *
 * @package MasterE_Group_Buying
 */

/* ── Utility ────────────────────────────────────────────────────────────── */

.mgb-btn {
	display: inline-block;
	cursor: pointer;
	text-decoration: none;
	line-height: 1.4;
	font-family: inherit;
	border: none;
	transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mgb-btn:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.mgb-btn-disabled,
.mgb-btn[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}

/* ── Open Enrollment Group widget ───────────────────────────────────────── */

.mgb-open-group-wrap {
	display: inline-block;
	vertical-align: middle;
}

.mgb-open-group-btn {
	/* Default appearance — overridden by Elementor styling controls. */
	padding: 0.6em 1.4em;
	background-color: #333;
	color: #fff;
	border-radius: 4px;
}

.mgb-max-groups-notice {
	margin-top: 0.5em;
	font-size: 0.875em;
	color: #888;
}

/* ── Groups list widget ──────────────────────────────────────────────────── */

.mgb-groups-list {
	position: relative;
}

/* Dropdown */
.mgb-dropdown-wrap {
	width: 100%;
	position: relative;
}

.mgb-groups-dropdown {
	width: 100%;
	padding: 0.5em 2.2em 0.5em 0.75em; /* right padding reserves space for the arrow */
	font-family: inherit;
	font-size: 1em;
	border: 1px solid #ccc;
	border-radius: 4px;
	background-color: #fff;
	color: #333;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
}

/* Preserve custom colors on focus/active — browsers reset select styling on open */
.mgb-groups-dropdown:focus,
.mgb-groups-dropdown:active {
	background-color: inherit;
	color: inherit;
	outline: none;
}

/* Custom arrow — replaced CSS background SVG with a standalone element */
.mgb-dropdown-arrow {
	position: absolute;
	top: 50%;
	right: 0.8em;
	width: 8px;
	height: 8px;
	border-right: 2px solid #666;
	border-bottom: 2px solid #666;
	transform: translateY(-75%) rotate(45deg);
	pointer-events: none;
}

/* Arrow positioned on the left side */
.mgb-arrow-left .mgb-dropdown-arrow {
	right: auto;
	left: 0.8em;
}

/* Adjust select padding when arrow is on the left */
.mgb-arrow-left .mgb-groups-dropdown {
	padding-inline-start: 2.2em;
	padding-inline-end: 0.75em;
}

/* Progress bar */
.mgb-progress-bar-wrap {
	margin: 1em 0 0.5em;
}

/* Labels sit ABOVE the bar */
.mgb-progress-labels {
	display: flex;
	justify-content: space-between;
	margin-bottom: 0.4em;
	font-size: 0.8em;
	color: #666;
	gap: 0.5em;
}

.mgb-progress-label-registered,
.mgb-progress-label-min {
	font-weight: 600;
}

/* Track is a flex row of equal-width segments */
.mgb-progress-track {
	display: flex;
	gap: 2px;
	width: 100%;
	height: 12px;
	background-color: transparent;
	border-radius: 6px;
	overflow: hidden;
}

/* Each segment */
.mgb-progress-segment {
	flex: 1;
	height: 100%;
	background-color: #e5e7eb; /* empty color — overridden by Elementor control */
	border-radius: 3px;        /* default rounding per segment; overridden by Elementor control */
	transition: background-color 0.3s ease;
}

.mgb-progress-segment.mgb-progress-segment--filled {
	background-color: #4f9a5e; /* filled color — overridden by Elementor control */
}

/* Extra rounding on the outer ends of the bar (belt-and-suspenders alongside overflow:hidden) */
/* LTR: first segment is on the left, last is on the right */
.mgb-progress-segment:first-child {
	border-top-left-radius: 6px;
	border-bottom-left-radius: 6px;
}

.mgb-progress-segment:last-child {
	border-top-right-radius: 6px;
	border-bottom-right-radius: 6px;
}

/* Deadline */
.mgb-deadline {
	margin: 0.75em 0;
	font-size: 0.9em;
	color: #555;
}

.mgb-deadline-label {
	font-weight: 600;
	margin-inline-end: 0.3em;
}

/* Group details panel */
.mgb-group-details {
	margin-top: 1em;
	padding-top: 0.75em;
	border-top: 1px solid #e5e7eb;
}

/* Add to Cart button */
.mgb-add-to-cart-btn {
	display: inline-block;
	padding: 0.6em 1.4em;
	background-color: #4f9a5e;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	font-size: 1em;
	text-align: center; /* always centered within the button — hardcoded by design */
	transition: background-color 0.2s ease;
}

.mgb-add-to-cart-btn:hover {
	background-color: #3d7a4a;
}

/* Empty state & guest message */
.mgb-empty-state,
.mgb-guest-notice {
	color: #888;
	font-size: 0.95em;
	margin: 0.5em 0;
}

/* Loading spinner */
.mgb-loading {
	text-align: center;
	padding: 1em 0;
}

.mgb-spinner {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2px solid rgba(0, 0, 0, 0.15);
	border-top-color: #4f9a5e;
	border-radius: 50%;
	animation: mgb-spin 0.7s linear infinite;
}

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

/* ── Create Group form (inside Elementor popup) ──────────────────────────── */

.mgb-create-group-form {
	width: 100%;
}

.mgb-form-field {
	margin-bottom: 1em;
}

.mgb-form-field label {
	display: block;
	margin-bottom: 0.35em;
	font-weight: 600;
	font-size: 0.9em;
}

.mgb-input {
	width: 100%;
	padding: 0.5em 0.75em;
	font-family: inherit;
	font-size: 1em;
	border: 1px solid #ccc;
	border-radius: 4px;
	box-sizing: border-box;
}

.mgb-input:focus {
	outline: none;
	border-color: #4f9a5e;
	box-shadow: 0 0 0 3px rgba(79, 154, 94, 0.15);
}

.mgb-btn-submit {
	padding: 0.65em 1.5em;
	background-color: #4f9a5e;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	font-size: 1em;
	width: 100%;
	transition: background-color 0.2s ease;
}

.mgb-btn-submit:hover {
	background-color: #3d7a4a;
}

.mgb-form-messages {
	padding: 0.6em 0.9em;
	border-radius: 4px;
	margin-bottom: 0.75em;
	font-size: 0.9em;
	display: none;
}

.mgb-msg-success {
	background-color: #ecfdf5;
	color: #065f46;
	border: 1px solid #6ee7b7;
}

.mgb-msg-error {
	background-color: #fef2f2;
	color: #991b1b;
	border: 1px solid #fca5a5;
}

/* Cart quantity lock (replaces quantity input with plain "1") */
.mgb-cart-qty {
	font-weight: 600;
}
