/**
 * Milo AI Chat – frontend styles (dark full-screen theme).
 *
 * Uses CSS custom properties so the primary color can be injected inline
 * from the plugin settings without requiring a dynamic stylesheet endpoint.
 */

/* ─── Reset & base ──────────────────────────────────────────────────────── */
.milo-chat-widget *,
.milo-chat-widget *::before,
.milo-chat-widget *::after {
	box-sizing: border-box;
}

/* ─── Widget container ─────────────────────────────────────────────────── */
.milo-chat-widget {
	--milo-primary:        #2563eb;
	--milo-bg:             #0a1628;  /* Deep ocean base */
	--milo-surface:        rgba(15, 35, 60, 0.85);
	--milo-surface-alt:    rgba(20, 45, 75, 0.9);
	--milo-border:         rgba(59, 130, 246, 0.3);
	--milo-text:           #ffffff;
	--milo-text-muted:     #9ca3af;
	--milo-ai-bubble-bg:   rgba(15, 35, 60, 0.9);
	--milo-user-bubble-bg: rgba(30, 58, 95, 0.9);
	--milo-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--milo-radius:         1rem;

	display:        flex;
	flex-direction: column;
	align-items:    center;
	width:          100%;
	min-height:     100vh;
	/* Ocean gradient background */
	background:     linear-gradient(180deg,
		#0a1628 0%,
		#0d2847 25%,
		#134e6f 50%,
		#1a5276 75%,
		#0d2847 100%
	);
	font-family:    var(--milo-font);
	color:          var(--milo-text);
	overflow:       hidden;
	position:       relative;
}

/* ─── Ocean wave overlay ───────────────────────────────────────────────── */
.milo-chat-widget::before {
	content:    '';
	position:   absolute;
	top:        0;
	left:       0;
	right:      0;
	bottom:     0;
	background:
		radial-gradient(ellipse at 50% 100%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
		radial-gradient(ellipse at 30% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 40%),
		radial-gradient(ellipse at 70% 60%, rgba(59, 130, 246, 0.08) 0%, transparent 35%);
	pointer-events: none;
	z-index:    0;
}

.milo-chat-widget > * {
	position: relative;
	z-index:  1;
}

/* ─── Fullscreen mode: fixed overlay ───────────────────────────────────── */
.milo-chat-widget--fullscreen {
	position: fixed;
	inset:    0;
	z-index:  99999;
	min-height: 100%;
}

/* ─── Hide theme chrome when fullscreen is active ───────────────────────── */
body.milo-chat-fullscreen > *:not(#page):not(.milo-chat-widget):not(.wp-site-blocks):not(script):not(style),
body.milo-chat-fullscreen header,
body.milo-chat-fullscreen #masthead,
body.milo-chat-fullscreen .site-header,
body.milo-chat-fullscreen .wp-site-blocks > header,
body.milo-chat-fullscreen footer,
body.milo-chat-fullscreen #footer,
body.milo-chat-fullscreen #colophon,
body.milo-chat-fullscreen .site-footer,
body.milo-chat-fullscreen .wp-site-blocks > footer,
body.milo-chat-fullscreen aside,
body.milo-chat-fullscreen .sidebar,
body.milo-chat-fullscreen #sidebar,
body.milo-chat-fullscreen #secondary,
body.milo-chat-fullscreen .widget-area,
body.milo-chat-fullscreen nav.navbar,
body.milo-chat-fullscreen #navigation,
body.milo-chat-fullscreen #header,
body.milo-chat-fullscreen .wp-block-post-title {
	display: none !important;
}

body.milo-chat-fullscreen {
	overflow: hidden;
	margin:   0 !important;
	padding:  0;
}

/* ─── Welcome / empty-state screen ────────────────────────────────────── */
.milo-chat-welcome {
	display:         flex;
	flex-direction:  column;
	align-items:     center;
	justify-content: center;
	gap:             1.5rem;
	flex:            1;
	width:           100%;
	max-width:       680px;
	padding:         2rem 1.5rem;
	text-align:      center;
	transition:      opacity 0.3s, transform 0.3s;
}

.milo-chat-welcome.is-hidden {
	display: none;
}

.milo-chat-welcome__avatar {
	width:         80px;
	height:        80px;
	border-radius: 50%;
	object-fit:    cover;
	display:       block;
	/* Glow effect to make logo stand out against ocean background */
	box-shadow:    0 0 20px rgba(59, 130, 246, 0.5),
	               0 0 40px rgba(6, 182, 212, 0.3);
	border:        2px solid rgba(255, 255, 255, 0.2);
}

.milo-chat-welcome__title {
	margin:      0;
	font-size:   clamp(1.5rem, 4vw, 2.25rem);
	font-weight: 600;
	line-height: 1.3;
	color:       var(--milo-text);
}

/* Gradient accent on the last word of the welcome title */
.milo-chat-welcome__accent {
	background:              linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #60a5fa 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip:         text;
}

/* ─── Message list ─────────────────────────────────────────────────────── */
.milo-chat-messages {
	flex:            1;
	overflow-y:      auto;
	padding:         1rem 1.5rem;
	display:         flex;
	flex-direction:  column;
	gap:             1rem;
	scroll-behavior: smooth;
	width:           100%;
	max-width:       768px;
	scrollbar-width: thin;
	scrollbar-color: var(--milo-surface-alt) transparent;
}

.milo-chat-messages::-webkit-scrollbar {
	width: 6px;
}

.milo-chat-messages::-webkit-scrollbar-thumb {
	background:    var(--milo-surface-alt);
	border-radius: 3px;
}

/* ─── Individual message ───────────────────────────────────────────────── */
.milo-chat-message {
	display:        flex;
	flex-direction: column;
	max-width:      78%;
}

.milo-chat-message--ai {
	align-self:     flex-start;
	flex-direction: row;
	align-items:    flex-start;
	gap:            0.5rem;
}

.milo-chat-message--user {
	align-self: flex-end;
}

/* Avatar shown next to AI messages */
.milo-chat-message__avatar {
	width:         32px;
	height:        32px;
	border-radius: 50%;
	object-fit:    cover;
	flex-shrink:   0;
	margin-top:    0.2rem;
}

.milo-chat-message__bubble {
	padding:       0.75rem 1rem;
	border-radius: var(--milo-radius);
	font-size:     0.9375rem;
	line-height:   1.6;
	word-break:    break-word;
	white-space:   pre-wrap;
}

.milo-chat-message--ai .milo-chat-message__bubble {
	background:              var(--milo-ai-bubble-bg);
	color:                   var(--milo-text);
	border-top-left-radius:  0.25rem;
}

.milo-chat-message--user .milo-chat-message__bubble {
	background:               var(--milo-user-bubble-bg);
	color:                    var(--milo-text);
	border-top-right-radius:  0.25rem;
}

/* Attached image inside a message bubble */
.milo-chat-message__image {
	max-width:     100%;
	max-height:    260px;
	border-radius: calc(var(--milo-radius) - 2px);
	display:       block;
	margin-bottom: 0.5rem;
	object-fit:    contain;
}

/* ─── Links inside message bubbles ─────────────────────────────────────── */
.milo-chat-message__bubble a {
	color:           #60a5fa;  /* Bright blue that stands out on dark background */
	text-decoration: underline;
	text-underline-offset: 2px;
	transition:      color 0.15s;
}

.milo-chat-message__bubble a:hover {
	color: #93c5fd;  /* Lighter blue on hover */
}

.milo-chat-message__bubble a:visited {
	color:           #a78bfa;  /* Purple for visited links */
}

/* ─── Typing indicator ─────────────────────────────────────────────────── */
.milo-chat-typing {
	display:      flex;
	align-items:  center;
	gap:          0.3rem;
	padding:      0.25rem 1.5rem 0;
	flex-shrink:  0;
	width:        100%;
	max-width:    768px;
}

.milo-chat-typing[hidden] {
	display: none;
}

.milo-chat-typing span {
	width:         8px;
	height:        8px;
	border-radius: 50%;
	background:    var(--milo-text-muted);
	animation:     milo-bounce 1.4s infinite ease-in-out both;
	display:       block;
}

.milo-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.milo-chat-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes milo-bounce {
	0%, 80%, 100% { transform: scale(0); }
	40%           { transform: scale(1); }
}

/* ─── Image preview strip ──────────────────────────────────────────────── */
.milo-chat-image-preview {
	display:     flex;
	align-items: center;
	gap:         0.5rem;
	padding:     0.5rem 1.5rem 0;
	flex-shrink: 0;
	width:       100%;
	max-width:   768px;
}

.milo-chat-image-preview[hidden] {
	display: none;
}

.milo-chat-image-preview img {
	height:        56px;
	width:         56px;
	object-fit:    cover;
	border-radius: 0.375rem;
	border:        2px solid var(--milo-border);
}

.milo-chat-image-remove {
	background:    transparent;
	border:        none;
	cursor:        pointer;
	color:         var(--milo-text-muted);
	font-size:     1rem;
	line-height:   1;
	padding:       0.25rem;
	border-radius: 50%;
	transition:    color 0.15s, background 0.15s;
}

.milo-chat-image-remove:hover {
	color:      #ef4444;
	background: rgba(239, 68, 68, 0.15);
}

/* ─── Input wrapper ────────────────────────────────────────────────────── */
.milo-chat-input-wrapper {
	width:      100%;
	max-width:  768px;
	padding:    0.75rem 1.5rem 2rem;
	flex-shrink: 0;
}

/* ─── Input area ───────────────────────────────────────────────────────── */
.milo-chat-form {
	width: 100%;
}

.milo-chat-input-row {
	display:       flex;
	align-items:   center;
	gap:           0.4rem;
	background:    var(--milo-surface);
	border:        1.5px solid var(--milo-border);
	border-radius: 9999px;
	padding:       0.45rem 0.45rem 0.45rem 1rem;
	transition:    border-color 0.2s, box-shadow 0.2s;
}

.milo-chat-input-row:focus-within {
	border-color: var(--milo-primary);
	box-shadow:   0 0 0 3px color-mix(in srgb, var(--milo-primary) 20%, transparent);
}

.milo-chat-attach {
	display:         flex;
	align-items:     center;
	justify-content: center;
	flex-shrink:     0;
	cursor:          pointer;
	color:           var(--milo-text-muted);
	padding:         0.3rem;
	border-radius:   50%;
	transition:      color 0.15s, background 0.15s;
}

.milo-chat-attach:hover {
	color:      var(--milo-text);
	background: var(--milo-surface-alt);
}

.milo-chat-attach--disabled {
	cursor: default;
	opacity: 0.4;
}

.milo-chat-attach--disabled:hover {
	color:      var(--milo-text-muted);
	background: transparent;
}

.milo-chat-textarea {
	flex:        1;
	background:  transparent;
	border:      none;
	outline:     none;
	resize:      none;
	font-family: inherit;
	font-size:   0.9375rem;
	line-height: 1.5;
	color:       var(--milo-text);
	padding:     0.25rem 0;
	max-height:  140px;
	overflow-y:  auto;
	scrollbar-width: thin;
}

.milo-chat-textarea::placeholder {
	color: var(--milo-text-muted);
}

/* ─── Mic button ───────────────────────────────────────────────────────── */
.milo-chat-mic {
	display:         flex;
	align-items:     center;
	justify-content: center;
	flex-shrink:     0;
	background:      transparent;
	border:          none;
	color:           var(--milo-text-muted);
	padding:         0.3rem;
	border-radius:   50%;
	cursor:          pointer;
	transition:      color 0.2s, background 0.2s, transform 0.1s;
}

.milo-chat-mic:hover:not(:disabled) {
	color:      var(--milo-primary);
	background: rgba(37, 99, 235, 0.1);
}

.milo-chat-mic:disabled {
	opacity: 0.4;
	cursor:  not-allowed;
}

/* Active listening state with pulsing animation */
.milo-chat-mic.is-listening {
	color:      #ef4444;
	background: rgba(239, 68, 68, 0.15);
	animation:  mic-pulse 1.5s ease-in-out infinite;
}

@keyframes mic-pulse {
	0%, 100% {
		transform:  scale(1);
		box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
	}
	50% {
		transform:  scale(1.05);
		box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
	}
}

/* ─── Send button ──────────────────────────────────────────────────────── */
.milo-chat-send {
	display:         flex;
	align-items:     center;
	justify-content: center;
	flex-shrink:     0;
	width:           36px;
	height:          36px;
	background:      var(--milo-surface-alt);
	border:          none;
	border-radius:   50%;
	color:           #fff;
	cursor:          pointer;
	padding:         0;
	transition:      background 0.15s, transform 0.1s;
	line-height:     1;
}

.milo-chat-send:hover {
	background: var(--milo-primary);
}

.milo-chat-send:active {
	transform: scale(0.93);
}

.milo-chat-send:disabled {
	opacity: 0.4;
	cursor:  not-allowed;
}

/* ─── Utility ──────────────────────────────────────────────────────────── */
.sr-only {
	position:  absolute;
	width:     1px;
	height:    1px;
	padding:   0;
	margin:    -1px;
	overflow:  hidden;
	clip:      rect(0, 0, 0, 0);
	white-space: nowrap;
	border:    0;
}

/* ─── Error message ────────────────────────────────────────────────────── */
.milo-chat-message--error .milo-chat-message__bubble {
	background: rgba(239, 68, 68, 0.15);
	color:      #fca5a5;
	border:     1px solid rgba(239, 68, 68, 0.3);
}

/* ─── Drag-over state ──────────────────────────────────────────────────── */
.milo-chat-widget--dragover .milo-chat-input-row {
	border-color: var(--milo-primary);
	box-shadow:   0 0 0 3px color-mix(in srgb, var(--milo-primary) 20%, transparent);
}

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
	.milo-chat-welcome__title {
		font-size: 1.375rem;
	}

	.milo-chat-message {
		max-width: 90%;
	}

	.milo-chat-messages,
	.milo-chat-input-wrapper,
	.milo-chat-typing,
	.milo-chat-image-preview {
		padding-left:  1rem;
		padding-right: 1rem;
	}

	.milo-chat-input-wrapper {
		padding-bottom: 1.25rem;
	}

	/* FIX 1: Sign Out button overlap – push messages below the fixed logout bar */
	.milo-chat-messages {
		padding-top: 3rem;
	}

	/* FIX 2: Reposition logout bar to fixed so it floats above content */
	.milo-chat-logout-bar {
		position:      fixed;
		top:           0.5rem;
		right:         0.75rem;
		z-index:       10;
		background:    rgba(10, 22, 40, 0.8);
		border-radius: 9999px;
		padding:       0.25rem;
	}

	/* FIX 3: Ensure user messages don't extend too far right on mobile */
	.milo-chat-message--user {
		max-width:    85%;
		margin-right: 0.5rem;
	}

	/* FIX 6: Chat widget container – use dynamic viewport height */
	.milo-chat-widget {
		min-height: 100dvh;
	}

	/* FIX 8: Chat textarea – prevent iOS zoom on focus */
	.milo-chat-textarea {
		font-size: 16px;
	}
}

/* ─── Additional small device fixes (< 400px) ─────────────────────────── */
@media (max-width: 400px) {
	.milo-chat-logout-btn {
		font-size: 0.7rem;
		padding:   0.25rem 0.5rem 0.25rem 0.4rem;
	}

	.milo-chat-logout-btn svg {
		width:  14px;
		height: 14px;
	}

	.milo-chat-message--user .milo-chat-message__bubble {
		max-width: 100%;
	}
}

/* ─── Safe area insets for notched devices (iPhone X and later) ───────── */
@supports (padding-top: env(safe-area-inset-top)) {
	.milo-chat-widget--fullscreen,
	.milo-login-widget--fullscreen {
		padding-top:    env(safe-area-inset-top);
		padding-bottom: env(safe-area-inset-bottom);
		padding-left:   env(safe-area-inset-left);
		padding-right:  env(safe-area-inset-right);
	}

	@media (max-width: 600px) {
		.milo-chat-logout-bar {
			top:   calc(0.5rem + env(safe-area-inset-top));
			right: calc(0.75rem + env(safe-area-inset-right));
		}

		.milo-chat-input-wrapper {
			padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
		}
	}
}

/* ─── Logout bar ───────────────────────────────────────────────────────── */
.milo-chat-logout-bar {
	position:    absolute;
	top:         0.75rem;
	right:       1rem;
	z-index:     2;
	display:     flex;
	gap:         0.5rem;
}

.milo-chat-logout-btn {
	display:      flex;
	align-items:  center;
	gap:          0.35rem;
	background:   transparent;
	border:       1px solid rgba(255, 255, 255, 0.15);
	border-radius: 9999px;
	color:        rgba(255, 255, 255, 0.55);
	font-family:  inherit;
	font-size:    0.75rem;
	cursor:       pointer;
	padding:      0.3rem 0.75rem 0.3rem 0.55rem;
	transition:   color 0.15s, border-color 0.15s, background 0.15s;
	line-height:  1;
}

.milo-chat-logout-btn:hover {
	color:         rgba(255, 255, 255, 0.9);
	border-color:  rgba(255, 255, 255, 0.35);
	background:    rgba(255, 255, 255, 0.07);
}

/* ─── Admin Dashboard button ───────────────────────────────────────────── */
.milo-chat-admin-btn {
	display:         flex;
	align-items:     center;
	gap:             0.35rem;
	background:      transparent;
	border:          1px solid rgba(255, 255, 255, 0.15);
	border-radius:   9999px;
	color:           rgba(255, 255, 255, 0.55);
	font-family:     inherit;
	font-size:       0.75rem;
	cursor:          pointer;
	padding:         0.3rem 0.75rem 0.3rem 0.55rem;
	transition:      color 0.15s, border-color 0.15s, background 0.15s;
	line-height:     1;
	text-decoration: none;
}

.milo-chat-admin-btn:hover {
	color:        rgba(255, 255, 255, 0.9);
	border-color: rgba(255, 255, 255, 0.35);
	background:   rgba(255, 255, 255, 0.07);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN WIDGET
   All classes are prefixed .milo-login- to avoid collisions.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Reset ────────────────────────────────────────────────────────────── */
.milo-login-widget *,
.milo-login-widget *::before,
.milo-login-widget *::after {
	box-sizing: border-box;
}

/* ─── Widget container – mirrors .milo-chat-widget ─────────────────────── */
.milo-login-widget {
	--milo-primary:     #2563eb;
	--milo-bg:          #0a1628;
	--milo-surface:     rgba(15, 35, 60, 0.85);
	--milo-surface-alt: rgba(20, 45, 75, 0.9);
	--milo-border:      rgba(59, 130, 246, 0.3);
	--milo-text:        #ffffff;
	--milo-text-muted:  #9ca3af;
	--milo-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	display:         flex;
	align-items:     center;
	justify-content: center;
	width:           100%;
	min-height:      100vh;
	background:      linear-gradient(
		180deg,
		#0a1628 0%,
		#0d2847 25%,
		#134e6f 50%,
		#1a5276 75%,
		#0d2847 100%
	);
	font-family:     var(--milo-font);
	color:           var(--milo-text);
	overflow:        hidden;
	position:        relative;
	padding:         2rem 1rem;
}

/* Ocean wave overlay – mirrors .milo-chat-widget::before */
.milo-login-widget::before {
	content:    '';
	position:   absolute;
	inset:      0;
	background:
		radial-gradient(ellipse at 50% 100%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
		radial-gradient(ellipse at 30% 80%,  rgba(6, 182, 212, 0.1)  0%, transparent 40%),
		radial-gradient(ellipse at 70% 60%,  rgba(59, 130, 246, 0.08) 0%, transparent 35%);
	pointer-events: none;
	z-index:    0;
}

.milo-login-widget > * {
	position: relative;
	z-index:  1;
}

/* ─── Fullscreen variant ───────────────────────────────────────────────── */
.milo-login-widget--fullscreen {
	position: fixed;
	inset:    0;
	z-index:  99999;
}

/* ─── Card wrapper ─────────────────────────────────────────────────────── */
.milo-login-form-wrapper {
	width:         100%;
	max-width:     420px;
	background:    var(--milo-surface);
	border:        1.5px solid var(--milo-border);
	border-radius: 1.5rem;
	padding:       2.5rem 2rem 2rem;
	display:       flex;
	flex-direction: column;
	align-items:   center;
	gap:           1.5rem;
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
}

/* ─── Avatar – mirrors .milo-chat-welcome__avatar ───────────────────────── */
.milo-login-avatar-wrap {
	display: flex;
	justify-content: center;
}

.milo-login-avatar {
	width:         80px;
	height:        80px;
	border-radius: 50%;
	object-fit:    cover;
	display:       block;
	box-shadow:    0 0 20px rgba(59, 130, 246, 0.5),
	               0 0 40px rgba(6, 182, 212, 0.3);
	border:        2px solid rgba(255, 255, 255, 0.2);
}

/* ─── Title – mirrors .milo-chat-welcome__title ─────────────────────────── */
.milo-login-title {
	margin:      0;
	font-size:   clamp(1.25rem, 3.5vw, 1.75rem);
	font-weight: 600;
	line-height: 1.3;
	color:       var(--milo-text);
	text-align:  center;
}

/* ─── Error message – mirrors .milo-chat-message--error ─────────────────── */
.milo-login-error {
	width:         100%;
	padding:       0.65rem 1rem;
	border-radius: 0.75rem;
	background:    rgba(239, 68, 68, 0.15);
	color:         #fca5a5;
	border:        1px solid rgba(239, 68, 68, 0.3);
	font-size:     0.875rem;
	line-height:   1.5;
	text-align:    center;
}

.milo-login-error[hidden] {
	display: none;
}

/* ─── Form ─────────────────────────────────────────────────────────────── */
.milo-login-form {
	width:          100%;
	display:        flex;
	flex-direction: column;
	gap:            0.85rem;
}

.milo-login-field {
	width: 100%;
}

/* ─── Input row – mirrors .milo-chat-input-row ──────────────────────────── */
.milo-login-input-row {
	display:       flex;
	align-items:   center;
	gap:           0.5rem;
	background:    var(--milo-surface-alt);
	border:        1.5px solid var(--milo-border);
	border-radius: 9999px;
	padding:       0.6rem 1.25rem;
	transition:    border-color 0.2s, box-shadow 0.2s;
}

.milo-login-input-row:focus-within {
	border-color: var(--milo-primary);
	box-shadow:   0 0 0 3px color-mix(in srgb, var(--milo-primary) 20%, transparent);
}

.milo-login-input-icon {
	flex-shrink: 0;
	color:       var(--milo-text-muted);
}

.milo-login-input {
	flex:        1;
	background:  transparent;
	border:      none;
	outline:     none;
	font-family: inherit;
	font-size:   0.9375rem;
	line-height: 1.5;
	color:       var(--milo-text);
	padding:     0;
	min-width:   0;
}

.milo-login-input::placeholder {
	color: var(--milo-text-muted);
}

/* ─── Remember Me ──────────────────────────────────────────────────────── */
.milo-login-remember {
	display:     flex;
	align-items: center;
	padding:     0 0.25rem;
}

.milo-login-remember__label {
	display:     flex;
	align-items: center;
	gap:         0.6rem;
	cursor:      pointer;
	font-size:   0.875rem;
	color:       var(--milo-text-muted);
	user-select: none;
}

/* Custom toggle track */
.milo-login-remember__toggle {
	position:      relative;
	display:       inline-block;
	width:         36px;
	height:        20px;
	background:    rgba(255, 255, 255, 0.15);
	border-radius: 9999px;
	border:        1.5px solid var(--milo-border);
	flex-shrink:   0;
	transition:    background 0.2s, border-color 0.2s;
}

/* Toggle thumb */
.milo-login-remember__toggle::after {
	content:       '';
	position:      absolute;
	top:           2px;
	left:          2px;
	width:         12px;
	height:        12px;
	border-radius: 50%;
	background:    var(--milo-text-muted);
	transition:    transform 0.2s, background 0.2s;
}

.milo-login-remember__checkbox:checked + .milo-login-remember__toggle {
	background:   var(--milo-primary);
	border-color: var(--milo-primary);
}

.milo-login-remember__checkbox:checked + .milo-login-remember__toggle::after {
	transform:  translateX(16px);
	background: #ffffff;
}

.milo-login-remember__checkbox:focus-visible + .milo-login-remember__toggle {
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--milo-primary) 30%, transparent);
}

/* ─── Submit button – mirrors .milo-chat-send ───────────────────────────── */
.milo-login-submit {
	display:         flex;
	align-items:     center;
	justify-content: center;
	gap:             0.5rem;
	width:           100%;
	padding:         0.75rem 1.5rem;
	background:      var(--milo-primary);
	border:          none;
	border-radius:   9999px;
	color:           #ffffff;
	font-family:     inherit;
	font-size:       1rem;
	font-weight:     600;
	cursor:          pointer;
	transition:      background 0.15s, transform 0.1s, box-shadow 0.15s;
	margin-top:      0.25rem;
	line-height:     1;
}

.milo-login-submit:hover:not(:disabled) {
	background:  color-mix(in srgb, var(--milo-primary) 80%, #000);
	box-shadow:  0 4px 14px color-mix(in srgb, var(--milo-primary) 40%, transparent);
}

.milo-login-submit:active {
	transform: scale(0.97);
}

.milo-login-submit:disabled {
	opacity: 0.6;
	cursor:  not-allowed;
}

/* Spinner inside submit button */
.milo-login-submit__spinner {
	animation: milo-spin 0.8s linear infinite;
	display:   flex;
	align-items: center;
}

.milo-login-submit__spinner[hidden] {
	display: none;
}

@keyframes milo-spin {
	from { transform: rotate(0deg); }
	to   { transform: rotate(360deg); }
}

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
	/* FIX 4: Login form wrapper – prevent overflow and add safe margins */
	.milo-login-form-wrapper {
		padding:       1.5rem 1rem 1.25rem;
		border-radius: 1.25rem;
		margin:        0 0.5rem;
		max-width:     calc(100% - 1rem);
	}

	.milo-login-title {
		font-size: 1.25rem;
	}

	/* FIX 5: Login widget – ensure proper centering and prevent overflow */
	.milo-login-widget {
		padding:    1rem 0.5rem;
		min-height: 100dvh;
	}

	/* FIX 7: Input fields on login – prevent text overflow */
	.milo-login-input-row {
		padding: 0.5rem 1rem;
	}

	/* FIX 8: Prevent iOS zoom on focus */
	.milo-login-input {
		font-size: 16px;
	}
}

/* ─── Additional small device fixes (< 400px) ─────────────────────────── */
@media (max-width: 400px) {
	.milo-login-form-wrapper {
		padding: 1.25rem 0.875rem 1rem;
	}
}
