/**
 * ARK Contests - Frontend Styles
 *
 * @package Jemuzu\ArkContests
 */

/* Variables */
:root {
	--ark-primary: #0073aa;
	--ark-primary-hover: #005177;
	--ark-success: #28a745;
	--ark-warning: #ffc107;
	--ark-error: #dc3545;
	--ark-text: #333;
	--ark-text-muted: #666;
	--ark-border: #ddd;
	--ark-bg-light: rgba(0,0,0,0.1);
	--ark-radius: 4px;
	--ark-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Form Wrapper */
.ark-contest-form-wrapper {
	max-width: 600px;
	margin: 0 auto;
}

/* Notices */
.ark-contest-notice {
	padding: 15px 20px;
	border-radius: var(--ark-radius);
	margin-bottom: 20px;
}

.ark-contest-notice-info {
	background: #e7f3ff;
	border: 1px solid #b8daff;
	color: #004085;
}

.ark-contest-notice-success {
	background: #d4edda;
	border: 1px solid #c3e6cb;
	color: #155724;
}

.ark-contest-notice-error {
	background: #f8d7da;
	border: 1px solid #f5c6cb;
	color: #721c24;
}

/* Rules */
.ark-contest-rules {
	margin-bottom: 30px;
	padding: 20px;
	background: var(--ark-bg-light);
	border-radius: var(--ark-radius);
}

.ark-contest-rules h3 {
	margin-top: 0;
	margin-bottom: 15px;
}

.ark-contest-rules-content {
	font-size: 14px;
	line-height: 1.6;
}

/* Form Fields */
.ark-contest-entry-form {
	background: #fff;
	padding: 30px;
	border-radius: var(--ark-radius);
}

.ark-contest-field {
	margin-bottom: 20px;
}

.ark-contest-field label {
	display: block;
	margin-bottom: 8px;
	font-weight: 600;
	color: var(--ark-text);
}

.ark-contest-field .required {
	color: var(--ark-error);
}

.ark-contest-field input[type="text"],
.ark-contest-field input[type="email"],
.ark-contest-field input[type="file"],
.ark-contest-field select,
.ark-contest-field textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--ark-border);
	border-radius: var(--ark-radius);
	font-size: 16px;
	line-height: 1.5;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.ark-contest-field input:focus,
.ark-contest-field select:focus,
.ark-contest-field textarea:focus {
	outline: none;
	border-color: var(--ark-primary);
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.ark-contest-field.has-error input,
.ark-contest-field.has-error select,
.ark-contest-field.has-error textarea {
	border-color: var(--ark-error);
}

.ark-contest-field .field-help {
	margin-top: 5px;
	font-size: 13px;
	color: var(--ark-text-muted);
}

.ark-contest-field .field-error {
	margin-top: 5px;
	font-size: 13px;
	color: var(--ark-error);
}

/* Radio and Checkbox */
.ark-contest-field-radio fieldset,
.ark-contest-field-checkbox fieldset {
	border: none;
	padding: 0;
	margin: 0;
}

.ark-contest-field-radio legend,
.ark-contest-field-checkbox legend {
	font-weight: 600;
	margin-bottom: 8px;
}

.ark-contest-radio-options,
.ark-contest-checkbox-options {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ark-contest-radio-option,
.ark-contest-checkbox-option {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

.ark-contest-radio-option input,
.ark-contest-checkbox-option input {
	width: auto;
	margin: 0;
}

/* Upload Dropzone */
.ark-upload-dropzone {
	position: relative;
	border: 2px dashed var(--ark-border);
	border-radius: 8px;
	background: #fafafa;
	transition: all 0.2s ease;
	cursor: pointer;
}

.ark-upload-dropzone:hover {
	border-color: var(--ark-primary);
	background: #f0f7fc;
}

.ark-upload-dropzone.is-dragover {
	border-color: var(--ark-primary);
	background: #e6f3fa;
	border-style: solid;
}

.ark-upload-dropzone.has-file {
	border-style: solid;
	border-color: var(--ark-success);
	background: #f0fff4;
}

.ark-contest-field.has-error .ark-upload-dropzone {
	border-color: var(--ark-error);
	background: #fff5f5;
}

.ark-upload-input {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
	z-index: 2;
}

.ark-upload-content {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	text-align: center;
}

.ark-upload-icon {
	color: var(--ark-text-muted);
	margin-bottom: 15px;
	transition: color 0.2s;
}

.ark-upload-dropzone:hover .ark-upload-icon,
.ark-upload-dropzone.is-dragover .ark-upload-icon {
	color: var(--ark-primary);
}

.ark-upload-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 10px;
}

.ark-upload-text-primary {
	font-size: 16px;
	font-weight: 600;
	color: var(--ark-text);
}

.ark-upload-text-secondary {
	font-size: 14px;
	color: var(--ark-primary);
}

.ark-upload-help {
	font-size: 13px;
	color: var(--ark-text-muted);
}

/* Upload Preview */
.ark-upload-preview {
	position: relative;
	padding: 15px;
}

.ark-upload-preview-image {
	display: block;
	max-width: 100%;
	max-height: 300px;
	margin: 0 auto;
	border-radius: 4px;
	box-shadow: var(--ark-shadow);
}

.ark-upload-remove {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	z-index: 3;
}

.ark-upload-remove:hover {
	background: var(--ark-error);
}

.ark-upload-filename {
	margin-top: 10px;
	text-align: center;
	font-size: 14px;
	color: var(--ark-text-muted);
	word-break: break-all;
}

/* Upload Progress */
.ark-upload-progress {
	padding: 20px;
}

.ark-upload-progress-bar {
	height: 8px;
	background: #e0e0e0;
	border-radius: 4px;
	overflow: hidden;
	margin-bottom: 10px;
}

.ark-upload-progress-fill {
	height: 100%;
	background: var(--ark-primary);
	border-radius: 4px;
	width: 0%;
	transition: width 0.3s ease;
}

.ark-upload-progress-text {
	text-align: center;
	font-size: 14px;
	color: var(--ark-text-muted);
}

/* Submit Button */
.ark-contest-submit-button {
	display: inline-block;
	padding: 12px 30px;
	background: var(--ark-primary);
	color: #fff;
	border: none;
	border-radius: var(--ark-radius);
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.ark-contest-submit-button:hover {
	background: var(--ark-primary-hover);
}

.ark-contest-submit-button:disabled {
	background: #999;
	cursor: not-allowed;
}

/* Rules Agreement */
.ark-contest-rules-agreement {
	margin-top: 12px;
	font-size: 12px;
	color: var(--ark-text-muted);
	line-height: 1.5;
}

.ark-contest-rules-link {
	color: var(--ark-primary);
	text-decoration: underline;
	cursor: pointer;
}

.ark-contest-rules-link:hover {
	color: var(--ark-primary-hover);
}

/* Form Messages */
.ark-contest-form-messages {
	margin-bottom: 20px;
}

.ark-contest-form-messages:empty {
	display: none;
}

/* Gallery */
.ark-contest-gallery {
	margin: 20px 0;
}

.ark-contest-gallery-filters {
	padding: 20px;
	background: var(--ark-bg-light);
	border-radius: var(--ark-radius);
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	justify-content: center;
	align-items: flex-end;
	width: 60%;
	margin: 20px auto;
}

.ark-contest-filter-group {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 200px;
	flex: 1;
}

.ark-contest-filter-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--ark-text);
}

.ark-contest-filter-select {
	padding: 8px 12px;
	border: 1px solid var(--ark-border);
	border-radius: var(--ark-radius);
	background: #fff;
	font-size: 14px;
	cursor: pointer;
	transition: border-color 0.2s;
}

.ark-contest-filter-select:hover {
	border-color: #999;
}

.ark-contest-filter-select:focus {
	outline: none;
	border-color: var(--ark-primary);
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.ark-contest-clear-filters {
	padding: 8px 16px;
	background: var(--ark-primary);
	color: #fff;
	border: none;
	border-radius: var(--ark-radius);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
	white-space: nowrap;
}

.ark-contest-clear-filters:hover {
	background: var(--ark-primary-hover);
}

.ark-contest-clear-filters:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.3);
}

.ark-contest-gallery-grid {
	display: grid;
	gap: 20px;
}

.ark-contest-gallery-cols-2 .ark-contest-gallery-grid { grid-template-columns: repeat(2, 1fr); }
.ark-contest-gallery-cols-3 .ark-contest-gallery-grid { grid-template-columns: repeat(3, 1fr); }
.ark-contest-gallery-cols-4 .ark-contest-gallery-grid { grid-template-columns: repeat(4, 1fr); }
.ark-contest-gallery-cols-5 .ark-contest-gallery-grid { grid-template-columns: repeat(5, 1fr); }
.ark-contest-gallery-cols-6 .ark-contest-gallery-grid { grid-template-columns: repeat(6, 1fr); }

.ark-contest-gallery-item {
	background: #fff;
	border-radius: var(--ark-radius);
	overflow: hidden;
	box-shadow: var(--ark-shadow);
	transition: transform 0.2s, box-shadow 0.2s;
}

.ark-contest-gallery-item:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ark-contest-gallery-link {
	display: block;
}

.ark-contest-gallery-image {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
}

.ark-contest-gallery-placeholder {
	width: 100%;
	aspect-ratio: 1;
	background: var(--ark-bg-light);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ccc;
}

.ark-contest-gallery-placeholder .dashicons {
	font-size: 48px;
	width: 48px;
	height: 48px;
}

.ark-contest-gallery-caption {
	padding:10px 10px 3px 10px;
	font-size: 14px;
	color: var(--ark-text);
	border-top: 1px solid var(--ark-border);
}

/* Gallery Field Display */
.ark-contest-gallery-fields {
	padding: 0px 10px 10px;
	font-size: 13px;
	color: var(--ark-text-muted);
}

.ark-contest-gallery-field {
	margin-bottom: 3px;
	line-height: 1;
	word-break: break-word;
}

.ark-contest-gallery-field:last-child {
	margin-bottom: 0;
}

/* Masonry Layout */
.ark-contest-gallery-masonry .ark-contest-gallery-grid {
	display: block;
	column-gap: 20px;
}

/* Column counts for masonry */
.ark-contest-gallery-masonry.ark-contest-gallery-cols-2 .ark-contest-gallery-grid {
	column-count: 2;
}

.ark-contest-gallery-masonry.ark-contest-gallery-cols-3 .ark-contest-gallery-grid {
	column-count: 3;
}

.ark-contest-gallery-masonry.ark-contest-gallery-cols-4 .ark-contest-gallery-grid {
	column-count: 4;
}

.ark-contest-gallery-masonry.ark-contest-gallery-cols-5 .ark-contest-gallery-grid {
	column-count: 5;
}

.ark-contest-gallery-masonry.ark-contest-gallery-cols-6 .ark-contest-gallery-grid {
	column-count: 6;
}

/* Masonry items */
.ark-contest-gallery-masonry .ark-contest-gallery-item {
	display: inline-block;
	width: 100%;
	margin-bottom: 20px;
	break-inside: avoid;
	page-break-inside: avoid; /* Fallback for older browsers */
}

/* Remove aspect ratio for masonry to allow natural image heights */
.ark-contest-gallery-masonry .ark-contest-gallery-image {
	aspect-ratio: auto;
	height: auto;
}

.ark-contest-gallery-empty {
	padding: 40px;
	text-align: center;
	color: var(--ark-text-muted);
	background: var(--ark-bg-light);
	border-radius: var(--ark-radius);
}

.ark-contest-gallery-load-more {
	margin-top: 30px;
	text-align: center;
}

.ark-contest-load-more-button {
	padding: 10px 25px;
	background: var(--ark-bg-light);
	border: 1px solid var(--ark-border);
	border-radius: var(--ark-radius);
	font-size: 14px;
	cursor: pointer;
	transition: background 0.2s;
}

.ark-contest-load-more-button.is-loading {
	cursor: wait;
	opacity: 0.7;
}

.ark-loading-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid var(--ark-border);
	border-top-color: var(--ark-primary);
	border-radius: 50%;
	animation: ark-spin 0.8s linear infinite;
	vertical-align: middle;
	margin-right: 5px;
}

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

.ark-contest-load-more-button:hover {
	background: #e9ecef;
}

/* Prizes */
.ark-contest-prizes {
	margin: 20px 0;
}

.ark-contest-prizes-title,
.ark-contest-winners-title {
	text-align: center;
	margin-bottom: 30px;
}

.ark-contest-prizes-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 20px;
}

.ark-contest-prize {
	background: #fff;
	border-radius: var(--ark-radius);
	overflow: hidden;
	box-shadow: var(--ark-shadow);
	text-align: center;
}

.ark-contest-prize-badge {
	padding: 8px 15px;
	font-weight: 600;
	font-size: 14px;
	text-transform: uppercase;
	color: #fff;
}

.ark-contest-prize-position-1 .ark-contest-prize-badge { background: linear-gradient(135deg, #FFD700, #FFA500); }
.ark-contest-prize-position-2 .ark-contest-prize-badge { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); }
.ark-contest-prize-position-3 .ark-contest-prize-badge { background: linear-gradient(135deg, #CD7F32, #8B4513); }

.ark-contest-prize-image img {
	width: 100%;
	max-height: 200px;
	object-fit: cover;
}

.ark-contest-prize-content {
	padding: 20px;
}

.ark-contest-prize-name {
	margin: 0 0 10px;
	font-size: 18px;
}

.ark-contest-prize-description {
	font-size: 14px;
	color: var(--ark-text-muted);
	line-height: 1.6;
}

.ark-contest-prizes-empty {
	padding: 40px;
	text-align: center;
	color: var(--ark-text-muted);
	background: var(--ark-bg-light);
	border-radius: var(--ark-radius);
}

/* Winners */
.ark-contest-winners {
	margin: 20px 0;
}

.ark-contest-winners-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 20px;
}

.ark-contest-winners-featured .ark-contest-winner-featured {
	grid-column: 1 / -1;
	max-width: 600px;
	margin: 0 auto 20px;
}

.ark-contest-winner {
	background: #fff;
	border-radius: var(--ark-radius);
	overflow: hidden;
	box-shadow: var(--ark-shadow);
	text-align: center;
}

.ark-contest-winner-badge {
	padding: 8px 15px;
	font-weight: 600;
	font-size: 14px;
	text-transform: uppercase;
	color: #fff;
}

.ark-contest-winner-position-1 .ark-contest-winner-badge { background: linear-gradient(135deg, #FFD700, #FFA500); }
.ark-contest-winner-position-2 .ark-contest-winner-badge { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); }
.ark-contest-winner-position-3 .ark-contest-winner-badge { background: linear-gradient(135deg, #CD7F32, #8B4513); }

.ark-contest-winner-photo img {
	width: 100%;
	max-height: 300px;
	object-fit: cover;
}

.ark-contest-winner-featured .ark-contest-winner-photo img {
	max-height: 400px;
}

.ark-contest-winner-content {
	padding: 20px;
}

.ark-contest-winner-name {
	margin: 0 0 10px;
	font-size: 20px;
}

.ark-contest-winner-prize {
	margin-bottom: 10px;
	font-size: 14px;
}

.ark-contest-winner-prize-label {
	color: var(--ark-text-muted);
}

.ark-contest-winner-prize-name {
	font-weight: 600;
	color: var(--ark-primary);
}

.ark-contest-winner-description {
	font-size: 14px;
	color: var(--ark-text-muted);
	line-height: 1.6;
}

.ark-contest-winners-empty {
	padding: 40px;
	text-align: center;
	color: var(--ark-text-muted);
	background: var(--ark-bg-light);
	border-radius: var(--ark-radius);
}

/* Block Placeholder */
.ark-contest-block-placeholder {
	padding: 40px;
	text-align: center;
	background: #f0f0f0;
	border: 2px dashed #ccc;
	border-radius: var(--ark-radius);
	color: #666;
}

/* Modal */
.ark-contest-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.ark-contest-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	cursor: pointer;
}

.ark-contest-modal-content {
	position: relative;
	background: #fff;
	border-radius: var(--ark-radius);
	max-width: 700px;
	max-height: 90vh;
	width: 100%;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	display: flex;
	flex-direction: column;
	animation: arkModalSlideIn 0.3s ease-out;
}

@keyframes arkModalSlideIn {
	from {
		opacity: 0;
		transform: translateY(-30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ark-contest-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 25px;
	border-bottom: 1px solid var(--ark-border);
}

.ark-contest-modal-header h2 {
	margin: 0;
	font-size: 20px;
	color: var(--ark-text);
}

.ark-contest-modal-close {
	background: none;
	border: none;
	font-size: 32px;
	line-height: 1;
	color: #999;
	cursor: pointer;
	padding: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background 0.2s, color 0.2s;
}

.ark-contest-modal-close:hover {
	background: #f0f0f0;
	color: #333;
}

.ark-contest-modal-body {
	padding: 25px;
	overflow-y: auto;
	flex: 1;
}

.ark-contest-modal-body h1,
.ark-contest-modal-body h2,
.ark-contest-modal-body h3,
.ark-contest-modal-body h4 {
	margin-top: 20px;
	margin-bottom: 10px;
}

.ark-contest-modal-body h1:first-child,
.ark-contest-modal-body h2:first-child,
.ark-contest-modal-body h3:first-child,
.ark-contest-modal-body h4:first-child {
	margin-top: 0;
}

.ark-contest-modal-body p,
.ark-contest-modal-body ul,
.ark-contest-modal-body ol {
	margin-bottom: 15px;
	line-height: 1.6;
}

.ark-contest-modal-body ul,
.ark-contest-modal-body ol {
	padding-left: 25px;
}

.ark-contest-modal-body li {
	margin-bottom: 8px;
}

/* Responsive */
@media screen and (max-width: 768px) {
	.ark-contest-entry-form {
		padding: 20px;
	}

	.ark-contest-gallery-filters {
		padding: 15px;
	}

	.ark-contest-filter-group {
		min-width: 150px;
	}

	.ark-contest-gallery-cols-4 .ark-contest-gallery-grid,
	.ark-contest-gallery-cols-5 .ark-contest-gallery-grid,
	.ark-contest-gallery-cols-6 .ark-contest-gallery-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.ark-contest-gallery-cols-3 .ark-contest-gallery-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	/* Masonry responsive: reduce to 2 columns on tablet */
	.ark-contest-gallery-masonry.ark-contest-gallery-cols-3 .ark-contest-gallery-grid,
	.ark-contest-gallery-masonry.ark-contest-gallery-cols-4 .ark-contest-gallery-grid,
	.ark-contest-gallery-masonry.ark-contest-gallery-cols-5 .ark-contest-gallery-grid,
	.ark-contest-gallery-masonry.ark-contest-gallery-cols-6 .ark-contest-gallery-grid {
		column-count: 2;
	}

	.ark-contest-modal {
		padding: 10px;
	}

	.ark-contest-modal-content {
		max-height: 95vh;
	}

	.ark-contest-modal-header {
		padding: 15px 20px;
	}

	.ark-contest-modal-header h2 {
		font-size: 18px;
	}

	.ark-contest-modal-body {
		padding: 20px;
	}
}

@media screen and (max-width: 480px) {
	.ark-contest-gallery-filters {
		flex-direction: column;
		align-items: stretch;
		min-width: 100%;
	}

	.ark-contest-filter-group {
		min-width: 100%;
	}

	.ark-contest-clear-filters {
		width: 100%;
	}

	.ark-contest-gallery-cols-2 .ark-contest-gallery-grid,
	.ark-contest-gallery-cols-3 .ark-contest-gallery-grid {
		grid-template-columns: 1fr;
	}

	/* Masonry responsive: reduce to 1 column on mobile */
	.ark-contest-gallery-masonry .ark-contest-gallery-grid {
		column-count: 1 !important;
	}

	/* Gallery fields responsive */
	.ark-contest-gallery-fields {
		font-size: 12px;
		padding: 6px 10px 0;
	}

	.ark-contest-gallery-field {
		margin-bottom: 5px;
	}

	.ark-contest-modal-header {
		padding: 12px 15px;
	}

	.ark-contest-modal-header h2 {
		font-size: 16px;
	}

	.ark-contest-modal-body {
		padding: 15px;
		font-size: 14px;
	}

	.ark-contest-modal-close {
		font-size: 28px;
		width: 28px;
		height: 28px;
	}
}
