/**
 * Breakdance Consent — Preferences Modal Styles
 *
 * Styles the <dialog>-based preferences panel.
 *
 * @package BreakdanceConsent
 */

/* ── Dialog reset & backdrop ── */
.breakdance-consent__preferences {
	border: none;
	border-radius: var(--bdc-radius, 0.5rem);
	background: var(--bdc-color-bg, #ffffff);
	box-shadow: var(--bdc-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
	max-width: 640px;
	width: 90vw;
	max-height: 85vh;
	padding: 0;
	color: var(--bdc-color-text, #374151);
	font-family: var(--bdc-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
	overflow: visible;
}

/* ── Open animation ── */
.breakdance-consent__preferences[open] {
	animation: bdc-dialog-in 0.2s ease-out;
}

.breakdance-consent__preferences[open]::backdrop {
	animation: bdc-backdrop-in 0.2s ease-out;
}

@keyframes bdc-dialog-in {
	from {
		opacity: 0;
		transform: scale(0.96) translateY(0.5rem);
	}
}

@keyframes bdc-backdrop-in {
	from {
		opacity: 0;
	}
}

.breakdance-consent__preferences::backdrop {
	background: rgba(0, 0, 0, var(--bdc-overlay-opacity, 0.5));
}

/* ── Inner layout ── */
.breakdance-consent__preferences-inner {
	display: flex;
	flex-direction: column;
	max-height: 85vh;
}

/* ── Header ── */
.breakdance-consent__preferences-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--bdc-spacing-lg, 1.5rem) var(--bdc-spacing-xl, 2rem);
	border-bottom: 1px solid var(--bdc-color-border, #d1d5db);
	flex-shrink: 0;
}

.breakdance-consent__preferences-header h2 {
	font-size: var(--bdc-font-size-base, 1rem);
	font-weight: 700;
	margin: 0;
	color: var(--bdc-color-heading, var(--bdc-color-text, #374151)) !important;
}

/* ── Close button ── */
.breakdance-consent__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: none;
	background: transparent;
	cursor: pointer;
	font-size: 1.5rem;
	color: var(--bdc-color-text-muted, #6b7280);
	border-radius: var(--bdc-radius, 0.5rem);
	padding: 0;
	line-height: 1;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.breakdance-consent__close:hover {
	background: var(--bdc-color-surface, #f9fafb);
	color: var(--bdc-color-text, #374151);
}

.breakdance-consent__close:focus-visible {
	outline: 2px solid var(--bdc-color-primary, #1a56db);
	outline-offset: 2px;
}

/* ── Body (scrollable) ── */
.breakdance-consent__preferences-body {
	flex: 1;
	overflow-y: auto;
	padding: var(--bdc-spacing-md, 1rem) var(--bdc-spacing-xl, 2rem);
}

/* ── Category blocks ── */
.breakdance-consent__category {
	padding: var(--bdc-spacing-md, 1rem) 0;
	border-bottom: 1px solid var(--bdc-color-border, #d1d5db);
}

.breakdance-consent__category:last-child {
	border-bottom: none;
}

.breakdance-consent__category-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--bdc-spacing-sm, 0.75rem);
}

/* ── Toggle (checkbox + label) ── */
.breakdance-consent__toggle {
	display: flex;
	align-items: center;
	gap: var(--bdc-spacing-sm, 0.75rem);
	cursor: pointer;
	min-height: 44px;
}

.breakdance-consent__toggle input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 44px;
	height: 24px;
	background: var(--bdc-color-border, #d1d5db);
	border-radius: 12px;
	position: relative;
	cursor: pointer;
	flex-shrink: 0;
	transition: background-color 0.15s ease;
	border: none;
	margin: 0;
}

.breakdance-consent__toggle input[type="checkbox"]::after {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	background: #ffffff;
	border-radius: 50%;
	transition: transform 0.15s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.breakdance-consent__toggle input[type="checkbox"]:checked {
	background: var(--bdc-color-toggle-active, var(--bdc-color-primary, #1a56db));
}

.breakdance-consent__toggle input[type="checkbox"]:checked::after {
	transform: translateX(20px);
}

/* Required category: locked on — show as fully active, not dimmed */
.breakdance-consent__toggle input[type="checkbox"]:disabled:checked {
	background: var(--bdc-color-toggle-active, var(--bdc-color-primary, #1a56db));
	opacity: 1;
	cursor: default;
}

.breakdance-consent__toggle input[type="checkbox"]:disabled:not(:checked) {
	cursor: default;
}

.breakdance-consent__toggle input[type="checkbox"]:focus-visible {
	outline: 2px solid var(--bdc-color-primary, #1a56db);
	outline-offset: 2px;
}

.breakdance-consent__toggle-label {
	font-size: var(--bdc-font-size-sm, 0.875rem);
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: var(--bdc-spacing-xs, 0.5rem);
}

/* ── Always active badge ── */
.breakdance-consent__badge {
	font-size: 0.75rem;
	font-weight: 600;
	color: #15803d;
	background: #f0fdf4;
	border: 1px solid #bbf7d0;
	padding: 2px 8px;
	border-radius: 9999px;
	white-space: nowrap;
}

/* Dark mode: softer green tones */
html[data-theme="dark"] .breakdance-consent__badge {
	color: #86efac;
	background: rgba(34, 197, 94, 0.1);
	border-color: rgba(34, 197, 94, 0.25);
}

/* ── Details toggle ── */
.breakdance-consent__details-toggle {
	font-size: var(--bdc-font-size-sm, 0.875rem);
	color: var(--bdc-color-link, var(--bdc-color-primary, #1a56db));
	background: transparent;
	border: none;
	cursor: pointer;
	padding: var(--bdc-spacing-xs, 0.5rem);
	min-height: 44px;
	min-width: 44px;
	text-decoration: underline;
	white-space: nowrap;
	transition: color 0.15s ease;
}

.breakdance-consent__details-toggle:hover {
	color: var(--bdc-color-link-hover, var(--bdc-color-primary-hover, #1244b0));
}

.breakdance-consent__details-toggle:focus-visible {
	outline: 2px solid var(--bdc-color-primary, #1a56db);
	outline-offset: 2px;
}

/* ── Category description ── */
.breakdance-consent__category-desc {
	font-size: var(--bdc-font-size-sm, 0.875rem);
	color: var(--bdc-color-text-muted, #6b7280);
	margin: var(--bdc-spacing-xs, 0.5rem) 0 0;
	line-height: 1.4;
}

/* ── Cookie table ── */
.breakdance-consent__category-cookies {
	margin-top: var(--bdc-spacing-sm, 0.75rem);
}

.breakdance-consent__cookie-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.8125rem;
}

.breakdance-consent__cookie-table th {
	text-align: left;
	font-weight: 600;
	color: var(--bdc-color-text-muted, #6b7280);
	padding: var(--bdc-spacing-xs, 0.5rem) var(--bdc-spacing-sm, 0.75rem);
	border-bottom: 1px solid var(--bdc-color-border, #d1d5db);
	white-space: nowrap;
}

.breakdance-consent__cookie-table td {
	padding: var(--bdc-spacing-xs, 0.5rem) var(--bdc-spacing-sm, 0.75rem);
	border-bottom: 1px solid var(--bdc-color-surface, #f9fafb);
	vertical-align: top;
}

.breakdance-consent__cookie-table code {
	font-size: 0.8125rem;
	background: var(--bdc-color-surface, #f9fafb);
	padding: 1px 4px;
	border-radius: 3px;
}

/* ── Footer ── */
.breakdance-consent__preferences-footer {
	padding: var(--bdc-spacing-md, 1rem) var(--bdc-spacing-xl, 2rem);
	background: var(--bdc-color-bg, #ffffff);
	border-top: 1px solid var(--bdc-color-border, #d1d5db);
	border-bottom-left-radius: var(--bdc-radius, 0.5rem);
	border-bottom-right-radius: var(--bdc-radius, 0.5rem);
	flex-shrink: 0;
	display: flex;
	justify-content: flex-end;
}

/* ── Hidden state ── */
.breakdance-consent__category-cookies[hidden] {
	display: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
	.breakdance-consent__preferences {
		width: 100vw;
		max-width: 100vw;
		max-height: 100vh;
		border-radius: 0;
		margin: 0;
	}

	.breakdance-consent__preferences-inner {
		max-height: 100vh;
	}

	.breakdance-consent__cookie-table {
		font-size: 0.75rem;
	}
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
	.breakdance-consent__preferences[open],
	.breakdance-consent__preferences[open]::backdrop {
		animation: none;
	}

	.breakdance-consent__toggle input[type="checkbox"],
	.breakdance-consent__toggle input[type="checkbox"]::after {
		transition: none;
	}

	.breakdance-consent__close,
	.breakdance-consent__details-toggle {
		transition: none;
	}
}
