/* ============================================================================
   theia-popup.css — canonical Theia in-screen popup styles
   ----------------------------------------------------------------------------
   Loaded globally by the SvelteKit shell so any page can call
   `theiaPopup.{prompt|confirm|choose|form}` without inlining CSS. Replaces
   every native window.alert / confirm / prompt call across the platform.

   All variants share the same backdrop + card chrome; differences live in
   .tp-body where each variant injects its own structure.

   See src/lib/popup.ts for the API surface.
   ============================================================================ */

/* Backdrop: semi-transparent dim. Animation kept short so the popup feels
   responsive — long fades make every interaction feel sluggish. */
.tp-backdrop {
	position: fixed;
	inset: 0;
	z-index: 9000;
	background: rgba(15, 23, 42, 0.42);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	animation: tp-fade 0.12s ease-out;
}
@keyframes tp-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* Card: white surface, 8px corners, layered shadow. NEVER a full pill
   shape — platform §1 rule. */
.tp-card {
	background: var(--bg, #ffffff);
	border-radius: 8px;
	box-shadow: 0 10px 32px rgba(15, 23, 42, 0.18),
		0 2px 6px rgba(15, 23, 42, 0.08);
	width: 100%;
	max-width: 440px;
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 48px);
	animation: tp-rise 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tp-rise {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Header. Severity tint paints the header background; the body / footer
   stay white for legibility. */
.tp-head {
	padding: 18px 22px 6px;
	border-radius: 8px 8px 0 0;
}
.tp-head.sev-danger  { background: var(--red-lt, rgba(185, 28, 28, 0.07)); }
.tp-head.sev-warning { background: var(--yellow-lt, rgba(146, 64, 14, 0.08)); }
.tp-title {
	font-family: 'IBM Plex Sans', sans-serif;
	font-size: 14px;
	font-weight: 500;
	color: var(--text, #0f172a);
	letter-spacing: -0.005em;
}
.tp-head.sev-danger .tp-title  { color: var(--red, #b91c1c); }
.tp-head.sev-warning .tp-title { color: var(--yellow, #92400e); }
.tp-msg {
	font-size: 12px;
	color: var(--text2, #334155);
	line-height: 1.55;
	margin-top: 6px;
	/* Explicit \n in the message string renders as a line break.
	   Without this, the browser collapses all whitespace and a
	   bulleted list passed as `• A\n• B` reads as one wrapped run. */
	white-space: pre-line;
}

/* Body. Scrollable when content is taller than the card max-height. */
.tp-body {
	padding: 14px 22px 6px;
	overflow-y: auto;
	flex: 1 1 auto;
}

/* Inputs. Orange-on-focus, no native glow. The 3px outer ring uses
   var(--orange-lt) so it reads as part of the brand, not as a system
   default. */
.tp-input,
.tp-textarea,
.tp-select {
	width: 100%;
	font-family: 'IBM Plex Sans', sans-serif;
	font-size: 13px;
	color: var(--text, #0f172a);
	background: var(--bg, #ffffff);
	border: 1px solid var(--border2, #cbd5e1);
	border-radius: 5px;
	padding: 9px 11px;
	outline: none;
	transition: border-color 0.12s, box-shadow 0.12s;
}
.tp-input:focus,
.tp-textarea:focus,
.tp-select:focus {
	border-color: var(--orange, #d95f02);
	box-shadow: 0 0 0 3px var(--orange-lt, rgba(217, 95, 2, 0.10));
}
.tp-input::placeholder,
.tp-textarea::placeholder {
	color: var(--text4, #94a3b8);
}
.tp-textarea {
	min-height: 72px;
	resize: vertical;
	font-family: inherit;
}
.tp-select {
	appearance: none;
	background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%2364748b' stroke-width='1.5'%3e%3cpath d='M2 4l3 3 3-3'/%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: right 10px center;
	padding-right: 30px;
}

/* Form field wrapper */
.tp-field {
	margin-bottom: 12px;
}
.tp-field-label {
	display: block;
	font-family: 'IBM Plex Mono', monospace;
	font-size: 10px;
	font-weight: 500;
	color: var(--text3, #64748b);
	letter-spacing: 0.06em;
	text-transform: uppercase;
	margin-bottom: 5px;
}
.tp-field-label .req {
	color: var(--red, #b91c1c);
	margin-left: 3px;
}

/* Choice list for the `choose` variant. Each row reads as a button. */
.tp-choices {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin: 4px 0;
}
.tp-choice {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	background: var(--bg, #ffffff);
	border: 1px solid var(--border, #e2e8f0);
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.1s;
	text-align: left;
	font-family: inherit;
}
.tp-choice:hover {
	background: var(--orange-lt, rgba(217, 95, 2, 0.10));
	border-color: var(--orange-bd, rgba(217, 95, 2, 0.28));
}
.tp-choice:focus-visible {
	outline: none;
	background: var(--orange-lt, rgba(217, 95, 2, 0.10));
	border-color: var(--orange, #d95f02);
	box-shadow: 0 0 0 3px var(--orange-lt, rgba(217, 95, 2, 0.10));
}
.tp-choice-main {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.tp-choice-label {
	font-size: 13px;
	font-weight: 500;
	color: var(--text, #0f172a);
}
.tp-choice-hint {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 10px;
	color: var(--text3, #64748b);
	letter-spacing: 0.04em;
}
.tp-choice-arrow {
	width: 14px;
	height: 14px;
	color: var(--text4, #94a3b8);
	flex-shrink: 0;
}
.tp-choice:hover .tp-choice-arrow {
	color: var(--orange, #d95f02);
}

/* Footer / button row. Right-aligned; primary on the far right matches
   platform §5 button order. */
.tp-foot {
	padding: 12px 22px 18px;
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	align-items: center;
}
.tp-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 7px 14px;
	font-family: 'IBM Plex Sans', sans-serif;
	font-size: 12px;
	font-weight: 500;
	border-radius: 5px;
	border: 1px solid var(--border2, #cbd5e1);
	background: var(--bg, #ffffff);
	color: var(--text, #0f172a);
	cursor: pointer;
	transition: all 0.12s;
	white-space: nowrap;
}
.tp-btn:hover {
	background: var(--bg3, #f1f3f6);
	border-color: var(--text4, #94a3b8);
}
.tp-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--orange-lt, rgba(217, 95, 2, 0.10));
	border-color: var(--orange, #d95f02);
}

/* Primary: brand orange */
.tp-btn.primary {
	background: var(--orange, #d95f02);
	color: #ffffff;
	border-color: var(--orange, #d95f02);
}
.tp-btn.primary:hover {
	background: #b54f02;
	border-color: #b54f02;
}

/* Danger: red filled (severity:'danger') */
.tp-btn.danger {
	background: var(--red, #b91c1c);
	color: #ffffff;
	border-color: var(--red, #b91c1c);
}
.tp-btn.danger:hover {
	background: #991717;
	border-color: #991717;
}

.tp-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.tp-btn:disabled:hover {
	background: var(--bg, #ffffff);
	border-color: var(--border2, #cbd5e1);
}
.tp-btn.primary:disabled,
.tp-btn.danger:disabled {
	background: var(--text4, #94a3b8);
	border-color: var(--text4, #94a3b8);
}

/* Inline error under inputs */
.tp-err {
	font-size: 11px;
	color: var(--red, #b91c1c);
	margin-top: 4px;
	min-height: 14px;
}
