/* ==========================================================================
   Agent Builder — Setup Wizard Styles
   Full-page custom template: admin.php?page=agentic-setup
   ========================================================================== */

* { box-sizing: border-box; }

body {
	background: #f0f0f1;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	margin: 0;
	padding: 0;
}

.setup-wrap {
	max-width: 860px;
	margin: 48px auto 80px;
	padding: 0 20px;
}

.setup-header {
	text-align: center;
	margin-bottom: 36px;
}

.setup-header h1 {
	font-size: 26px;
	font-weight: 700;
	color: #1e1e1e;
	margin: 0 0 8px;
}

.setup-header p {
	font-size: 15px;
	color: #50575e;
	margin: 0;
}

.setup-logo {
	width: 48px;
	height: 48px;
	margin: 0 auto 16px;
	display: block;
}

/* ── Step indicators ─────────────────────────── */
.setup-steps {
	display: flex;
	justify-content: center;
	gap: 0;
	margin-bottom: 36px;
}

.setup-step-item {
	display: flex;
	align-items: center;
	font-size: 13px;
	color: #8c8f94;
}

.setup-step-item .step-num {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: #ddd;
	color: #50575e;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	font-size: 13px;
	margin-right: 6px;
	flex-shrink: 0;
}

.setup-step-item.active .step-num {
	background: #2271b1;
	color: #fff;
}

.setup-step-item.done .step-num {
	background: #00a32a;
	color: #fff;
}

.setup-step-item .step-label {
	white-space: nowrap;
}

.step-connector {
	width: 40px;
	height: 2px;
	background: #ddd;
	margin: 0 8px;
	flex-shrink: 0;
}

/* ── Card ────────────────────────────────────── */
.setup-card {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 8px;
	overflow: hidden;
}

.setup-card-inner {
	padding: 32px 36px;
}

/* ── Phase 1: Account question ───────────────── */
.account-question h2 {
	font-size: 18px;
	font-weight: 600;
	color: #1e1e1e;
	margin: 0 0 6px;
}

.account-question p {
	color: #50575e;
	margin: 0 0 28px;
	font-size: 14px;
}

.account-buttons {
	display: flex;
	gap: 16px;
}

.provider-list {
	margin: 0 0 20px 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.provider-list li {
	background: #f0f0f1;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 4px 10px;
	font-size: 13px;
	color: #3c434a;
}

.provider-list-badge {
	background: #d1e7dd;
	color: #0a3622;
	font-size: 11px;
	font-weight: 600;
	border-radius: 3px;
	padding: 1px 5px;
	margin-left: 4px;
}

.btn-account {
	flex: 1;
	padding: 16px 20px;
	border: 2px solid #c3c4c7;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	color: #1e1e1e;
	transition: border-color 0.15s, background 0.15s;
}

.btn-account:hover {
	border-color: #2271b1;
	background: #f0f6fc;
}

.btn-account .btn-icon {
	font-size: 28px;
	display: block;
	margin-bottom: 6px;
}

/* ── Phase 2: Provider grid ──────────────────── */
.provider-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 14px;
}

@media (max-width: 600px) {
	.provider-grid { grid-template-columns: repeat(2, 1fr); }
}

.provider-card {
	border: 2px solid #c3c4c7;
	border-radius: 8px;
	padding: 18px 14px 14px;
	cursor: pointer;
	text-align: center;
	transition: border-color 0.15s, box-shadow 0.15s;
	background: #fff;
	position: relative;
}

.provider-card:hover {
	border-color: #2271b1;
	box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.provider-card.selected {
	border-color: #2271b1;
	background: #f0f6fc;
}

.provider-card .provider-name {
	font-size: 14px;
	font-weight: 600;
	color: #1e1e1e;
	margin-top: 8px;
}

.provider-card .provider-icon {
	width: 40px;
	height: 40px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
}

.provider-card .provider-icon svg,
.provider-card .provider-icon img {
	width: 36px;
	height: 36px;
}

.badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	padding: 2px 7px;
	border-radius: 20px;
	margin-top: 6px;
}

.badge-free {
	background: #e6f4ea;
	color: #1a7431;
}

.badge-paid {
	background: #fff3cd;
	color: #856404;
}

/* ── Phase 3: Setup steps ────────────────────── */
.provider-steps-section {
	display: none;
}

.provider-steps-section.active {
	display: block;
}

.provider-steps-header {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 24px;
}

.provider-steps-header h2 {
	font-size: 17px;
	font-weight: 600;
	margin: 0;
	color: #1e1e1e;
}

.btn-back {
	background: none;
	border: none;
	color: #2271b1;
	cursor: pointer;
	font-size: 13px;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 4px;
}

.btn-back:hover { text-decoration: underline; }

.step-list {
	list-style: none;
	padding: 0;
	margin: 0 0 24px;
}

.step-list li {
	display: flex;
	gap: 14px;
	margin-bottom: 20px;
	align-items: flex-start;
}

.step-list .step-n {
	width: 26px;
	height: 26px;
	background: #2271b1;
	color: #fff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
	flex-shrink: 0;
	margin-top: 1px;
}

.step-list .step-body {
	flex: 1;
}

.step-list .step-body p {
	margin: 0 0 10px;
	font-size: 14px;
	line-height: 1.6;
	color: #1e1e1e;
}

.step-list .step-body a {
	color: #2271b1;
}

.screenshot-wrap {
	display: inline-block;
	position: relative;
	margin-top: 8px;
	max-width: 100%;
	cursor: zoom-in;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	overflow: hidden;
	transition: box-shadow 0.15s;
}

.screenshot-wrap:hover {
	box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.screenshot-wrap:hover .screenshot-zoom-icon {
	opacity: 1;
}

.screenshot-zoom-icon {
	position: absolute;
	bottom: 8px;
	right: 8px;
	width: 30px;
	height: 30px;
	background: rgba(0,0,0,0.55);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.15s;
	pointer-events: none;
}

.screenshot-zoom-icon svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: #fff;
	stroke-width: 2;
	stroke-linecap: round;
}

.step-screenshot {
	display: block;
	max-width: 100%;
	max-height: 200px;
	object-fit: cover;
	object-position: top;
}

.credit-note {
	font-size: 12px;
	color: #50575e;
	margin: 12px 0 0;
	padding: 10px 14px;
	background: #fff8e1;
	border-left: 3px solid #f0b429;
	border-radius: 3px;
}

.get-key-section {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-top: 20px;
	padding: 16px;
	background: #f6f7f7;
	border-radius: 6px;
}

.get-key-section .btn-primary {
	flex-shrink: 0;
}

.get-key-note {
	font-size: 12px;
	color: #50575e;
	margin: 0;
	line-height: 1.5;
}

.key-section {
	border-top: 1px solid #f0f0f1;
	padding-top: 24px;
}

.key-section label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 8px;
	color: #1e1e1e;
}

.key-section .key-hint {
	font-size: 12px;
	color: #50575e;
	margin-bottom: 10px;
}

.key-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 20px;
}

.key-input-row input[type="password"] {
	min-width: 0;
}

.key-input-row .btn-save,
.key-input-row .btn-test-inline {
	flex-shrink: 0;
	white-space: nowrap;
}

.key-input-row input[type="password"],
.key-input-row input[type="text"] {
	flex: 1;
	padding: 9px 12px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	font-size: 14px;
	font-family: monospace;
}

.key-input-row input:focus {
	border-color: #2271b1;
	outline: 2px solid rgba(34,113,177,0.2);
}

.ollama-url-row {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ollama-url-row input {
	padding: 9px 12px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	font-size: 14px;
	font-family: monospace;
	width: 100%;
}

.test-status {
	display: none;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	margin-top: 10px;
	padding: 10px 14px;
	border-radius: 6px;
}

.test-status.testing {
	display: flex;
	background: #f0f6fc;
	color: #2271b1;
}

.test-status.success {
	display: flex;
	background: #e6f4ea;
	color: #1a7431;
}

.test-status.error {
	display: flex;
	background: #fff4f4;
	color: #d63638;
}

/* ── Footer ──────────────────────────────────── */
.setup-card-footer {
	padding: 18px 36px;
	background: #f6f7f7;
	border-top: 1px solid #c3c4c7;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.footer-right {
	display: flex;
	gap: 10px;
	align-items: center;
}

.btn-primary {
	background: #2271b1;
	color: #fff;
	border: none;
	border-radius: 4px;
	padding: 10px 22px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s;
}

.btn-primary:hover { background: #135e96; }
.btn-primary:disabled { background: #a5c4e0; cursor: not-allowed; }

.btn-secondary {
	background: #fff;
	color: #2271b1;
	border: 1px solid #2271b1;
	border-radius: 4px;
	padding: 10px 22px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.btn-secondary:hover { background: #f0f6fc; }

.btn-skip {
	color: #8c8f94;
	font-size: 13px;
	text-decoration: none;
}

.btn-skip:hover { color: #50575e; text-decoration: underline; }

/* ── Phase 4: Done ───────────────────────────── */
.done-section {
	text-align: center;
	padding: 20px 0;
}

.done-section .done-icon {
	font-size: 52px;
	margin-bottom: 16px;
}

.done-section h2 {
	font-size: 22px;
	font-weight: 700;
	color: #1e1e1e;
	margin: 0 0 8px;
}

.done-section p {
	color: #50575e;
	font-size: 15px;
	margin: 0 0 28px;
}

.btn-large {
	display: inline-block;
	background: #2271b1;
	color: #fff;
	border-radius: 6px;
	padding: 13px 32px;
	font-size: 16px;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s;
}

.btn-large:hover { background: #135e96; color: #fff; }

/* ── Lightbox ────────────────────────────────── */
.lightbox {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.8);
	z-index: 99999;
	align-items: center;
	justify-content: center;
	cursor: zoom-out;
}

.lightbox.open { display: flex; }

.lightbox img {
	max-width: 90vw;
	max-height: 90vh;
	border-radius: 6px;
	box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

code {
	background: #f6f7f7;
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 13px;
}

/* ── Provider info panel ─────────────────────── */
.provider-info-panel {
	display: none;
	margin-top: 18px;
	border: 1px solid #2271b1;
	border-radius: 8px;
	background: #f8fbff;
	overflow: hidden;
}

.provider-info-panel.visible {
	display: block;
	animation: pipFadeIn 0.18s ease;
}

@keyframes pipFadeIn {
	from { opacity: 0; transform: translateY(-6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.pip-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px 12px;
	border-bottom: 1px solid #dce3eb;
	background: #fff;
}

.pip-header h3 {
	font-size: 14px;
	font-weight: 700;
	color: #1e1e1e;
	margin: 0 0 3px;
}

.pip-header p {
	font-size: 12px;
	color: #50575e;
	margin: 0;
}

.pip-stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	border-bottom: 1px solid #dce3eb;
}

.pip-stat {
	padding: 10px 20px;
	border-right: 1px solid #dce3eb;
}

.pip-stat:last-child { border-right: none; }

.pip-stat-label {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #8c8f94;
	margin-bottom: 4px;
}

.pip-stat-value {
	font-size: 12px;
	color: #1e1e1e;
	font-weight: 500;
	line-height: 1.45;
}

.pip-models {
	padding: 10px 20px 14px;
}

.pip-models-label {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #8c8f94;
	margin-bottom: 8px;
}

.pip-model-list {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
}

.pip-model-chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 20px;
	font-size: 12px;
	color: #1e1e1e;
}

.pip-model-chip.recommended {
	border-color: #2271b1;
	background: #e8f0fa;
	font-weight: 600;
}

.pip-tag {
	font-size: 10px;
	color: #50575e;
	background: #f0f0f1;
	padding: 1px 5px;
	border-radius: 10px;
}

.pip-model-chip.recommended .pip-tag {
	background: #c7dbf5;
	color: #1a4a7e;
}

/* ── Phase 4: Test ───────────────────────────── */
.wizard-test-section {
	text-align: center;
	padding: 12px 0 28px;
	border-bottom: 1px solid #f0f0f1;
}

.wizard-test-section h2 {
	font-size: 18px;
	font-weight: 600;
	margin: 0 0 8px;
	color: #1e1e1e;
}

.wizard-test-section p {
	color: #50575e;
	font-size: 14px;
	margin: 0 0 20px;
}

#test-status-wizard {
	justify-content: center;
}

.wizard-congrats-banner {
	text-align: center;
	padding: 36px 24px 32px;
	background: linear-gradient(135deg, #f0f6fc 0%, #e8f5e9 100%);
	border-top: 1px solid #c3c4c7;
	border-bottom: 1px solid #c3c4c7;
	margin: 0 -36px;
}

.wizard-congrats-icon {
	font-size: 56px;
	line-height: 1;
	margin-bottom: 14px;
}

.wizard-congrats-banner h2 {
	font-size: 23px;
	font-weight: 700;
	color: #1e1e1e;
	margin: 0 0 10px;
}

.wizard-congrats-banner p {
	color: #3c434a;
	font-size: 16px;
	margin: 0;
}

.wizard-chatbox {
	border-radius: 14px;
	overflow: hidden;
	margin: 28px 0 0;
	background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
	box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.wizard-chat-titlebar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	background: rgba(0,0,0,0.3);
	border-bottom: 1px solid rgba(255,255,255,0.08);
}

.wizard-win-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
}
.wizard-win-dot--red    { background: #ff5f56; }
.wizard-win-dot--yellow { background: #ffbd2e; }
.wizard-win-dot--green  { background: #27c93f; }

.wizard-chat-title-text {
	flex: 1;
	text-align: center;
	color: rgba(255,255,255,0.4);
	font-size: 12px;
}

.wizard-chat-messages {
	height: 430px;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: transparent;
}

.wizard-chat-msg {
	display: flex;
	gap: 10px;
	max-width: 88%;
}

.wizard-chat-msg--user {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.wizard-chat-msg--agent {
	align-self: flex-start;
}

.wizard-chat-bubble {
	padding: 11px 15px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.65;
	white-space: pre-wrap;
	word-break: break-word;
}

.wizard-chat-msg--user .wizard-chat-bubble {
	background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
	color: #fff;
}

.wizard-chat-msg--agent .wizard-chat-bubble {
	background: rgba(255,255,255,0.07);
	color: rgba(255,255,255,0.92);
	border: 1px solid rgba(255,255,255,0.1);
}

.wizard-chat-msg--thinking .wizard-chat-bubble {
	color: rgba(255,255,255,0.4);
	font-style: italic;
}

.wizard-suggested-prompts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 18px 14px;
}

.wizard-suggested-prompts button {
	background: rgba(168,85,247,0.15);
	border: 1px solid rgba(168,85,247,0.32);
	color: rgba(255,255,255,0.85);
	padding: 7px 14px;
	border-radius: 20px;
	font-size: 12.5px;
	cursor: pointer;
	transition: all 0.18s;
	box-shadow: none;
}

.wizard-suggested-prompts button:hover {
	background: rgba(168,85,247,0.28);
	border-color: rgba(168,85,247,0.55);
	transform: translateY(-1px);
}

.wizard-chat-input-wrap {
	display: flex;
	border-top: 1px solid rgba(255,255,255,0.08);
	background: rgba(0,0,0,0.25);
}

.wizard-chat-input-wrap input {
	flex: 1;
	padding: 13px 16px;
	border: none;
	font-size: 14px;
	outline: none;
	background: transparent;
	color: #fff;
}

.wizard-chat-input-wrap input::placeholder {
	color: rgba(255,255,255,0.35);
}

.wizard-chat-input-wrap .btn-primary {
	border-radius: 0;
	padding: 13px 22px;
	border: none;
}

.wizard-mic-btn {
	background: none;
	border: none;
	padding: 0 10px;
	color: rgba(255,255,255,0.45);
	cursor: pointer;
	display: flex;
	align-items: center;
	transition: color 0.2s;
	flex-shrink: 0;
}

.wizard-mic-btn:hover { color: rgba(255,255,255,0.85); }

.wizard-mic-btn.wizard-mic-active {
	color: #d63638;
	animation: wizardMicPulse 1.5s ease-in-out infinite;
}

@keyframes wizardMicPulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.4; }
}

.wizard-exit-row {
	text-align: center;
	margin-top: 28px;
}

/* ── Model + Mode pickers ── */
.wizard-pref-section {
	margin: 0 0 32px;
	padding: 24px 28px;
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
}

.wizard-pref-section h3 {
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 600;
	color: #1d2327;
}

.wizard-pref-hint {
	margin: 0 0 16px;
	color: #6b7280;
	font-size: 13px;
}

.wizard-model-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 10px;
}

.wizard-model-card {
	padding: 12px 14px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
	position: relative;
}

.wizard-model-card:hover { border-color: #2563eb; }

.wizard-model-card.selected {
	border-color: #2563eb;
	background: #eff6ff;
}

.wizard-model-name {
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	margin-bottom: 6px;
	word-break: break-all;
}

.wizard-model-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.wizard-model-tag {
	font-size: 11px;
	padding: 2px 7px;
	border-radius: 99px;
	background: #e5e7eb;
	color: #374151;
}

.wizard-model-tag.tag-recommended {
	background: #dcfce7;
	color: #15803d;
	font-weight: 600;
}

.wizard-model-check {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #2563eb;
	color: #fff;
	font-size: 11px;
	display: none;
	align-items: center;
	justify-content: center;
}

.wizard-model-card.selected .wizard-model-check { display: flex; }

.wizard-mode-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
}

@media (max-width: 620px) {
	.wizard-mode-grid { grid-template-columns: 1fr; }
	.wizard-model-grid { grid-template-columns: 1fr 1fr; }
}

.wizard-mode-card {
	display: block;
	padding: 14px 16px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}

.wizard-mode-card:hover { border-color: #2563eb; }

.wizard-mode-card input[type="radio"] { display: none; }

.wizard-mode-card:has(input:checked) {
	border-color: #2563eb;
	background: #eff6ff;
}

.wizard-mode-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
}

.wizard-mode-icon { font-size: 18px; }

.wizard-mode-header strong {
	font-size: 14px;
	color: #1d2327;
}

.wizard-mode-badge {
	margin-left: auto;
	font-size: 11px;
	padding: 2px 8px;
	border-radius: 99px;
	background: #dcfce7;
	color: #15803d;
	font-weight: 600;
}

.wizard-mode-card p {
	margin: 0;
	font-size: 12px;
	color: #6b7280;
	line-height: 1.5;
}
