/**
 * iPhone Preview - Frontend styles
 * Desktop (full) / Tablet (iPad frame) / Mobile (iPhone frame)
 */

/* ---------- Base ---------- */
.iphone-preview-body {
	margin: 0;
	padding: 0;
	min-height: 100vh;
	background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	overflow-x: hidden;
	box-sizing: border-box;
}

.iphone-preview-body *,
.iphone-preview-body *::before,
.iphone-preview-body *::after {
	box-sizing: border-box;
}

/* ---------- Toolbar (switch dispositivo) ---------- */
.iphone-preview-toolbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1000;
	background: rgba(0, 0, 0, 0.75);
	backdrop-filter: blur(8px);
	padding: 12px 16px;
	display: flex;
	align-items: center;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.iphone-preview-back {
	position: relative;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	background: var(--iphone-preview-back-bg, #3d3d3d);
	color: var(--iphone-preview-back-color, #fff);
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
	border-radius: 8px;
	transition: opacity 0.2s, background 0.2s, filter 0.2s;
	flex-shrink: 0;
}
.iphone-preview-back:hover {
	opacity: 0.95;
	filter: brightness(1.1);
	color: var(--iphone-preview-back-color, #fff);
}
.iphone-preview-back-icon {
	font-size: 18px;
	line-height: 1;
}

.iphone-preview-toolbar-inner {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}
.iphone-preview-toolbar-inner .iphone-preview-device-btn {
	pointer-events: auto;
}

.iphone-preview-device-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 18px;
	border: none !important;
	border-radius: 20px;
	background: var(--iphone-preview-btn-bg, rgba(255, 255, 255, 0.08));
	color: var(--iphone-preview-btn-color, #fff);
	font-weight: 700;
	cursor: pointer;
	font-size: 14px;
}

.iphone-preview-device-btn:hover {
	filter: brightness(1.15);
	background: var(--iphone-preview-btn-active-bg, rgba(255, 255, 255, 0.08));
	color: var(--iphone-preview-btn-active-color, #fff);
}

.iphone-preview-device-btn.active {
	background: var(--iphone-preview-btn-active-bg, rgba(255, 255, 255, 0.2));
	color: var(--iphone-preview-btn-active-color, #fff);
}

.iphone-preview-device-btn .icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	color: inherit;
	opacity: 0.95;
}

.iphone-preview-device-btn .icon svg {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* ---------- Viewports: top = altezza toolbar (impostata via JS) ---------- */
.iphone-preview-viewport {
	display: none;
	/*position: fixed;*/
	position: relative;
	top: var(--iphone-preview-toolbar-height, 56px);
	/*left: 0;
	right: 0;
	bottom: 0;*/
	align-items: center;
	justify-content: center;
	padding: 2rem;
	overflow: auto;
	min-height: calc(100vh - var(--iphone-preview-toolbar-height, 56px));
}

.iphone-preview-viewport-desktop {
	padding: 0;
	align-items: stretch;
	justify-content: stretch;
}

.iphone-preview-body.iphone-preview-viewport-desktop .iphone-preview-viewport-desktop,
.iphone-preview-body.iphone-preview-viewport-tablet .iphone-preview-viewport-tablet,
.iphone-preview-body.iphone-preview-viewport-mobile .iphone-preview-viewport-mobile {
	display: flex;
}

/* ---------- Desktop: iframe a tutto lo spazio disponibile ---------- */
.iphone-preview-viewport-desktop .iphone-preview-desktop-inner {
	position: relative;
	flex: 1;
	width: 100%;
	min-width: 0;
	min-height: 0;
	background: #fff;
	overflow: hidden;
}

.iphone-preview-viewport-desktop .iphone-preview-iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* ---------- iPad frame (Tablet) ---------- */
.ipad-frame {
	position: relative;
	width: 576px;
	min-height: 768px;
	max-height: 85vh;
	background: #1c1c1e;
	border-radius: 32px;
	padding: 16px;
	box-shadow:
		0 0 0 2px #2c2c2e,
		0 0 0 5px #1c1c1e,
		0 25px 60px -12px rgba(0, 0, 0, 0.6),
		inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.ipad-notch {
	position: absolute;
	top: 16px;
	left: 50%;
	transform: translateX(-50%);
	width: 80px;
	height: 22px;
	background: #000;
	border-radius: 0 0 14px 14px;
	z-index: 2;
}

.ipad-screen {
	position: relative;
	width: 100%;
	height: 100%;
	min-height: 736px;
	background: #000;
	border-radius: 22px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* Status bar (iPad e iPhone) */
.device-status-bar {
	position: relative;
	z-index: 3;
	flex-shrink: 0;
	height: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px 0 24px;
	color: rgba(255, 255, 255, 0.95);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.02em;
	-webkit-user-select: none;
	user-select: none;
}

.device-status-bar.device-status-bar--light {
	color: rgba(0, 0, 0, 0.85);
}

.device-status-bar.device-status-bar--light .device-status-bar-signal i,
.device-status-bar.device-status-bar--light .device-status-bar-wifi,
.device-status-bar.device-status-bar--light .device-status-bar-battery {
	color: inherit;
}

.ipad-screen .device-status-bar {
	padding: 0 24px 0 28px;
	font-size: 16px;
	height: 50px;
	min-height: 50px;
}

.device-status-bar-time {
	opacity: 0.95;
}

.device-status-bar-icons {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
	flex-shrink: 0;
}

.device-status-bar-signal,
.device-status-bar-wifi,
.device-status-bar-battery {
	display: inline-block;
	background: currentColor;
	opacity: 0.9;
}

.device-status-bar-signal {
	display: flex;
	align-items: flex-end;
	gap: 2px;
	height: 12px;
}

.device-status-bar-signal i {
	display: block;
	width: 3px;
	background: currentColor;
	border-radius: 1px;
}

.device-status-bar-signal i:nth-child(1) { height: 4px; }
.device-status-bar-signal i:nth-child(2) { height: 6px; }
.device-status-bar-signal i:nth-child(3) { height: 9px; }
.device-status-bar-signal i:nth-child(4) { height: 12px; }

.device-status-bar-wifi {
	width: 14px;
	height: 10px;
	border: 2px solid currentColor;
	border-top: none;
	border-radius: 0 0 50% 50%;
	background: transparent;
}

.device-status-bar-battery {
	width: 25px;
	height: 12px;
	border: 1.5px solid currentColor;
	border-radius: 2px;
	position: relative;
	display: inline-flex;
	align-items: stretch;
	overflow: hidden;
	box-sizing: border-box;
}

.device-status-bar-battery-fill {
	display: block;
	height: 100%;
	background: currentColor;
	border-radius: 1px;
	min-width: 2px;
	transition: width 0.2s ease;
}

.device-status-bar-battery::after {
	content: '';
	position: absolute;
	right: -3px;
	top: 50%;
	transform: translateY(-50%);
	width: 2px;
	height: 6px;
	background: currentColor;
	border-radius: 0 1px 1px 0;
	pointer-events: none;
}

/* Area sotto la status bar (iframe) */
.device-screen-content {
	position: relative;
	flex: 1;
	min-height: 0;
	overflow: hidden;
}

.ipad-screen .device-screen-content {
	/* iPad: status bar 50px */
}

.iphone-screen .device-screen-content {
	/* iPhone: status bar 44px */
}

.device-screen-content .iphone-preview-iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

.ipad-screen .device-screen-content .iphone-preview-iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* ---------- iPhone frame (Mobile) 390 × 844 ---------- */
.iphone-frame {
	position: relative;
	width: 418px;   /* 390 + padding 14px × 2 */
	min-height: 872px;  /* 844 + padding 14px × 2 */
	max-height: 90vh;
	background: #1c1c1e;
	border-radius: 44px;
	padding: 14px;
	box-shadow:
		0 0 0 3px #2c2c2e,
		0 0 0 6px #1c1c1e,
		0 25px 50px -12px rgba(0, 0, 0, 0.6),
		inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Dynamic Island (iPhone 14 Pro e successivi) – sopra la status bar, nera e visibile */
.iphone-island {
	position: absolute;
	top: 14px;
	left: 50%;
	transform: translateX(-50%);
	width: 126px;
	height: 37px;
	background: #000;
	border-radius: 20px;
	z-index: 4;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
	pointer-events: none;
}

.iphone-screen {
	position: relative;
	width: 100%;
	height: 844px;
	min-height: 844px;
	background: #000;
	border-radius: 34px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.iphone-screen .device-screen-content .iphone-preview-iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* ---------- Loader ---------- */
.iphone-preview-loader {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.iphone-preview-loader.iphone-preview-loaded {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.iphone-preview-loader-inner {
	width: 48px;
	height: 48px;
	border: 4px solid rgba(255, 255, 255, 0.2);
	border-top-color: #fff;
	border-radius: 50%;
	animation: iphonepreview-spin 0.8s linear infinite;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
	.iphone-preview-toolbar-inner {
		display: none;
	}
	.iphone-preview-viewport-desktop {
		padding: 0 !important;
	}
}

@media (max-width: 640px) {
	.iphone-preview-toolbar-inner {
		flex-wrap: wrap;
		justify-content: center;
	}
	.iphone-preview-device-btn .label {
		display: none;
	}
	.iphone-preview-device-btn {
		padding: 12px 14px;
	}
	.ipad-frame {
		width: 420px;
		min-height: 560px;
		padding: 12px;
		border-radius: 24px;
	}
	.ipad-screen {
		min-height: 536px;
		border-radius: 18px;
	}
	.iphone-frame {
		width: min(418px, 100vw - 2rem);
		padding: 12px;
		border-radius: 38px;
		min-height: 860px;
	}
	.iphone-island {
		width: 110px;
		height: 32px;
		border-radius: 16px;
		top: 12px;
	}
	.iphone-screen {
		height: 844px;
		min-height: 844px;
		border-radius: 28px;
	}
	.iphone-preview-viewport {
		padding: 1rem;
	}
}
