/**
 * SERP Preview - Preview Controls
 *
 * Theme toggle button and device tabs styling.
 *
 * @package AgenticWP
 */

/* ============================================
   Preview Controls Container
   ============================================ */

.preview-controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--tool-space-md);
	margin-bottom: var(--tool-space-lg);
	padding-bottom: var(--tool-space-md);
	border-bottom: 1px solid var(--tool-border);
}

.preview-controls-left {
	display: flex;
	align-items: center;
	gap: var(--tool-space-md);
}

.preview-controls-right {
	display: flex;
	align-items: center;
	gap: var(--tool-space-sm);
}

.preview-heading {
	margin: 0;
	font-size: var(--tool-font-lg);
	font-weight: 600;
	color: var(--tool-text);
}

/* ============================================
   Theme Toggle Button
   ============================================ */

.theme-toggle {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	background: var(--tool-bg-subtle);
	border: 1px solid var(--tool-border);
	border-radius: var(--tool-radius-md);
	cursor: pointer;
	transition:
		background-color var(--tool-transition-base),
		border-color var(--tool-transition-base),
		box-shadow var(--tool-transition-base);
}

.theme-toggle:hover {
	background: var(--tool-bg);
	border-color: var(--tool-border-strong);
	box-shadow: var(--tool-shadow-sm);
}

.theme-toggle:focus-visible {
	outline: none;
	box-shadow: var(--tool-shadow-focus);
}

.theme-toggle-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--tool-text-muted);
	transition:
		opacity var(--tool-transition-base),
		transform var(--tool-transition-base),
		color var(--tool-transition-base);
}

.theme-toggle-icon svg {
	width: 20px;
	height: 20px;
}

/* Light icon (sun) - visible in light mode */
.theme-toggle-icon--light {
	position: absolute;
}

/* Dark icon (moon) - visible in dark mode */
.theme-toggle-icon--dark {
	position: absolute;
	opacity: 0;
	transform: rotate(-90deg) scale(0.5);
}

/* When dark mode is active (aria-pressed="true") */
.theme-toggle[aria-pressed="true"] .theme-toggle-icon--light {
	opacity: 0;
	transform: rotate(90deg) scale(0.5);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-icon--dark {
	opacity: 1;
	transform: rotate(0deg) scale(1);
	color: var(--serp-accent, var(--tool-info));
}

.theme-toggle[aria-pressed="true"] {
	background: var(--ink);
	border-color: var(--ink);
}

.theme-toggle[aria-pressed="true"]:hover {
	background: #1a2333;
	border-color: #1a2333;
}

/* ============================================
   Device Tabs (Mobile Navigation)
   ============================================ */

.device-tabs {
	display: none;
	gap: var(--tool-space-xs);
	padding: var(--tool-space-xs);
	margin-bottom: var(--tool-space-lg);
	background: var(--tool-bg-subtle);
	border: 1px solid var(--tool-border);
	border-radius: var(--tool-radius-lg);
}

.device-tab {
	flex: 1;
	min-height: 44px;
	padding: var(--tool-space-sm) var(--tool-space-md);
	font-size: var(--tool-font-base);
	font-weight: 500;
	color: var(--tool-text-muted);
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--tool-radius-md);
	cursor: pointer;
	transition:
		background-color var(--tool-transition-base),
		color var(--tool-transition-base),
		border-color var(--tool-transition-base),
		box-shadow var(--tool-transition-base);
}

.device-tab:hover {
	color: var(--tool-text);
	background: rgba(255, 255, 255, 0.5);
}

.device-tab:focus-visible {
	outline: none;
	box-shadow: var(--tool-shadow-focus);
}

/* Active tab state */
.device-tab--active,
.device-tab[aria-selected="true"] {
	color: var(--tool-text);
	background: var(--tool-bg);
	border-color: var(--tool-border);
	box-shadow: var(--tool-shadow-sm);
}

.device-tab--active:hover,
.device-tab[aria-selected="true"]:hover {
	background: var(--tool-bg);
}

/* ============================================
   Device Labels
   ============================================ */

.device-label {
	display: flex;
	align-items: center;
	gap: var(--tool-space-sm);
	margin-bottom: var(--tool-space-md);
	font-size: var(--tool-font-sm);
	font-weight: 600;
	color: var(--tool-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.device-width {
	font-weight: 400;
	color: var(--tool-text-muted);
	opacity: 0.7;
}

/* ============================================
   Responsive Behavior
   ============================================ */

/* Show device tabs on narrow viewports */
@media (max-width: 900px) {
	.device-tabs {
		display: flex;
	}

	/* Hide device labels when tabs are visible */
	.device-label {
		display: none;
	}
}

/* Stack controls on very narrow viewports */
@media (max-width: 480px) {
	.preview-controls {
		flex-direction: column;
		align-items: stretch;
		gap: var(--tool-space-sm);
	}

	.preview-controls-left {
		justify-content: center;
	}

	.preview-controls-right {
		justify-content: center;
	}

	.preview-heading {
		text-align: center;
	}
}

/* ============================================
   Export Button
   ============================================ */

#serp-export-btn {
	position: relative;
	gap: var(--tool-space-xs);
}

#serp-export-btn svg {
	flex-shrink: 0;
}

#serp-export-btn.is-loading {
	pointer-events: none;
}

#serp-export-btn.is-loading svg,
#serp-export-btn.is-loading span {
	visibility: hidden;
}

#serp-export-btn.is-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

/* Spin animation defined in accessibility.css */

/* ============================================
   Progressive Enhancement (No-JS)
   ============================================ */

/* Hide JS-only controls when JavaScript is disabled */
.no-js #serp-export-btn,
.no-js #serp-fetch-btn,
.no-js #serp-copy-html-btn,
.no-js #serp-reset-btn,
.no-js .theme-toggle,
.no-js .device-tabs,
.no-js .char-counter {
	display: none;
}

/* Show both previews in no-JS mode */
.no-js .serp-preview[hidden] {
	display: flex;
}

/* Show helpful message for no-JS users */
.no-js .serp-form-section::before {
	content: 'JavaScript is required for real-time preview updates. Fill in the fields below to see how your content will appear.';
	display: block;
	max-width: 640px;
	margin: 0 auto var(--tool-space-lg);
	padding: var(--tool-space-md);
	font-size: var(--tool-font-sm);
	color: var(--tool-text-muted);
	background: var(--tool-bg-subtle);
	border: 1px solid var(--tool-border);
	border-radius: var(--tool-radius-md);
	text-align: center;
}

/* Reduced motion styles consolidated in accessibility.css */
/* Toast styles consolidated in shared/components.css */
