/**
 * Campaign Wizard styles.
 * Uses existing CSS variables from rsocials design system.
 */

/* ── Container ── */
.cw-container {
	max-width: 960px;
	margin: 2rem auto;
	padding: 0 1.5rem;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	color: var(--rs-text-primary, #e1e1e1);
}

.cw-header {
	margin-bottom: 2rem;
}

.cw-header h1 {
	font-size: 1.6rem;
	margin: 0 0 0.25rem;
}

.cw-header p {
	color: var(--rs-text-secondary, #94a3b8);
	margin: 0;
	font-size: 0.9rem;
}

/* ── Step indicator ── */
.cw-steps {
	display: flex;
	align-items: center;
	gap: 0;
	margin-bottom: 2.5rem;
	padding: 0;
	list-style: none;
}

.cw-step {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.82rem;
	color: var(--rs-text-muted, #64748b);
	white-space: nowrap;
}

.cw-step__num {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	font-size: 0.75rem;
	border: 2px solid var(--rs-border, #333);
	background: transparent;
	transition: all 0.2s;
	flex-shrink: 0;
}

.cw-step.active .cw-step__num {
	border-color: var(--rs-accent, #14b8a6);
	background: var(--rs-accent, #14b8a6);
	color: #000;
}

.cw-step.done .cw-step__num {
	border-color: var(--rs-accent, #14b8a6);
	background: var(--rs-accent, #14b8a6);
	color: #000;
}

.cw-step.active {
	color: var(--rs-text-primary, #e1e1e1);
}

.cw-step.done {
	color: var(--rs-text-secondary, #94a3b8);
}

.cw-step__line {
	flex: 1;
	height: 2px;
	min-width: 20px;
	background: var(--rs-border, #333);
	margin: 0 0.25rem;
}

.cw-step.done + .cw-step__line,
.cw-step.done ~ .cw-step__line {
	background: var(--rs-accent, #14b8a6);
}

/* ── Step panels ── */
.cw-panel {
	background: var(--rs-bg-surface, #1e1e2e);
	border: 1px solid var(--rs-border, #333);
	border-radius: 12px;
	padding: 1.5rem;
	margin-bottom: 1.5rem;
}

.cw-panel h2 {
	font-size: 1.2rem;
	margin: 0 0 0.5rem;
}

.cw-panel p.cw-hint {
	color: var(--rs-text-secondary, #94a3b8);
	font-size: 0.85rem;
	margin: 0 0 1rem;
}

/* ── Brief textarea ── */
.cw-textarea {
	width: 100%;
	min-height: 180px;
	padding: 0.75rem 1rem;
	border: 1px solid var(--rs-input-border, #334155);
	border-radius: 8px;
	background: var(--rs-bg-surface-sunken, #14141e);
	color: var(--rs-text-primary, #e1e1e1);
	font-family: inherit;
	font-size: 0.9rem;
	line-height: 1.6;
	resize: vertical;
	box-sizing: border-box;
}

.cw-textarea:focus {
	outline: none;
	border-color: var(--rs-accent, #14b8a6);
}

/* ── Action buttons ── */
.cw-actions {
	display: flex;
	gap: 0.75rem;
	margin-top: 1.25rem;
	flex-wrap: wrap;
}

.cw-btn {
	padding: 0.6rem 1.25rem;
	border-radius: 8px;
	border: 1px solid var(--rs-border, #444);
	background: var(--rs-bg-surface, #252538);
	color: var(--rs-text-primary, #e1e1e1);
	font-size: 0.85rem;
	cursor: pointer;
	transition: all 0.15s;
	font-family: inherit;
}

.cw-btn:hover {
	border-color: var(--rs-accent, #14b8a6);
	background: var(--rs-bg-hover);
}

.cw-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.cw-btn--primary {
	background: var(--rs-accent, #14b8a6);
	color: #000;
	border-color: var(--rs-accent, #14b8a6);
	font-weight: 600;
}

.cw-btn--primary:hover {
	opacity: 0.9;
}

.cw-btn--danger {
	border-color: #dc2626;
	color: #f87171;
}

.cw-btn--danger:hover {
	background: rgba(220, 38, 38, 0.15);
}

.cw-btn--ghost {
	background: transparent;
	border-color: transparent;
	color: var(--rs-text-secondary, #94a3b8);
}

.cw-btn--ghost:hover {
	color: var(--rs-text-primary, #e1e1e1);
}

/* ── Extracted brief summary ── */
.cw-brief-summary {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.cw-brief-field {
	background: var(--rs-bg-surface-sunken, #14141e);
	padding: 0.6rem 0.85rem;
	border-radius: 8px;
	border: 1px solid var(--rs-border, #333);
}

.cw-brief-field__label {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--rs-text-muted, #64748b);
	margin-bottom: 0.2rem;
}

.cw-brief-field__value {
	font-size: 0.88rem;
	color: var(--rs-text-primary, #e1e1e1);
}

.cw-brief-field--wide {
	grid-column: 1 / -1;
}

/* ── Phase cards ── */
.cw-phases {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.cw-phase-card {
	background: var(--rs-bg-surface-sunken, #14141e);
	border: 1px solid var(--rs-border, #333);
	border-radius: 10px;
	padding: 1rem 1.25rem;
}

.cw-phase-card__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
}

.cw-phase-card__name {
	font-weight: 600;
	font-size: 0.95rem;
}

.cw-phase-card__days {
	font-size: 0.8rem;
	color: var(--rs-text-muted, #64748b);
}

.cw-phase-card__cadence {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.cw-cadence-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.2rem 0.5rem;
	border-radius: 4px;
	font-size: 0.75rem;
	background: rgba(20, 184, 166, 0.1);
	color: var(--rs-accent, #14b8a6);
	border: 1px solid rgba(20, 184, 166, 0.2);
}

/* ── Post review table ── */
.cw-posts-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.85rem;
}

.cw-posts-table th {
	text-align: left;
	padding: 0.6rem 0.75rem;
	border-bottom: 2px solid var(--rs-border, #333);
	color: var(--rs-text-muted, #64748b);
	font-weight: 600;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.cw-posts-table td {
	padding: 0.6rem 0.75rem;
	border-bottom: 1px solid var(--rs-border, #262626);
	vertical-align: top;
}

.cw-posts-table tr:hover td {
	background: var(--rs-bg-surface-sunken, #14141e);
}

.cw-post-content {
	max-width: 400px;
	white-space: pre-wrap;
	word-break: break-word;
	line-height: 1.45;
}

.cw-post-content--truncated {
	max-height: 80px;
	overflow: hidden;
	position: relative;
}

.cw-post-content--truncated::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 24px;
	background: linear-gradient(transparent, var(--rs-bg-surface, #1e1e2e));
}

.cw-platform-badge {
	display: inline-block;
	padding: 0.15rem 0.45rem;
	border-radius: 4px;
	font-size: 0.75rem;
	font-weight: 500;
	text-transform: capitalize;
}

.cw-platform-badge--x { background: #1d9bf01a; color: #1d9bf0; }
.cw-platform-badge--linkedin { background: #0a66c21a; color: #0a66c2; }
.cw-platform-badge--instagram { background: #e1306c1a; color: #e1306c; }
.cw-platform-badge--threads { background: #ffffff1a; color: #ccc; }
.cw-platform-badge--bluesky { background: #0085ff1a; color: #0085ff; }
.cw-platform-badge--youtube { background: #ff00001a; color: #ff4444; }
.cw-platform-badge--newsletter { background: #10b9811a; color: #10b981; }

/* ── Loading / spinner ── */
.cw-loading {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 2rem;
	justify-content: center;
	color: var(--rs-text-secondary, #94a3b8);
}

.cw-spinner {
	width: 20px;
	height: 20px;
	border: 2px solid var(--rs-border, #333);
	border-top-color: var(--rs-accent, #14b8a6);
	border-radius: 50%;
	animation: cw-spin 0.6s linear infinite;
}

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

/* ── Success panel ── */
.cw-success {
	text-align: center;
	padding: 2rem 1rem;
}

.cw-success__icon {
	font-size: 3rem;
	margin-bottom: 0.75rem;
}

.cw-success__links {
	display: flex;
	gap: 0.75rem;
	justify-content: center;
	margin-top: 1.5rem;
	flex-wrap: wrap;
}

.cw-success__links a {
	color: var(--rs-accent, #14b8a6);
	text-decoration: none;
	padding: 0.5rem 1rem;
	border: 1px solid var(--rs-accent, #14b8a6);
	border-radius: 8px;
	font-size: 0.85rem;
	transition: background 0.15s;
}

.cw-success__links a:hover {
	background: rgba(20, 184, 166, 0.1);
}

/* ── Platform selector chips ── */
.cw-platform-selector {
	margin-top: 1rem;
}

.cw-platform-selector__label {
	font-size: 0.8rem;
	color: var(--rs-text-muted, #64748b);
	display: block;
	margin-bottom: 0.5rem;
}

.cw-platform-selector__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.cw-platform-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.7rem;
	border-radius: 6px;
	border: 1px solid var(--rs-border, #444);
	background: transparent;
	color: var(--rs-text-muted, #64748b);
	font-size: 0.8rem;
	font-family: inherit;
	cursor: pointer;
	transition: all 0.15s;
	text-transform: capitalize;
}

.cw-platform-chip input[type="checkbox"] {
	accent-color: var(--rs-accent, #14b8a6);
	width: 14px;
	height: 14px;
	margin: 0;
	cursor: pointer;
}

.cw-platform-chip span {
	pointer-events: none;
}

.cw-platform-chip:hover {
	border-color: var(--rs-accent, #14b8a6);
	color: var(--rs-text-primary, #e1e1e1);
}

.cw-platform-chip--active {
	background: rgba(20, 184, 166, 0.1);
	border-color: var(--rs-accent, #14b8a6);
	color: var(--rs-accent, #14b8a6);
}

/* ── Clickable phase card headers ── */
.cw-phase-card__header--clickable {
	cursor: pointer;
	user-select: none;
	border-radius: 6px;
	transition: background 0.15s;
}

.cw-phase-card__header--clickable:hover {
	background: rgba(255, 255, 255, 0.03);
}

/* ── Phase chevron ── */
.cw-phase-chevron {
	display: inline-block;
	font-size: 0.65rem;
	color: var(--rs-text-muted, #64748b);
	transition: transform 0.2s ease;
}

.cw-phase-chevron--open {
	transform: rotate(90deg);
}

/* ── Phase expanded preview ── */
.cw-phase-card__preview {
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px solid var(--rs-border, #333);
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.cw-phase-preview-post {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.8rem;
	color: var(--rs-text-secondary, #94a3b8);
}

.cw-phase-preview-post__spread {
	color: var(--rs-text-muted, #64748b);
	font-size: 0.75rem;
	margin-left: auto;
}

/* ── Phase instructions textarea ── */
.cw-phase-instructions {
	width: 100%;
	min-height: 56px;
	padding: 0.5rem 0.75rem;
	margin-top: 0.5rem;
	border: 1px solid var(--rs-input-border, #334155);
	border-radius: 6px;
	background: var(--rs-bg-surface, #1e1e2e);
	color: var(--rs-text-primary, #e1e1e1);
	font-family: inherit;
	font-size: 0.8rem;
	line-height: 1.5;
	resize: vertical;
	box-sizing: border-box;
}

.cw-phase-instructions:focus {
	outline: none;
	border-color: var(--rs-accent, #14b8a6);
}

.cw-phase-instructions::placeholder {
	color: var(--rs-text-muted, #64748b);
	font-style: italic;
}

/* ── Responsive ── */
@media (max-width: 640px) {
	.cw-brief-summary {
		grid-template-columns: 1fr;
	}

	.cw-steps {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.cw-posts-table {
		display: block;
		overflow-x: auto;
	}
}
