/**
 * MDS Module 5 — video generator UI.
 * Depends on mds-system.css.
 */

/* ── Standalone layout (max 720px, single column) ──────────────────────── */
.mds-video {
	width: 100%;
	max-width: 100%;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.mds-video__form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

/* Notice banner */
.mds-video__notice {
	padding: 12px 16px;
	border-radius: var(--mds-radius, 12px);
	background: rgba(255,196,0,0.08);
	border: 1px solid rgba(255,196,0,0.25);
	color: var(--mds-premium);
	font-size: 0.88em;
}

/* ── Dropzone (shown when no source image) ───────────────────────────────── */
.mds-video__dropzone {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 22px;
	border-radius: var(--mds-radius, 12px);
	border: 1.5px dashed var(--mds-bd);
	background: var(--mds-bg-dropzone, var(--mds-fill-muted));
	cursor: pointer;
	text-align: center;
	transition: background 0.18s, border-color 0.18s;
}
.mds-video__dropzone:hover,
.mds-video__dropzone.is-over {
	background: var(--mds-bg3);
	border-color: var(--mds-accent);
}
.mds-video__dz-icon {
	color: var(--mds-text-muted);
	display: block;
	line-height: 0;
}
.mds-video__dz-label {
	font-weight: 600;
	font-size: 0.9em;
	color: var(--mds-text);
}
.mds-video__dz-hint {
	font-size: 0.78em;
	color: var(--mds-text-muted);
}

/* ── Source preview (shown when image is set) ────────────────────────────── */
.mds-video__src {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 14px;
	border-radius: var(--mds-radius, 12px);
	border: 1px solid var(--mds-bd);
	background: var(--mds-bg2);
}
.mds-video__src-thumb {
	width: 60px;
	height: 60px;
	object-fit: cover;
	border-radius: var(--mds-radius-sm, 8px);
	flex: 0 0 auto;
	display: block;
}
.mds-video__src-info {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.mds-video__src-label {
	font-size: 0.88em;
	font-weight: 600;
	color: var(--mds-text);
}
.mds-video__src-clear {
	padding: 5px 12px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--mds-bd);
	background: transparent;
	color: var(--mds-text-muted);
	font-size: 0.8em;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}
.mds-video__src-clear:hover { background: var(--mds-bg3); color: var(--mds-text); }

/* ── Prompt group (label + textarea) ────────────────────────────────────── */
.mds-video__prompt-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.mds-video__prompt-label {
	font-size: 0.78em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--mds-text-muted);
}

/* ── Prompt textarea ─────────────────────────────────────────────────────── */
.mds-video__prompt,
.mds-video__motion {
	width: 100%;
	resize: vertical;
	border-radius: var(--mds-radius, 12px);
	padding: 14px;
	font: inherit;
	font-size: 0.95em;
	border: 1px solid var(--mds-bd);
	background: var(--mds-bg2);
	color: var(--mds-text);
	transition: border-color 0.18s;
	box-sizing: border-box;
}
.mds-video__prompt:focus,
.mds-video__motion:focus { border-color: var(--mds-accent); outline: none; }
.mds-video__prompt::placeholder,
.mds-video__motion::placeholder { color: var(--mds-text-muted); }

/* ── Controls row ────────────────────────────────────────────────────────── */
.mds-video__controls {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.mds-video__ctrl-group {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.mds-video__ctrl-group--audio {
	flex-direction: row;
	align-items: center;
	gap: 12px;
}

.mds-video__ctrl-label {
	font-size: 0.8em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--mds-text-muted);
	min-width: 56px;
	flex-shrink: 0;
}

/* ── Chip group ──────────────────────────────────────────────────────────── */
.mds-chip-group {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	width: 100%;
}

.mds-chip {
	padding: 5px 14px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--mds-bd);
	background: transparent;
	color: var(--mds-text-muted);
	font-size: 0.84em;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
	line-height: 1;
}

.mds-chip:hover {
	background: var(--mds-bg3);
	color: var(--mds-text);
}

.mds-chip--active {
	background: var(--mds-accent);
	border-color: var(--mds-accent);
	color: var(--mds-on-accent);
}

.mds-chip--active:hover,
.mds-chip--active:focus-visible {
	background: var(--mds-accent-hover);
	color: var(--mds-on-accent);
}

/* Audio toggle (title + switch) */
.mds-video__ctrl-group--audio .mds-switch {
	position: relative;
	display: inline-block;
	flex: 0 0 auto;
	cursor: pointer;
	line-height: 0;
}
.mds-video__ctrl-group--audio .mds-switch__input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}
.mds-video__ctrl-group--audio .mds-switch__track {
	display: block;
	width: 46px;
	height: 26px;
	border-radius: var(--mds-radius-pill, 999px);
	background: var(--mds-bg3);
	border: 1px solid var(--mds-bd);
	position: relative;
	transition: background 0.22s, border-color 0.22s;
}
.mds-video__ctrl-group--audio .mds-switch__thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--mds-on-accent);
	box-shadow: 0 1px 4px rgba(0,0,0,0.35);
	transition: transform 0.22s;
}
.mds-video__ctrl-group--audio .mds-switch__input:checked + .mds-switch__track {
	background: var(--mds-accent);
	border-color: var(--mds-accent);
}
.mds-video__ctrl-group--audio .mds-switch__input:checked + .mds-switch__track .mds-switch__thumb {
	transform: translateX(20px);
}

/* ── Generate button ─────────────────────────────────────────────────────── */
.mds-video__go {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: center;
	gap: 0;
	width: 100%;
	padding: 14px 24px;
	border-radius: var(--mds-radius-pill, 999px);
	border: none;
	background: var(--mds-accent);
	color: var(--mds-on-accent);
	font-size: 1em;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.18s, opacity 0.18s;
	box-sizing: border-box;
}
.mds-video__go:hover { background: var(--mds-accent-hover); }
.mds-video__go.is-busy { opacity: 0.65; cursor: not-allowed; }

.mds-video__go > .mds-video__cost,
.mds-video__cost {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	padding: 3px 10px;
	border-radius: var(--mds-radius-pill, 999px);
	background: color-mix(in srgb, var(--mds-text) 18%, transparent);
	font-size: 0.82em;
	font-weight: 700;
}
.mds-video__go > .mds-video__cost {
	grid-column: 3;
	justify-self: end;
	align-self: center;
}

/* ── Prompt suggestion pills ─────────────────────────────────────────────── */
.mds-video__pills {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mds-video__pills-tabs {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
}

.mds-video__pill-tab {
	padding: 4px 12px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--mds-bd);
	background: transparent;
	color: var(--mds-text-muted);
	font-size: 0.78em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.mds-video__pill-tab:hover { color: var(--mds-text); }
.mds-video__pill-tab--active {
	background: var(--mds-bg3);
	color: var(--mds-text);
	border-color: var(--mds-accent);
}

.mds-video__pills-group { display: none; flex-wrap: wrap; gap: 6px; }
.mds-video__pills-group.is-active { display: flex; }

.mds-video__pill {
	padding: 4px 12px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--mds-bd);
	background: transparent;
	color: var(--mds-text-muted);
	font-size: 0.8em;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mds-video__pill:hover {
	background: var(--mds-bg3);
	border-color: var(--mds-accent);
	color: var(--mds-text);
}

.mds-video__wan-presets {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 4px;
}

.mds-video__wan-presets-hint {
	margin: 0;
	font-size: 0.78em;
	color: var(--mds-text-muted);
}

.mds-video__wan-presets-row {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.mds-video__wan-preset {
	padding: 4px 12px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--theme-color-text_link, var(--mds-accent));
	background: transparent;
	color: var(--mds-text);
	font-size: 0.8em;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.mds-video__wan-preset:hover,
.mds-video__wan-preset.is-active {
	background: color-mix(in srgb, var(--theme-color-text_link, var(--mds-accent)) 18%, transparent);
	color: var(--theme-color-text_dark, var(--mds-text));
}

/* ── Result area ─────────────────────────────────────────────────────────── */
.mds-video__result { margin-top: 4px; }

.mds-video__result-empty {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	border-radius: var(--mds-radius, 12px);
	border: 1.5px dashed var(--mds-bd);
	color: var(--mds-text-muted);
	font-size: 0.9em;
	text-align: center;
	padding: 24px;
}

/* Hides the empty placeholder once a real result is rendered */
.mds-video__result:not(:empty) .mds-video__result-empty { display: none; }
.mds-video__result video {
	width: 100%;
	border-radius: var(--mds-radius, 12px);
	display: block;
}
.mds-video__actions { margin-top: 10px; display: flex; gap: 10px; }
.mds-video__actions a {
	padding: 8px 20px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--mds-bd);
	background: transparent;
	color: var(--mds-text);
	font-weight: 600;
	font-size: 0.88em;
	text-decoration: none;
	transition: background 0.18s;
}
.mds-video__actions a:hover { background: var(--mds-bg3); color: var(--mds-text); }

/* Status + spinner */
.mds-video__status {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	border-radius: var(--mds-radius, 12px);
	background: var(--mds-bg2);
	border: 1px solid var(--mds-bd);
	color: var(--mds-text-muted);
	font-size: 0.9em;
}
.mds-video__spinner {
	display: inline-block;
	width: 18px; height: 18px;
	border: 2px solid var(--mds-bd);
	border-top-color: var(--mds-accent);
	border-radius: 50%;
	animation: mds-spin 0.75s linear infinite;
	flex-shrink: 0;
}
@keyframes mds-spin { to { transform: rotate(360deg); } }

.mds-video__error-row {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	padding: 12px 16px;
	border-radius: var(--mds-radius, 12px);
	background: rgba(255,80,80,0.08);
	border: 1px solid rgba(255,80,80,0.25);
}
.mds-video__error {
	color: var(--mds-danger);
	font-size: 0.88em;
	margin: 0;
	flex: 1;
}
.mds-video__retry-btn {
	padding: 5px 14px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid rgba(255,80,80,0.4);
	background: transparent;
	color: var(--mds-danger);
	font-size: 0.82em;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s;
	flex-shrink: 0;
}
.mds-video__retry-btn:hover { background: rgba(255,80,80,0.12); }

/* ── Split-panel layout when inside Studio ───────────────────────────────── */
.mds-studio__panel--active .mds-video {
	max-width: none;
	margin: 0;
	display: grid;
	grid-template-columns: minmax(280px, 2fr) minmax(0, 3fr);
	gap: 28px;
	align-items: start;
}

/* Studio Video: single column until first result slot; no giant empty pane */
.mds-studio__panel--active .mds-video:has(.mds-video__results:empty) {
	grid-template-columns: 1fr;
}

.mds-studio__panel--active .mds-video:has(.mds-video__results:empty) .mds-video__result {
	display: none;
}

.mds-studio__panel--active .mds-video__result {
	margin-top: 0;
	position: sticky;
	top: 80px; /* account for sticky header */
}

.mds-studio__panel--active .mds-video__result-empty {
	display: none;
}

@media (max-width: 767px) {
	.mds-studio__panel--active .mds-video {
		grid-template-columns: 1fr;
	}
	.mds-studio__panel--active .mds-video__result {
		position: static;
	}
}

/* ── Generate button wrapper (for counter badge positioning) ─────────────── */
.mds-video__generate-wrap {
	position: relative;
	display: block;
	width: 100%;
}

/* ── Active-slot counter badge ───────────────────────────────────────────── */
.mds-video__gen-count {
	position: absolute;
	top: -8px;
	right: -8px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: var(--mds-radius-pill, 999px);
	background: var(--mds-accent);
	color: var(--mds-on-accent);
	font-size: 0.72em;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	pointer-events: none;
}

/* ── Concurrent-generation hint bar ──────────────────────────────────────── */
.mds-video__concurrent-hint {
	background: var(--mds-bg2);
	border: 1px solid var(--mds-bd);
	border-radius: var(--mds-radius, 12px);
	padding: 10px 14px;
	font-size: 0.85em;
	color: var(--mds-text-muted);
}

/* ── Multi-slot results container ────────────────────────────────────────── */
.mds-video__results {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-top: 4px;
}

/* ── Individual result slot card ─────────────────────────────────────────── */
.mds-video__result-slot {
	background: var(--mds-bg2);
	border: 1px solid var(--mds-bd);
	border-radius: var(--mds-radius, 12px);
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Status row: spinner + pulsing text */
.mds-video__slot-status {
	display: flex;
	align-items: center;
	gap: 10px;
}

.mds-video__slot-status-text {
	font-size: 0.88em;
	font-style: italic;
	color: var(--mds-text-muted);
	animation: mds-slot-pulse 1.6s ease-in-out infinite;
}

@keyframes mds-slot-pulse {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0.45; }
}

/* Media area */
.mds-video__slot-media video {
	width: 100%;
	border-radius: var(--mds-radius-sm, 8px);
	display: block;
}

/* Action buttons row */
.mds-video__slot-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.mds-video__slot-actions a,
.mds-video__slot-actions button {
	padding: 7px 16px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid var(--mds-bd);
	background: transparent;
	color: var(--mds-text);
	font-weight: 600;
	font-size: 0.85em;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.18s;
	font-family: inherit;
}

.mds-video__slot-actions a:hover,
.mds-video__slot-actions button:hover {
	background: var(--mds-bg3);
	color: var(--mds-text);
}

/* Error row */
.mds-video__slot-error {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	border-radius: var(--mds-radius, 12px);
	background: rgba(255,80,80,0.08);
	border: 1px solid rgba(255,80,80,0.22);
}

.mds-video__slot-error-msg {
	font-size: 0.88em;
	color: var(--mds-danger);
	flex: 1;
}

.mds-video__slot-error-btns {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.mds-video__retry-btn,
.mds-video__slot-dismiss {
	padding: 5px 12px;
	border-radius: var(--mds-radius-pill, 999px);
	border: 1px solid rgba(255,80,80,0.35);
	background: transparent;
	color: var(--mds-danger);
	font-size: 0.8em;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.15s;
	font-family: inherit;
}

.mds-video__retry-btn:hover,
.mds-video__slot-dismiss:hover {
	background: rgba(255,80,80,0.12);
}

/* Sticky results pane in split-panel (inherits from .mds-video__result) */
.mds-studio__panel--active .mds-video__results {
	margin-top: 0;
}
