/**
 * GiraForms - Frontend Styles
 */

/* CSS Custom Properties (can be overridden by style options) */
.giraforms-form-container {
	--giraforms-font-family: inherit;
	--giraforms-font-size: inherit;
	--giraforms-font-weight: inherit;
	--giraforms-accent-color: inherit;
	--giraforms-text-color: inherit;
	--giraforms-background-color: transparent;
	--giraforms-border-color: #ddd;
	--giraforms-button-bg: #385aea;
	--giraforms-button-color: #ffffff;
	--giraforms-border-radius: 4px;
	--giraforms-input-bg-color: #fff;
	--giraforms-required-color: #dc3232;
}

.giraforms-form-container {
	font-family: var(--giraforms-font-family);
	font-size: var(--giraforms-font-size);
	font-weight: var(--giraforms-font-weight);
	color: var(--giraforms-text-color);
	background-color: var(--giraforms-background-color);
}

/* Form Container */
.giraforms-form {
	margin: 0 auto;
}

/* Form Fields */
.giraforms-field {
	margin-bottom: 1.5rem;
}

.giraforms-field label {
	display: block;
	margin-bottom: var(--giraforms-label-spacing, 0.5rem);
	line-height: 1;
	font-weight: var(--giraforms-label-font-weight, 600);
	color: var(--giraforms-text-color);
}

/* Reset margin for inline option labels */
.giraforms-booking-slot-item label,
.giraforms-checkbox-option label,
.giraforms-radio-option label {
	display: inline;
	margin-bottom: 0;
}

.giraforms-field label.required::after {
	content: " *";
	color: var(--giraforms-required-color);
}

.giraforms-field input[type="text"],
.giraforms-field input[type="email"],
.giraforms-field input[type="tel"],
.giraforms-field input[type="url"],
.giraforms-field input[type="number"],
.giraforms-field input[type="date"],
.giraforms-field input[type="time"],
.giraforms-field input[type="password"],
.giraforms-field select,
.giraforms-field textarea {
	width: 100%;
	padding: 0.75rem;
	border: 1px solid var(--giraforms-border-color, #ddd);
	border-radius: var(--giraforms-border-radius, 4px);
	font-size: var(--giraforms-font-size, 1rem);
	font-family: var(--giraforms-font-family, inherit);
	line-height: 1.5;
	color: var(--giraforms-text-color, #1e1e1e);
	background-color: var(--giraforms-input-bg-color, #fff);
	transition: border-color 0.2s;
	box-sizing: border-box;
}

.giraforms-field input[type="text"]:focus,
.giraforms-field input[type="email"]:focus,
.giraforms-field input[type="tel"]:focus,
.giraforms-field input[type="url"]:focus,
.giraforms-field input[type="number"]:focus,
.giraforms-field input[type="date"]:focus,
.giraforms-field input[type="time"]:focus,
.giraforms-field input[type="password"]:focus,
.giraforms-field select:focus,
.giraforms-field textarea:focus {
	outline: none;
	border-color: var(--giraforms-accent-color);
	box-shadow: 0 0 0 1px var(--giraforms-accent-color);
}

.giraforms-field textarea {
	min-height: 120px;
	resize: vertical;
}



/* Checkboxes and Radio Buttons */
.giraforms-field-checkbox,
.giraforms-field-radio {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.giraforms-checkbox-option,
.giraforms-radio-option {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.giraforms-checkbox-option input[type="checkbox"],
.giraforms-radio-option input[type="radio"] {
	width: auto;
	margin: 0;
}

/* Options Wrapper */
.giraforms-options-wrapper {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

/* Button Style for Radio/Checkbox */
.giraforms-style-buttons .giraforms-options-wrapper {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.giraforms-style-buttons .giraforms-radio-option,
.giraforms-style-buttons .giraforms-checkbox-option {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0;
	border: 1px solid #e0e0e0;
	border-radius: var(--giraforms-border-radius, 4px);
	cursor: pointer;
	transition: all 0.2s;
	background: #fff;
}

.giraforms-style-buttons .giraforms-radio-option:hover,
.giraforms-style-buttons .giraforms-checkbox-option:hover {
	border-color: var(--giraforms-accent-color);
	background: #f8fafc;
}

.giraforms-style-buttons .giraforms-radio-option:has(input:checked),
.giraforms-style-buttons .giraforms-checkbox-option:has(input:checked) {
	border-color: var(--giraforms-accent-color);
	background: var(--giraforms-accent-color);
}

.giraforms-style-buttons .giraforms-radio-option:has(input:checked) label,
.giraforms-style-buttons .giraforms-checkbox-option:has(input:checked) label {
	color: #fff;
}

.giraforms-style-buttons .giraforms-radio-option input,
.giraforms-style-buttons .giraforms-checkbox-option input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.giraforms-style-buttons .giraforms-radio-option label,
.giraforms-style-buttons .giraforms-checkbox-option label {
	cursor: pointer;
	font-weight: 500;
	color: var(--giraforms-text-color);
	transition: color 0.2s;
	user-select: none;
	padding: 0.75rem;
}

/* Field Description */
.giraforms-field-description {
	margin-top: 0.25rem;
	font-size: 0.875rem;
	color: #757575;
}

/* Error Styles */
.giraforms-field.has-error input,
.giraforms-field.has-error textarea,
.giraforms-field.has-error select {
	border-color: #dc3232;
}

.giraforms-field-error {
	margin-top: 0.25rem;
	font-size: 0.875rem;
	color: #dc3232;
}

/* Submit Button - Width */
.wp-block-giraforms-submit-button .wp-block-button.has-custom-width {
	display: inline-block;
}

.wp-block-giraforms-submit-button .wp-block-button.has-custom-width .wp-block-button__link {
	display: block;
	width: 100%;
}

.wp-block-giraforms-submit-button .wp-block-button.wp-block-button__width-25 {
	width: 25%;
}

.wp-block-giraforms-submit-button .wp-block-button.wp-block-button__width-50 {
	width: 50%;
}

.wp-block-giraforms-submit-button .wp-block-button.wp-block-button__width-75 {
	width: 75%;
}

.wp-block-giraforms-submit-button .wp-block-button.wp-block-button__width-100 {
	width: 100%;
}

/* Submit Button - inherit typography from block wrapper (overrides :root :where(.wp-element-button)) */
.wp-block-giraforms-submit-button .wp-block-button__link {
	font-size: inherit;
	font-family: inherit;
	font-weight: inherit;
	line-height: inherit;
	letter-spacing: inherit;
}

/* Submit Button */
.giraforms-submit-button {
	display: inline-block;
	padding: 0.75rem 1.5rem;
	background-color: var(--giraforms-button-bg, #385aea);
	color: var(--giraforms-button-color, #fff);
	border: none;
	border-radius: var(--giraforms-border-radius, 4px);
	font-size: var(--giraforms-font-size, 1rem);
	font-family: var(--giraforms-font-family, inherit);
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s;
}

.giraforms-submit-button:hover {
	filter: brightness(0.9);
}

.giraforms-submit-button:disabled {
	background-color: #ddd;
	cursor: not-allowed;
}

.giraforms-submit-button.loading {
	position: relative;
	color: transparent;
}

.giraforms-submit-button.loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin-top: -10px;
	margin-left: -10px;
	border: 2px solid #fff;
	border-top-color: transparent;
	border-radius: 50%;
	animation: giraforms-spin 0.6s linear infinite;
}

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

/* Messages */
.giraforms-message {
	padding: 1rem;
	margin-bottom: 1rem;
	border-radius: 4px;
}

.giraforms-message.success {
	background-color: #d4edda;
	border: 1px solid #c3e6cb;
	color: #155724;
}

.giraforms-message.error {
	background-color: #f8d7da;
	border: 1px solid #f5c6cb;
	color: #721c24;
}

/* ===========================
   Password Field Styles
   =========================== */

.giraforms-password-wrapper {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.giraforms-password-wrapper input[type="password"],
.giraforms-password-wrapper input[type="text"] {
	flex: 1;
	padding-right: 3rem;
}

.giraforms-password-toggle {
	position: absolute;
	right: 0.5rem;
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 0.5rem;
	color: var(--giraforms-text-color, #666);
	transition: color 0.2s ease;
}

.giraforms-password-toggle:hover {
	color: var(--giraforms-accent-color, #385aea);
}

.giraforms-password-toggle .dashicons {
	font-size: 20px;
	width: 20px;
	height: 20px;
}

/* ===========================
   Color Picker Field Styles
   =========================== */

.giraforms-color-picker-wrapper {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.giraforms-color-preview {
	position: relative;
	width: 50px;
	height: 50px;
	border-radius: var(--giraforms-border-radius, 4px);
	border: 2px solid var(--giraforms-border-color, #ddd);
	overflow: hidden;
	cursor: pointer;
	transition: transform 0.2s ease;
}

.giraforms-color-preview:hover {
	transform: scale(1.05);
}

.giraforms-color-input {
	position: absolute;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}

.giraforms-color-hex-input {
	flex: 1;
	max-width: 150px;
	font-family: monospace;
	text-transform: uppercase;
}

/* ===========================
   Range Slider Field Styles
   =========================== */

.giraforms-range-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.75rem;
}

.giraforms-range-value {
	font-weight: 600;
	color: var(--giraforms-accent-color, #385aea);
	font-size: 1.1em;
	min-width: 60px;
	text-align: right;
}

.giraforms-range-wrapper {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.giraforms-range-min,
.giraforms-range-max {
	color: var(--giraforms-text-color, #666);
	font-size: 0.875em;
	min-width: 40px;
	text-align: center;
}

.giraforms-range-input {
	flex: 1;
	-webkit-appearance: none;
	appearance: none;
	height: 8px;
	background: #e0e0e0;
	border-radius: 5px;
	outline: none;
	transition: background 0.3s ease;
}

.giraforms-range-input::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 20px;
	height: 20px;
	background: var(--giraforms-accent-color, #385aea);
	border-radius: 50%;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.giraforms-range-input::-webkit-slider-thumb:hover {
	transform: scale(1.2);
	box-shadow: 0 0 0 8px rgba(0, 123, 186, 0.1);
}

.giraforms-range-input::-moz-range-thumb {
	width: 20px;
	height: 20px;
	background: var(--giraforms-accent-color, #385aea);
	border-radius: 50%;
	cursor: pointer;
	border: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.giraforms-range-input::-moz-range-thumb:hover {
	transform: scale(1.2);
	box-shadow: 0 0 0 8px rgba(0, 123, 186, 0.1);
}

.giraforms-range-input:focus {
	background: #d0d0d0;
}

.giraforms-range-input:focus::-webkit-slider-thumb {
	box-shadow: 0 0 0 8px rgba(0, 123, 186, 0.2);
}

.giraforms-range-input:focus::-moz-range-thumb {
	box-shadow: 0 0 0 8px rgba(0, 123, 186, 0.2);
}

/* ===========================
   Consent Field
   =========================== */

.giraforms-consent-field .giraforms-checkbox-wrapper {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.giraforms-consent-field .giraforms-consent-checkbox {
	width: auto;
	margin: 6px 0 0 0;
	flex-shrink: 0;
	cursor: pointer;
}

.giraforms-consent-field .giraforms-consent-label {
	margin: 0;
	cursor: pointer;
	user-select: none;
	color: var(--giraforms-text-color, inherit);
	font-family: var(--giraforms-font-family, inherit);
	line-height: 1.5;
}

.giraforms-consent-field .giraforms-consent-label a {
	color: var(--giraforms-accent-color);
	text-decoration: underline;
	font-weight: 600;
	transition: color 0.2s;
}


.giraforms-consent-field .required {
	color: var(--giraforms-required-color);
	margin-left: 4px;
	font-weight: 700;
}

/* Error state for consent checkbox */
.giraforms-consent-field .giraforms-checkbox-wrapper.error {
	border-color: #dc3232;
	background-color: #fef7f7;
}

.giraforms-consent-field .giraforms-error-message {
	margin-top: 8px;
	padding: 8px 12px;
	background-color: #fef7f7;
	border: 1px solid #dc3232;
	border-radius: var(--giraforms-border-radius, 4px);
	color: #dc3232;
	font-size: 0.875rem;
	display: none;
}

.giraforms-consent-field.has-error .giraforms-error-message {
	display: block;
}

/* ===========================
   Restriction Messages
   =========================== */

.giraforms-restriction-message {
	padding: 24px 20px;
	border-radius: var(--giraforms-border-radius, 4px);
	text-align: center;
	margin: 20px 0;
}

.giraforms-restriction-message p {
	margin: 0;
	font-size: 1rem;
	line-height: 1.5;
}

/* Login required / Logout required */
.giraforms-restriction-login-required,
.giraforms-restriction-logout-required {
	background-color: #fff8e5;
	border: 1px solid #f0c33c;
	color: #6e4b00;
}

/* Form not started yet */
.giraforms-restriction-not-started {
	background-color: #e7f3ff;
	border: 1px solid #4a90d9;
	color: #1e4a7a;
}

/* Form expired */
.giraforms-restriction-expired {
	background-color: #fef2f2;
	border: 1px solid #ef4444;
	color: #991b1b;
}
