/*
 * Trial Setup Stream — live strategy narration UI
 *
 * Renders in place of the calendar grid while automated setup runs.
 * Part of FEAT-ChatDrivenSetup.
 */

.saiap-setup-stream-root {
	margin: 16px 0;
}

.saiap-setup-stream {
	display: flex;
	flex-direction: column;
	background: var(--saiap-color-surface, #ffffff);
	border: 1px solid var(--saiap-color-border, #e5e7eb);
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
	max-width: 900px;
}

/* Header ------------------------------------------------------------- */

.saiap-setup-stream__header {
	padding: 20px 24px;
	border-bottom: 1px solid var(--saiap-color-border-subtle, #f3f4f6);
	background: linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
}

.saiap-setup-stream__header-title {
	font-size: 18px;
	font-weight: 600;
	color: var(--saiap-color-text, #111827);
	margin-bottom: 4px;
}

.saiap-setup-stream__header-sub {
	font-size: 13px;
	color: var(--saiap-color-text-muted, #6b7280);
}

/* History (scrollable) ----------------------------------------------- */

.saiap-setup-stream__history {
	max-height: min(60vh, 520px);
	overflow-y: auto;
	padding: 20px 24px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.saiap-setup-stream__empty {
	color: var(--saiap-color-text-muted, #6b7280);
	font-style: italic;
	padding: 16px 0;
	text-align: center;
}

/* Turn markers ------------------------------------------------------- */

.saiap-setup-stream__turn-marker {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 0;
	margin-top: 8px;
	color: var(--saiap-color-text-muted, #6b7280);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	border-top: 1px dashed var(--saiap-color-border-subtle, #f3f4f6);
	padding-top: 14px;
}

.saiap-setup-stream__turn-marker:first-child {
	border-top: none;
	padding-top: 0;
	margin-top: 0;
}

.saiap-setup-stream__turn-number {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--saiap-color-primary-muted, #eef2ff);
	color: var(--saiap-color-primary, #4f46e5);
	font-size: 11px;
	font-weight: 700;
}

/* Assistant text ------------------------------------------------------ */

.saiap-setup-stream__text {
	color: var(--saiap-color-text, #1f2937);
	font-size: 14px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Tool cards --------------------------------------------------------- */

.saiap-setup-stream__tool {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	border: 1px solid var(--saiap-color-border-subtle, #f3f4f6);
	border-radius: 8px;
	background: #fafbfc;
	cursor: pointer;
	transition: border-color 120ms ease, background 120ms ease;
	position: relative;
	flex-wrap: wrap;
}

.saiap-setup-stream__tool:hover {
	border-color: var(--saiap-color-border, #d1d5db);
}

.saiap-setup-stream__tool--running {
	background: #f5f7ff;
	border-color: #c7d2fe;
}

.saiap-setup-stream__tool--complete {
	opacity: 0.85;
}

.saiap-setup-stream__tool-icon {
	font-size: 16px;
	line-height: 1;
}

.saiap-setup-stream__tool-label {
	flex: 1;
	font-size: 13px;
	color: var(--saiap-color-text, #111827);
	font-weight: 500;
}

.saiap-setup-stream__tool-status {
	color: var(--saiap-color-primary, #4f46e5);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
}

.saiap-setup-stream__tool--complete .saiap-setup-stream__tool-status {
	color: #10b981;
}

.saiap-setup-stream__spinner {
	width: 12px;
	height: 12px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: saiap-setup-stream-spin 0.8s linear infinite;
}

@keyframes saiap-setup-stream-spin {
	to { transform: rotate(360deg); }
}

.saiap-setup-stream__tool-details {
	width: 100%;
	margin-top: 8px;
	padding: 10px;
	background: #0f172a;
	color: #e5e7eb;
	border-radius: 6px;
	font-size: 11px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	max-height: 200px;
	overflow: auto;
}

.saiap-setup-stream__tool-details pre {
	margin: 0;
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Questions + answers in history ------------------------------------ */

.saiap-setup-stream__question-marker {
	padding: 12px 14px;
	background: #fef3c7;
	border-left: 3px solid #f59e0b;
	border-radius: 6px;
	margin: 4px 0;
}

.saiap-setup-stream__question-text {
	font-weight: 600;
	color: #78350f;
	font-size: 14px;
}

.saiap-setup-stream__question-context {
	margin-top: 6px;
	color: #92400e;
	font-size: 13px;
	line-height: 1.5;
}

.saiap-setup-stream__answer-marker {
	padding: 8px 14px;
	background: #ecfdf5;
	border-left: 3px solid #10b981;
	border-radius: 6px;
	font-size: 13px;
}

.saiap-setup-stream__answer-label {
	font-weight: 600;
	color: #065f46;
	margin-right: 6px;
}

.saiap-setup-stream__answer-text {
	color: #047857;
}

/* Current state (pinned at bottom) ----------------------------------- */

.saiap-setup-stream__current {
	padding: 16px 24px;
	border-top: 1px solid var(--saiap-color-border-subtle, #f3f4f6);
	background: #fafbff;
	min-height: 48px;
	display: flex;
	align-items: center;
}

.saiap-setup-stream__current-text {
	color: var(--saiap-color-text, #111827);
	font-size: 14px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.saiap-setup-stream__current-status {
	color: var(--saiap-color-text-muted, #6b7280);
	font-style: italic;
	font-size: 13px;
}

.saiap-setup-stream__conn {
	color: var(--saiap-color-text-muted, #6b7280);
	font-size: 12px;
	font-style: italic;
}

/* Error banner ------------------------------------------------------- */

.saiap-setup-stream__error-banner {
	padding: 12px 14px;
	background: #fef2f2;
	border-left: 3px solid #ef4444;
	border-radius: 6px;
	color: #991b1b;
	font-size: 13px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* Confirmation card ------------------------------------------------- */

.saiap-setup-stream__confirmation {
	margin: 16px 24px 20px;
	padding: 20px;
	background: linear-gradient(180deg, #ffffff 0%, #fefce8 100%);
	border: 2px solid #fde68a;
	border-radius: 12px;
}

.saiap-setup-stream__confirmation-q {
	font-size: 16px;
	font-weight: 600;
	color: #111827;
	margin-bottom: 8px;
}

.saiap-setup-stream__confirmation-ctx {
	color: #374151;
	font-size: 14px;
	line-height: 1.6;
	margin-bottom: 16px;
	white-space: pre-wrap;
}

.saiap-setup-stream__confirmation-options {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.saiap-setup-stream__confirmation-option {
	padding: 10px 16px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background: #ffffff;
	color: #111827;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 120ms ease;
}

.saiap-setup-stream__confirmation-option:hover:not(:disabled) {
	background: #4f46e5;
	color: #ffffff;
	border-color: #4f46e5;
}

.saiap-setup-stream__confirmation-option:first-child {
	background: #4f46e5;
	color: #ffffff;
	border-color: #4f46e5;
}

.saiap-setup-stream__confirmation-option:first-child:hover:not(:disabled) {
	background: #4338ca;
	border-color: #4338ca;
}

.saiap-setup-stream__confirmation-option:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.saiap-setup-stream__confirmation-freetext {
	display: flex;
	gap: 8px;
	align-items: flex-start;
}

.saiap-setup-stream__confirmation-freetext textarea {
	flex: 1;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 13px;
	font-family: inherit;
	resize: vertical;
	min-height: 40px;
}

.saiap-setup-stream__confirmation-send {
	padding: 8px 14px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #ffffff;
	color: #111827;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
}

.saiap-setup-stream__confirmation-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.saiap-setup-stream__confirmation-error {
	margin-top: 8px;
	color: #b91c1c;
	font-size: 12px;
}

.saiap-setup-stream__confirmation--answered {
	border-color: #a7f3d0;
	background: linear-gradient(180deg, #ffffff 0%, #ecfdf5 100%);
}

.saiap-setup-stream__confirmation-a {
	color: #065f46;
	font-size: 14px;
	font-weight: 500;
}

.saiap-setup-stream__confirmation-done {
	margin: 16px 24px 20px;
	padding: 14px 16px;
	background: #ecfdf5;
	border: 1px solid #a7f3d0;
	border-radius: 8px;
	color: #065f46;
	font-size: 14px;
	font-weight: 500;
	text-align: center;
}
