/**
 * Frontend Styles
 *
 * Styles for the public-facing side
 *
 * @package    Quellcoder\QuellcoderSurvey
 * @since      1.0.0
 */

/* CSS Variables for easy customization */
:root {
	--survey-primary-color: #2271b1;
	--survey-primary-hover: #135e96;
	--survey-secondary-color: #f0f0f0;
	--survey-text-color: #1e1e1e;
	--survey-text-light: #757575;
	--survey-border-color: #dcdcdc;
	--survey-border-radius: 8px;
	--survey-spacing: 16px;
	--survey-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	--survey-transition: all 0.3s ease;
}

/* Survey Container */
.quellcoder-survey {
	margin: var(--survey-spacing) 0;
	padding: calc(var(--survey-spacing) * 1.5);
	background: #fff;
	border: 1px solid var(--survey-border-color);
	border-radius: var(--survey-border-radius);
	font-family: var(--survey-font-family);
	max-width: 600px;
}

/* Header */
.quellcoder-survey__header {
	margin-bottom: calc(var(--survey-spacing) * 1.5);
}

.quellcoder-survey__question {
	margin: 0 0 8px 0;
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--survey-text-color);
	line-height: 1.4;
}

.quellcoder-survey__description {
	margin: 0;
	font-size: 0.95rem;
	color: var(--survey-text-light);
	line-height: 1.5;
}

/* Voting Form */
.quellcoder-survey__form {
	display: grid;
	gap: 12px;
	margin-bottom: var(--survey-spacing);
}

/* Horizontal Layout */
.quellcoder-survey__form--horizontal {
	grid-template-columns: 1fr 1fr;
}

/* Vertical Layout (default) */
.quellcoder-survey__form--vertical {
	grid-template-columns: 1fr;
}

.quellcoder-survey__option {
	width: 100%;
	padding: 16px 20px;
	background: var(--survey-secondary-color);
	border: 2px solid transparent;
	border-radius: calc(var(--survey-border-radius) * 0.75);
	font-size: 1rem;
	font-weight: 500;
	color: var(--survey-text-color);
	cursor: pointer;
	transition: var(--survey-transition);
	text-align: center;
	position: relative;
	overflow: hidden;
}

/* Button Animation */
.quellcoder-survey__option--animated {
	animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(34, 113, 177, 0.4);
	}
	50% {
		box-shadow: 0 0 0 8px rgba(34, 113, 177, 0);
	}
}

.quellcoder-survey__option:hover {
	background: var(--survey-primary-color);
	color: #fff;
	border-color: var(--survey-primary-color);
	transform: translateY(-2px) scale(1.02);
	box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
	animation: none;
}

.quellcoder-survey__option:active {
	transform: translateY(0) scale(0.98);
}

.quellcoder-survey__option:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	animation: none;
}

.quellcoder-survey__option-label {
	display: inline-block;
	transition: transform 0.3s ease;
}

.quellcoder-survey__option:hover .quellcoder-survey__option-label {
	transform: translateX(-8px);
}

.quellcoder-survey__option-icon {
	position: absolute;
	right: 20px;
	top: 50%;
	transform: translateY(-50%) translateX(30px);
	opacity: 0;
	font-size: 1.2rem;
	transition: all 0.3s ease;
}

.quellcoder-survey__option:hover .quellcoder-survey__option-icon {
	opacity: 1;
	transform: translateY(-50%) translateX(0);
}

/* Click Animation */
.quellcoder-survey__option.clicked {
	animation: button-click 0.6s ease;
}

@keyframes button-click {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(0.95);
		background: var(--survey-primary-hover);
	}
	100% {
		transform: scale(1);
	}
}

/* Message */
.quellcoder-survey__message {
	padding: 12px 16px;
	margin-bottom: var(--survey-spacing);
	border-radius: calc(var(--survey-border-radius) * 0.5);
	font-size: 0.9rem;
}

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

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

/* Results */
.quellcoder-survey__results {
	margin-top: calc(var(--survey-spacing) * 1.5);
}

.quellcoder-survey__results.show-results {
	animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.quellcoder-survey__result-item {
	margin-bottom: calc(var(--survey-spacing) * 1.25);
	opacity: 0;
	animation: fadeInSlide 0.5s ease-out forwards;
}

.quellcoder-survey__result-item:nth-child(1) {
	animation-delay: 0.1s;
}

.quellcoder-survey__result-item:nth-child(2) {
	animation-delay: 0.2s;
}

@keyframes fadeInSlide {
	from {
		opacity: 0;
		transform: translateX(-20px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

.quellcoder-survey__result-item:last-child {
	margin-bottom: var(--survey-spacing);
}

.quellcoder-survey__result-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
}

.quellcoder-survey__result-label {
	font-weight: 600;
	color: var(--survey-text-color);
	font-size: 0.95rem;
}

.quellcoder-survey__result-percentage {
	font-weight: 600;
	color: var(--survey-primary-color);
	font-size: 1rem;
}

.quellcoder-survey__result-bar {
	height: 32px;
	background: var(--survey-secondary-color);
	border-radius: calc(var(--survey-border-radius) * 0.5);
	overflow: hidden;
	margin-bottom: 6px;
	position: relative;
}

.quellcoder-survey__result-bar::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
	animation: shimmer 2s infinite;
}

@keyframes shimmer {
	0% {
		left: -100%;
	}
	100% {
		left: 100%;
	}
}

.quellcoder-survey__result-bar-fill {
	height: 100%;
	background: linear-gradient(90deg, var(--survey-primary-color), var(--survey-primary-hover));
	transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding-right: 8px;
	color: #fff;
	font-size: 0.85rem;
	font-weight: 600;
	position: relative;
	overflow: hidden;
}

.quellcoder-survey__result-bar-fill::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
	animation: shine 3s infinite;
}

@keyframes shine {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(100%);
	}
}

.quellcoder-survey__result-count {
	font-size: 0.875rem;
	color: var(--survey-text-light);
}

.quellcoder-survey__total {
	margin-top: var(--survey-spacing);
	padding-top: var(--survey-spacing);
	border-top: 1px solid var(--survey-border-color);
	font-size: 0.95rem;
	color: var(--survey-text-light);
	text-align: center;
}

.quellcoder-survey__total strong {
	color: var(--survey-text-color);
}

/* Loading */
.quellcoder-survey__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 20px;
	color: var(--survey-text-light);
}

.quellcoder-survey__spinner {
	width: 20px;
	height: 20px;
	border: 3px solid var(--survey-secondary-color);
	border-top-color: var(--survey-primary-color);
	border-radius: 50%;
	animation: survey-spinner-rotate 0.8s linear infinite;
}

@keyframes survey-spinner-rotate {
	to { transform: rotate(360deg); }
}

.quellcoder-survey__loading-text {
	font-size: 0.9rem;
}

/* Error */
.quellcoder-survey-error {
	padding: 16px;
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
	border-radius: calc(var(--survey-border-radius) * 0.5);
	font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
	.quellcoder-survey {
		padding: var(--survey-spacing);
	}

	.quellcoder-survey__question {
		font-size: 1.1rem;
	}

	.quellcoder-survey__option {
		padding: 14px 16px;
	}

	/* Stack buttons vertically on mobile, even for horizontal layout */
	.quellcoder-survey__form--horizontal {
		grid-template-columns: 1fr;
	}
}

/* Lead Generation Form */
.quellcoder-survey__lead {
	margin-top: calc(var(--survey-spacing) * 1.5);
	padding: calc(var(--survey-spacing) * 1.5);
	background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
	border-radius: var(--survey-border-radius);
	border: 2px solid var(--survey-primary-color);
}

.quellcoder-survey__lead-content {
	text-align: center;
}

.quellcoder-survey__lead-text {
	font-size: 1.05rem;
	color: var(--survey-text-color);
	margin-bottom: calc(var(--survey-spacing) * 1.25);
	line-height: 1.6;
	font-weight: 500;
}

.quellcoder-survey__lead-form {
	margin-bottom: 12px;
}

.quellcoder-survey__lead-input-wrapper {
	display: flex;
	gap: 8px;
	max-width: 500px;
	margin: 0 auto;
}

.quellcoder-survey__lead-input {
	flex: 1;
	padding: 14px 18px;
	font-size: 1rem;
	border: 2px solid var(--survey-border-color);
	border-radius: calc(var(--survey-border-radius) * 0.5);
	transition: var(--survey-transition);
	font-family: var(--survey-font-family);
}

.quellcoder-survey__lead-input:focus {
	outline: none;
	border-color: var(--survey-primary-color);
	box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.quellcoder-survey__lead-submit {
	padding: 14px 28px;
	background: var(--survey-primary-color);
	color: #fff;
	border: none;
	border-radius: calc(var(--survey-border-radius) * 0.5);
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: var(--survey-transition);
	white-space: nowrap;
}

.quellcoder-survey__lead-submit:hover {
	background: var(--survey-primary-hover);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
}

.quellcoder-survey__lead-submit:active {
	transform: translateY(0);
}

.quellcoder-survey__lead-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

.quellcoder-survey__lead-privacy {
	margin-top: 12px;
	color: var(--survey-text-light);
	font-size: 0.85rem;
	margin-bottom: 0;
}

.quellcoder-survey__lead-success {
	text-align: center;
	padding: var(--survey-spacing);
}

.quellcoder-survey__lead-success-icon {
	display: inline-block;
	width: 60px;
	height: 60px;
	line-height: 60px;
	background: #28a745;
	color: #fff;
	border-radius: 50%;
	font-size: 2rem;
	margin-bottom: 12px;
	animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
	from {
		transform: scale(0);
	}
	to {
		transform: scale(1);
	}
}

.quellcoder-survey__lead-success p {
	font-size: 1.1rem;
	color: var(--survey-text-color);
	font-weight: 500;
	margin: 0;
}

/* Responsive Lead Form */
@media (max-width: 600px) {
	.quellcoder-survey__lead-input-wrapper {
		flex-direction: column;
	}

	.quellcoder-survey__lead-submit {
		width: 100%;
	}
}

/* Debug Controls (Admin only) */
.quellcoder-survey__debug {
	margin-top: calc(var(--survey-spacing) * 1.5);
	padding-top: calc(var(--survey-spacing) * 1.5);
	border-top: 2px dashed #ff9800;
	text-align: center;
}

.quellcoder-survey__debug-reset {
	padding: 10px 20px;
	background: #ff9800;
	color: #fff;
	border: none;
	border-radius: calc(var(--survey-border-radius) * 0.5);
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: var(--survey-transition);
	box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3);
}

.quellcoder-survey__debug-reset:hover {
	background: #f57c00;
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(255, 152, 0, 0.4);
}

.quellcoder-survey__debug-reset:active {
	transform: translateY(0);
}

.quellcoder-survey__debug-reset:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}
