/**
 * Frontend Styles für WP Advanced Forms
 *
 * @package WP_Advanced_Forms
 */

/* ==========================================================================
   Formular-Container
   ========================================================================== */

.waf-form {
	max-width: 800px;
	margin: 30px auto;
	padding: 40px;
	background: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.waf-form * {
	box-sizing: border-box;
}

.waf-form__fields {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
	margin-bottom: 32px;
}

/* ==========================================================================
   Nachrichten (Erfolg/Fehler)
   ========================================================================== */

.waf-form__message {
	padding: 16px 20px;
	margin-bottom: 24px;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.6;
	font-weight: 500;
	display: flex;
	align-items: center;
	gap: 12px;
}

.waf-form__message::before {
	content: '';
	display: inline-block;
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

.waf-form__message--success {
	background-color: #d1fae5;
	border: 2px solid #34d399;
	color: #065f46;
}

.waf-form__message--success::before {
	background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%2334d399"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/></svg>');
	background-size: contain;
}

.waf-form__message--error {
	background-color: #fee2e2;
	border: 2px solid #ef4444;
	color: #991b1b;
}

.waf-form__message--error::before {
	background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%23ef4444"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/></svg>');
	background-size: contain;
}

/* ==========================================================================
   Felder - Wrapper mit Breiten-System
   ========================================================================== */

.waf-field-wrapper {
	box-sizing: border-box;
	min-width: 0;
}

/* Breiten */
.waf-field-wrapper--width-full {
	flex: 0 0 100%;
	max-width: 100%;
}

.waf-field-wrapper--width-1\/2 {
	flex: 0 0 calc(50% - 10px);
	max-width: calc(50% - 10px);
}

.waf-field-wrapper--width-1\/3 {
	flex: 0 0 calc(33.333% - 14px);
	max-width: calc(33.333% - 14px);
}

.waf-field-wrapper--width-2\/3 {
	flex: 0 0 calc(66.666% - 7px);
	max-width: calc(66.666% - 7px);
}

.waf-field-wrapper--width-1\/4 {
	flex: 0 0 calc(25% - 15px);
	max-width: calc(25% - 15px);
}

.waf-field-wrapper--width-3\/4 {
	flex: 0 0 calc(75% - 5px);
	max-width: calc(75% - 5px);
}

/* Ausrichtung innerhalb des Wrappers */
.waf-field-wrapper--align-left {
	display: flex;
	justify-content: flex-start;
	margin-left: 0;
	margin-right: auto;
}

.waf-field-wrapper--align-center {
	display: flex;
	justify-content: center;
	margin-left: auto;
	margin-right: auto;
}

.waf-field-wrapper--align-right {
	display: flex;
	justify-content: flex-end;
	margin-left: auto;
	margin-right: 0;
}

/* ==========================================================================
   Felder - Interne Struktur
   ========================================================================== */

.waf-field {
	display: flex;
	flex-direction: column;
	width: 100%;
}

/* Label-Position: Oben (Standard) */
.waf-field--label-top {
	flex-direction: column;
}

/* Label-Position: Links */
.waf-field--label-left {
	flex-direction: row;
	align-items: center;
	gap: 12px;
}

.waf-field--label-left .waf-field__label {
	flex-shrink: 0;
	min-width: 120px;
	margin-bottom: 0;
}

.waf-field--label-left input,
.waf-field--label-left textarea,
.waf-field--label-left select {
	flex: 1;
}

/* Label-Position: Versteckt */
.waf-field--label-hidden .waf-field__label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ==========================================================================
   Choice Fields (Radio, Checkbox, Select)
   ========================================================================== */

.waf-field--radio fieldset,
.waf-field--checkbox fieldset {
	border: none;
	padding: 0;
	margin: 0;
}

.waf-field--radio legend,
.waf-field--checkbox legend {
	display: block;
	margin-bottom: 10px;
	font-weight: 600;
	font-size: 14px;
	color: #333333;
	padding: 0;
}

.waf-field__options {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.waf-field__option {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	padding: 6px 0;
}

.waf-field__option input[type="radio"],
.waf-field__option input[type="checkbox"] {
	width: auto;
	margin: 0;
	cursor: pointer;
}

.waf-field__option span {
	flex: 1;
	font-size: 14px;
	color: #333333;
}

.waf-field__option:hover {
	background: #f6f7f7;
	padding-left: 8px;
	padding-right: 8px;
	border-radius: 4px;
}

/* Select/Dropdown */
.waf-field select {
	width: 100%;
	padding: 10px 12px;
	font-size: 15px;
	line-height: 1.5;
	color: #333333;
	background-color: #ffffff;
	border: 1px solid #cccccc;
	border-radius: 4px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	cursor: pointer;
}

.waf-field select:focus {
	outline: none;
	border-color: #0073aa;
	box-shadow: 0 0 0 1px #0073aa;
}

/* ==========================================================================
   Acceptance Field (GDPR/Terms)
   ========================================================================== */

.waf-field--acceptance {
	flex-direction: row;
	align-items: flex-start;
	gap: 10px;
}

.waf-field--acceptance input[type="checkbox"] {
	width: auto;
	margin-top: 3px;
	cursor: pointer;
}

.waf-field__acceptance-text {
	flex: 1;
	font-size: 14px;
	line-height: 1.6;
	color: #333333;
}

.waf-field__acceptance-text a {
	color: #0073aa;
	text-decoration: underline;
}

.waf-field__acceptance-text a:hover {
	color: #005a87;
}

/* ==========================================================================
   HTML Content Block
   ========================================================================== */

.waf-field--html {
	padding: 0;
	color: #333333;
	line-height: 1.6;
}

.waf-field--html h1,
.waf-field--html h2,
.waf-field--html h3,
.waf-field--html h4,
.waf-field--html h5,
.waf-field--html h6 {
	margin: 0 0 10px 0;
	color: #1d2327;
}

.waf-field--html p {
	margin: 0 0 10px 0;
}

.waf-field--html ul,
.waf-field--html ol {
	margin: 0 0 10px 20px;
}

.waf-field__label {
	display: block;
	margin-bottom: 8px;
	font-weight: 500;
	font-size: 14px;
	color: #374151;
	letter-spacing: 0.01em;
}

.waf-field-wrapper--align-center .waf-field__label {
	text-align: center;
}

.waf-field-wrapper--align-right .waf-field__label {
	text-align: right;
}

.waf-field input[type="text"],
.waf-field input[type="email"],
.waf-field input[type="url"],
.waf-field input[type="tel"],
.waf-field input[type="number"],
.waf-field input[type="date"],
.waf-field input[type="time"],
.waf-field textarea,
.waf-field select {
	width: 100%;
	padding: 12px 16px;
	font-size: 15px;
	line-height: 1.5;
	color: #1f2937;
	background-color: #ffffff;
	border: 2px solid #d1d5db;
	border-radius: 8px;
	transition: all 0.2s ease;
	font-family: inherit;
}

.waf-field input::placeholder,
.waf-field textarea::placeholder {
	color: #9ca3af;
}

.waf-field input:hover,
.waf-field textarea:hover,
.waf-field select:hover {
	border-color: #9ca3af;
}

.waf-field input:focus,
.waf-field textarea:focus,
.waf-field select:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
	background-color: #ffffff;
}

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

/* Felder mit Fehler */
.waf-field--error input,
.waf-field--error textarea,
.waf-field--error select {
	border-color: #ef4444;
	background-color: #fef2f2;
}

.waf-field--error input:focus,
.waf-field--error textarea:focus,
.waf-field--error select:focus {
	border-color: #ef4444;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.waf-field__error {
	margin-top: 8px;
	font-size: 13px;
	color: #dc2626;
	line-height: 1.4;
	display: flex;
	align-items: center;
	gap: 6px;
}

.waf-field__error::before {
	content: '⚠';
	font-size: 14px;
}

/* ==========================================================================
   Checkboxen und Radio-Buttons
   ========================================================================== */

.waf-field--checkbox,
.waf-field--radio {
	flex-direction: row;
	align-items: center;
}

.waf-field--checkbox input[type="checkbox"],
.waf-field--radio input[type="radio"] {
	width: auto;
	margin-right: 8px;
	cursor: pointer;
}

.waf-field--checkbox .waf-field__label,
.waf-field--radio .waf-field__label {
	margin-bottom: 0;
	font-weight: 400;
	cursor: pointer;
}

/* ==========================================================================
   Submit-Button
   ========================================================================== */

.waf-form__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 14px 32px;
	font-size: 16px;
	font-weight: 600;
	color: #ffffff;
	background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
	font-family: inherit;
	min-width: 160px;
}

.waf-form__submit:hover {
	background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
	transform: translateY(-1px);
}

.waf-form__submit:active {
	transform: translateY(0);
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.waf-form__submit:disabled {
	background: #9ca3af;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
	opacity: 0.6;
}

/* ==========================================================================
   Pflichtfeld-Marker
   ========================================================================== */

.waf-field__label .required {
	color: #ef4444;
	margin-left: 4px;
	font-weight: 600;
	font-size: 16px;
}

.waf-field--required .waf-field__label::after {
	content: ' *';
	color: #ef4444;
	font-weight: 600;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
	.waf-form {
		padding: 24px;
		margin: 20px auto;
		border-radius: 10px;
	}

	.waf-form__fields {
		gap: 20px;
	}

	.waf-field input,
	.waf-field textarea,
	.waf-field select {
		font-size: 16px; /* Verhindert Zoom auf iOS */
		padding: 14px 16px;
	}

	.waf-form__submit {
		width: 100%;
		padding: 16px 24px;
		font-size: 17px;
	}

	/* Mobile: Alle Felder auf 100% Breite */
	.waf-field-wrapper {
		flex: 0 0 100% !important;
		max-width: 100% !important;
	}

	/* Mobile: Labels immer oben */
	.waf-field--label-left {
		flex-direction: column;
		align-items: stretch;
	}

	.waf-field--label-left .waf-field__label {
		margin-bottom: 8px;
	}
}

@media (max-width: 480px) {
	.waf-form {
		padding: 20px;
		margin: 16px 10px;
	}

	.waf-form__fields {
		gap: 16px;
	}
}

/* ==========================================================================
   Hilfstext
   ========================================================================== */

.waf-field__help {
	margin-top: 4px;
	font-size: 13px;
	color: #666666;
	line-height: 1.4;
}

/* ==========================================================================
   Loading-State
   ========================================================================== */

.waf-form--loading {
	opacity: 0.6;
	pointer-events: none;
}

.waf-form__submit.loading::after {
	content: "...";
	animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
	0%,
	20% {
		content: ".";
	}
	40% {
		content: "..";
	}
	60%,
	100% {
		content: "...";
	}
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.waf-field input:focus-visible,
.waf-field textarea:focus-visible,
.waf-field select:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

/* Screen-Reader Only */
.waf-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;
}

/* ==========================================================================
   HTML-Feld Utility-Klassen
   ========================================================================== */

/* Horizontale Trennlinie - dünn */
.waf-divider {
	width: 100%;
	height: 1px;
	border: none;
	background-color: #ccc;
	margin: 10px 0;
}

/* Horizontale Trennlinie - dick */
.waf-divider-thick {
	width: 100%;
	height: 2px;
	border: none;
	background-color: #999;
	margin: 20px 0;
}

/* Horizontale Trennlinie - gepunktet */
.waf-divider-dotted {
	width: 100%;
	height: 0;
	border: none;
	border-top: 2px dotted #ccc;
	margin: 15px 0;
}

/* Horizontale Trennlinie - gestrichelt */
.waf-divider-dashed {
	width: 100%;
	height: 0;
	border: none;
	border-top: 2px dashed #ccc;
	margin: 15px 0;
}

/* Text-Abschnitt */
.waf-text-section {
	margin: 15px 0;
	padding: 15px;
	background-color: #f9f9f9;
	border-left: 4px solid #3b82f6;
	border-radius: 4px;
}

/* Überschrift */
.waf-heading {
	margin: 20px 0 10px 0;
	padding-bottom: 8px;
	border-bottom: 2px solid #e5e7eb;
	color: #1d2327;
	font-weight: 600;
}
