/**
 * Mondvol Cookie Tasting - tasted tracker, cookie grid, Tasted toggle, ingredients/allergens dialog.
 *
 * Moved verbatim from the astra-child theme (style.css "Cookies Tracker" .. "Tablet Styles", and the
 * Tasted toggle CSS that was duplicated inline in dashboard.php and hall_of_fame.php).
 * Leaderboard and Hall of Fame page styles still live in the Customizer (Additional CSS).
 */

/* Cookies Tracker Section */
.dashboard-cookies-tracker {
	margin: 30px 0;
}

.dashboard-cookies-tracker h3 {
	text-align: center;
	margin: 0 0 20px;
	font-size: 1.3em;
	color: var(--ast-global-color-2);
}

.cookies-progress-bar {
	margin-bottom: 20px;
}

.cookies-progress-bar .progress-text {
	font-size: 1.1em;
	font-weight: 600;
	color: var(--ast-global-color-1);
	margin-bottom: 10px;
	text-align: center;
}

.progress-bar-container {
	background: #e0e0e0;
	border-radius: 25px;
	height: 12px;
	overflow: hidden;
}

.progress-bar-fill {
	background: linear-gradient(90deg, var(--ast-global-color-1) 0%, var(--ast-global-color-0) 100%);
	height: 100%;
	border-radius: 25px;
	transition: width 0.5s ease;
}

.cookies-tracker-subtitle {
	text-align: center;
	color: #666;
	margin-bottom: 25px;
	font-size: 0.95em;
}

/* Cookies Grid - Desktop */
.dashboard-cookies-grid {
	margin-top: 20px;
}

.cookies-slider-container {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
	align-items: stretch;
}

.dashboard-cookie-card {
	background: #ffffff;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	display: flex;
	flex-direction: column;
	height: 100%;
}

.dashboard-cookie-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.dashboard-cookie-card.is-tasted {
	border: 2px solid var(--ast-global-color-1);
}

.dashboard-cookie-card .cookie-image-link {
	display: block;
	flex-shrink: 0;
}

.dashboard-cookie-card .cookie-image-link img {
	width: 100%;
	height: auto;
	display: block;
}

.dashboard-cookie-card .cookie-info {
	padding: 12px;
	text-align: center;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	flex-grow: 1;
}

.dashboard-cookie-card .cookie-name {
	margin: 0 0 10px;
	font-size: 0.9em;
	line-height: 1.3;
	flex-shrink: 0;
}

.dashboard-cookie-card .tasted-toggle {
	margin: auto 0 10px;
}

.dashboard-cookie-card .cookie-info-buttons {
	margin-top: auto;
}

.dashboard-cookie-card .cookie-name a {
	color: var(--ast-global-color-2);
	text-decoration: none;
}

.dashboard-cookie-card .cookie-name a:hover {
	color: var(--ast-global-color-1);
}

/* Tasted Toggle Checkbox */
.tasted-toggle {
	margin-top: 8px;
}

.tasted-checkbox-label {
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	font-size: 0.85em;
	color: #666;
}

.tasted-checkbox-label input[type="checkbox"] {
	display: none;
}

.tasted-checkbox-label .checkmark {
	width: 20px;
	height: 20px;
	border: 2px solid #ccc;
	border-radius: 4px;
	margin-right: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.tasted-checkbox-label input[type="checkbox"]:checked + .checkmark {
	background: var(--ast-global-color-1);
	border-color: var(--ast-global-color-1);
}

.tasted-checkbox-label input[type="checkbox"]:checked + .checkmark::after {
	content: "✓";
	color: #fff;
	font-size: 14px;
	font-weight: bold;
}

.tasted-checkbox-label .tasted-text {
	transition: color 0.2s ease;
}

.tasted-checkbox-label input[type="checkbox"]:checked ~ .tasted-text {
	color: var(--ast-global-color-1);
	font-weight: 600;
}

/* Cookie Info Buttons (Ingredients & Allergens) */
.cookie-info-buttons {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 10px;
}

.cookie-info-btn {
	padding: 8px 12px;
	font-size: 0.75em;
	font-weight: 600;
	border: none;
	border-radius: 20px;
	cursor: pointer;
	transition: all 0.3s ease-in-out;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	background-color: var(--ast-global-color-1);
	color: #ffffff;
	width: 100%;
}

.cookie-info-btn:hover {
	background-color: var(--ast-global-color-0);
	transform: translateY(-1px);
}

/* Cookie Info Dialog Modal */
.cookie-dialog-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.6);
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
}

.cookie-dialog-modal {
	background: #ffffff;
	border-radius: 16px;
	max-width: 400px;
	width: 100%;
	max-height: 80vh;
	overflow-y: auto;
	position: relative;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	animation: dialogFadeIn 0.3s ease-out;
}

@keyframes dialogFadeIn {
	from {
		opacity: 0;
		transform: scale(0.9) translateY(-20px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

.cookie-dialog-close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 32px;
	height: 32px;
	border: none;
	background: #f5f5f5;
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	color: #666;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cookie-dialog-close:hover {
	background: #e0e0e0;
	color: #333;
}

.cookie-dialog-header {
	padding: 24px 24px 16px;
	border-bottom: 1px solid #eee;
}

.cookie-dialog-header h3 {
	margin: 0 0 4px;
	font-size: 1.25em;
	color: var(--ast-global-color-1);
}

.cookie-dialog-header .dialog-subtitle {
	margin: 0;
	font-size: 0.9em;
	color: #666;
}

.cookie-dialog-body {
	padding: 20px 24px 24px;
	font-size: 0.95em;
	line-height: 1.6;
	color: #444;
}

.cookie-dialog-body p {
	margin: 0 0 12px;
}

.cookie-dialog-body p:last-child {
	margin-bottom: 0;
}

/* Mobile Slider Styles */
@media (max-width: 768px) {
	.dashboard-cookies-grid {
		width: 100%;
		overflow: visible;
	}
	
	.cookies-slider-container {
		display: block !important;
		white-space: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		padding: 10px 0 20px;
		margin: 0;
	}
	
	.cookies-slider-container::-webkit-scrollbar {
		display: none;
	}
	
	.dashboard-cookie-card {
		display: inline-flex;
		flex-direction: column;
		vertical-align: top;
		white-space: normal;
		width: 70%;
		min-width: 200px;
		max-width: 250px;
		margin-right: 15px;
		scroll-snap-align: start;
		height: auto;
		min-height: 350px;
	}
	
	.dashboard-cookie-card:last-child {
		margin-right: 0;
	}
	
	.dashboard-cookie-card .cookie-info-buttons {
		gap: 10px;
	}
	
	.dashboard-cookies-tracker {
		padding: 20px 15px;
	}
}

/* Tablet Styles */
@media (max-width: 991px) and (min-width: 769px) {
	.cookies-slider-container {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* Tasted Toggle Switch Styles */
.tasted-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0.75rem 0;
}

.tasted-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.625rem;
	cursor: pointer;
	user-select: none;
}

.tasted-switch input.tasted_checkbox {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.switch-slider {
	position: relative;
	width: 44px;
	height: 24px;
	background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
	border-radius: 24px;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.switch-slider::before {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
	border-radius: 50%;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.tasted-switch input:checked + .switch-slider {
	background: linear-gradient(135deg, #bce8f1 0%, #9ad9e6 100%);
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 12px rgba(188, 232, 241, 0.5);
}

.tasted-switch input:checked + .switch-slider::before {
	transform: translateX(20px);
	background: linear-gradient(135deg, #ffffff 0%, #e8f7fa 100%);
}

.tasted-switch:hover .switch-slider {
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 8px rgba(0, 0, 0, 0.15);
}

.tasted-switch:hover input:checked + .switch-slider {
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 16px rgba(188, 232, 241, 0.6);
}

.tasted-switch input:focus-visible + .switch-slider {
	outline: 2px solid #3b82f6;
	outline-offset: 2px;
}

.tasted-label {
	font-size: 0.875rem;
	font-weight: 500;
	color: #6b7280;
	transition: color 0.3s ease;
}

.tasted-switch input:checked ~ .tasted-label {
	color: #5ba7b5;
	font-weight: 600;
}

/* Animation pulse on toggle */
@keyframes toggle-pulse {
	0% { transform: translateX(20px) scale(1); }
	50% { transform: translateX(20px) scale(1.1); }
	100% { transform: translateX(20px) scale(1); }
}

.tasted-switch input:checked + .switch-slider::before {
	animation: toggle-pulse 0.3s ease;
}

/* =====================================================
   Dashboard "Mark tasted" listing: grid / list view
   (the Hall of Fame keeps the grid and mobile slider)
   ===================================================== */

.mv-listing-bar {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 25px;
}

.mv-listing-bar .cookies-tracker-subtitle {
	margin: 0;
}

.mv-view-toggle {
	position: absolute;
	top: 50%;
	right: 0;
	display: inline-flex;
	gap: 4px;
	padding: 3px;
	border: 1px solid #e5e5e5;
	border-radius: 10px;
	background: #ffffff;
	transform: translateY(-50%);
}

/* Explicit states: the theme's global button:hover/:focus styles would otherwise paint these. */
.mv-view-toggle .mv-view-btn,
.mv-view-toggle .mv-view-btn:focus,
.mv-view-toggle .mv-view-btn:active {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 30px;
	padding: 0;
	border: 0;
	border-radius: 7px;
	background: transparent;
	box-shadow: none;
	color: #9a9a9a;
	cursor: pointer;
}

.mv-view-toggle .mv-view-btn:hover {
	background: #fcf7f6;
	color: var(--ast-global-color-1, #e4b1b0);
}

.mv-view-toggle .mv-view-btn.is-active,
.mv-view-toggle .mv-view-btn.is-active:hover,
.mv-view-toggle .mv-view-btn.is-active:focus {
	background: var(--ast-global-color-1, #e4b1b0);
	color: #ffffff;
}

.mv-view-toggle .mv-view-btn:focus-visible {
	outline: 2px solid #5ba7b5;
	outline-offset: 2px;
}

.mv-view-btn svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

/* List view (desktop/tablet, when chosen) */

.mv-cookies--dashboard.is-list .cookies-slider-container {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.mv-cookies--dashboard.is-list .dashboard-cookie-card {
	flex-direction: row;
	align-items: center;
	gap: 16px;
	height: auto;
	padding: 10px 16px;
}

.mv-cookies--dashboard.is-list .dashboard-cookie-card:hover {
	transform: none;
}

.mv-cookies--dashboard.is-list .cookie-image-link {
	width: 64px;
	height: 64px;
	overflow: hidden;
	border-radius: 50%;
}

.mv-cookies--dashboard.is-list .cookie-image-link img {
	height: 100%;
	object-fit: cover;
}

.mv-cookies--dashboard.is-list .cookie-info {
	flex-direction: row;
	align-items: center;
	gap: 20px;
	padding: 0;
	text-align: left;
}

.mv-cookies--dashboard.is-list .cookie-name {
	flex-grow: 1;
	margin: 0;
	font-size: 1em;
}

.mv-cookies--dashboard.is-list .tasted-toggle {
	margin: 0;
}

.mv-cookies--dashboard.is-list .cookie-info-buttons {
	flex-direction: row;
	gap: 6px;
	margin: 0;
}

.mv-cookies--dashboard.is-list .cookie-info-btn {
	width: auto;
	padding: 6px 12px;
	font-size: 0.7em;
}

/* List view, desktop: fixed columns so every row lines up (badge | photo | name | Tasted | buttons) */
@media (min-width: 769px) {
	.mv-cookies--dashboard.is-list .dashboard-cookie-card {
		display: grid;
		grid-template-columns: 88px 64px minmax(0, 1fr) 110px 230px;
		align-items: center;
		column-gap: 16px;
	}

	.mv-cookies--dashboard.is-list .cookie-info {
		display: contents; /* name, toggle and buttons become columns of the row */
	}

	/* All on one row (a missing badge or button keeps its empty column) */
	.mv-cookies--dashboard.is-list .mv-badge,
	.mv-cookies--dashboard.is-list .cookie-image-link,
	.mv-cookies--dashboard.is-list .cookie-name,
	.mv-cookies--dashboard.is-list .tasted-toggle,
	.mv-cookies--dashboard.is-list .cookie-info-buttons {
		grid-row: 1;
		order: 0;
	}

	.mv-cookies--dashboard.is-list .mv-badge {
		grid-column: 1;
		justify-self: center;
	}

	.mv-cookies--dashboard.is-list .cookie-image-link {
		grid-column: 2;
	}

	.mv-cookies--dashboard.is-list .cookie-name {
		grid-column: 3;
		min-width: 0; /* long names wrap instead of pushing the buttons out */
	}

	.mv-cookies--dashboard.is-list .tasted-toggle {
		grid-column: 4;
	}

	.mv-cookies--dashboard.is-list .cookie-info-buttons {
		grid-column: 5;
		justify-content: flex-end;
	}

	.mv-cookies--dashboard.is-list .cookie-image-link img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

/* Mobile: the dashboard listing is always a list (no toggle, no slider) */

@media (max-width: 768px) {
	.mv-view-toggle {
		display: none;
	}

	.mv-cookies--dashboard .cookies-slider-container {
		display: flex !important;
		flex-direction: column;
		gap: 10px;
		padding: 0;
		overflow: visible;
		white-space: normal;
	}

	.mv-cookies--dashboard .dashboard-cookie-card {
		display: flex;
		flex-direction: row;
		align-items: flex-start;
		gap: 14px;
		width: 100%;
		min-width: 0;
		max-width: none;
		min-height: 0;
		margin: 0;
		padding: 12px;
	}

	.mv-cookies--dashboard .dashboard-cookie-card:hover {
		transform: none;
	}

	.mv-cookies--dashboard .cookie-image-link {
		order: -1;
		flex-shrink: 0;
		width: 72px;
		height: 72px;
		overflow: hidden;
		border-radius: 50%;
	}

	.mv-cookies--dashboard .cookie-image-link img {
		height: 100%;
		object-fit: cover;
	}

	.mv-cookies--dashboard .cookie-info {
		align-items: flex-start;
		gap: 8px;
		padding: 0;
		text-align: left;
	}

	.mv-cookies--dashboard .cookie-name {
		margin: 0;
		font-size: 1em;
	}

	.mv-cookies--dashboard .tasted-toggle {
		justify-content: flex-start;
		margin: 0;
	}

	.mv-cookies--dashboard .cookie-info-buttons {
		flex-direction: row;
		gap: 6px;
		margin: 0;
	}

	.mv-cookies--dashboard .cookie-info-btn {
		width: auto;
		padding: 6px 12px;
		font-size: 0.7em;
	}
}
