/* ===================================================================
   AI Wedding Studio — Frontend styles
   Design language: a nod to the Persian "Sofreh Aghd" mirror (آینه بخت) —
   the moment the couple first sees their reflection together. Ink-dark
   ground, antique-gold line work, warm ivory paper, framed portraits
   with viewfinder-style corner brackets.
   =================================================================== */

.aiws-root {
	--aiws-accent: #c9a24b;
	--aiws-accent-dark: #7a2e3a;
	--aiws-ink: #1c1a1e;
	--aiws-paper: #fbf6ee;
	--aiws-sage: #3f5c4e;
	--aiws-ink-soft: rgba(28, 26, 30, 0.66);
	--aiws-line: rgba(28, 26, 30, 0.12);
	--aiws-on-ink: #f4ede1;
	--aiws-radius-lg: 22px;
	--aiws-radius-md: 14px;
	--aiws-radius-sm: 9px;
	--aiws-font: 'Vazirmatn', Tahoma, 'Segoe UI', system-ui, sans-serif;

	font-family: var(--aiws-font);
	color: var(--aiws-ink);
	direction: rtl;
	box-sizing: border-box;
}
.aiws-root *,
.aiws-root *::before,
.aiws-root *::after {
	box-sizing: inherit;
	font-family: inherit;
}
.aiws-root button {
	cursor: pointer;
	font: inherit;
}
/* یک قانون تعیین‌کننده: هرجا ویژگی hidden ست شده، همیشه مخفی باشد —
   حتی اگر کلاس همان المنت display دیگری (flex/grid) تعریف کرده باشد. */
.aiws-root [hidden] {
	display: none !important;
}

/* -------------------------------------------------- Banner -------- */
.aiws-banner {
	position: relative;
	background: var(--aiws-ink);
	border-radius: var(--aiws-radius-lg);
	overflow: hidden;
	isolation: isolate;
}
.aiws-banner::before {
	content: '';
	position: absolute;
	inset: -30% -10% auto auto;
	width: 60%;
	aspect-ratio: 1;
	background: radial-gradient(circle, var(--aiws-accent) 0%, transparent 70%);
	opacity: 0.16;
	pointer-events: none;
	z-index: 0;
}
.aiws-banner-inner {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: minmax(220px, 0.85fr) 1.15fr;
	align-items: center;
	gap: clamp(24px, 5vw, 56px);
	padding: clamp(28px, 4vw, 48px);
}
.aiws-banner-media {
	display: flex;
	justify-content: center;
}
.aiws-frame {
	position: relative;
	width: 100%;
	max-width: 280px;
	aspect-ratio: 3 / 4;
	border-radius: 130px 130px 18px 18px;
	overflow: hidden;
	background: linear-gradient(160deg, rgba(201, 162, 75, 0.18), rgba(122, 46, 58, 0.18));
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.aiws-frame img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.aiws-frame-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--aiws-accent);
}
.aiws-frame-placeholder svg {
	width: 55%;
	height: 55%;
}
.aiws-corner {
	position: absolute;
	width: 26px;
	height: 26px;
	pointer-events: none;
}
.aiws-corner-tl { top: 10px; left: 10px; border-top: 2px solid var(--aiws-accent); border-right: 2px solid var(--aiws-accent); border-radius: 0 8px 0 0; }
.aiws-corner-tr { top: 10px; right: 10px; border-top: 2px solid var(--aiws-accent); border-left: 2px solid var(--aiws-accent); border-radius: 8px 0 0 0; }
.aiws-corner-bl { bottom: 10px; left: 10px; border-bottom: 2px solid var(--aiws-accent); border-right: 2px solid var(--aiws-accent); border-radius: 0 0 8px 0; }
.aiws-corner-br { bottom: 10px; right: 10px; border-bottom: 2px solid var(--aiws-accent); border-left: 2px solid var(--aiws-accent); border-radius: 0 0 0 8px; }

.aiws-banner-content { min-width: 0; }
.aiws-eyebrow {
	display: inline-block;
	color: var(--aiws-accent);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.04em;
	margin-bottom: 12px;
	position: relative;
	padding-inline-start: 22px;
}
.aiws-eyebrow::before {
	content: '';
	position: absolute;
	inline-size: 14px;
	block-size: 1px;
	background: var(--aiws-accent);
	inset-inline-start: 0;
	top: 50%;
}
.aiws-title {
	color: var(--aiws-on-ink);
	font-size: clamp(22px, 2.6vw, 32px);
	font-weight: 800;
	line-height: 1.5;
	margin: 0 0 14px;
}
.aiws-desc {
	color: rgba(244, 237, 225, 0.78);
	font-size: 15px;
	line-height: 1.9;
	margin: 0 0 26px;
	max-width: 52ch;
}
.aiws-cta-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: var(--aiws-accent);
	color: var(--aiws-ink);
	border: none;
	border-radius: 999px;
	padding: 14px 26px;
	font-size: 15px;
	font-weight: 700;
	transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
	box-shadow: 0 10px 24px rgba(201, 162, 75, 0.25);
}
.aiws-cta-btn:hover { background: #d9b463; transform: translateY(-1px); }
.aiws-cta-btn:focus-visible { outline: 2px solid var(--aiws-on-ink); outline-offset: 3px; }
.aiws-cta-btn svg { transition: transform 0.15s ease; }
.aiws-cta-btn:hover svg { transform: translateX(-3px); }

@media (max-width: 720px) {
	.aiws-banner-inner { grid-template-columns: 1fr; text-align: center; }
	.aiws-banner-media { order: -1; }
	.aiws-eyebrow { padding-inline-start: 0; }
	.aiws-eyebrow::before { display: none; }
	.aiws-desc { max-width: none; }
}

/* -------------------------------------------------- Modal ---------- */
.aiws-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(17, 15, 18, 0.72);
	backdrop-filter: blur(3px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px;
	z-index: 100000;
}
.aiws-modal-overlay[hidden] { display: none; }
.aiws-modal {
	width: 100%;
	max-width: 1120px;
	max-height: 92vh;
	background: var(--aiws-paper);
	border-radius: var(--aiws-radius-lg);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}
.aiws-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 22px;
	background: var(--aiws-ink);
	color: var(--aiws-on-ink);
	flex-shrink: 0;
}
.aiws-modal-header h2 { margin: 0; font-size: 17px; font-weight: 700; }
.aiws-icon-btn {
	background: transparent;
	border: none;
	color: inherit;
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background 0.15s ease;
}
.aiws-icon-btn:hover { background: rgba(244, 237, 225, 0.12); }

.aiws-modal-body {
	display: grid;
	grid-template-columns: 1.05fr 0.95fr;
	gap: 0;
	overflow: hidden;
	flex: 1;
	min-height: 0;
}
.aiws-modal-controls {
	padding: 22px;
	overflow-y: auto;
	border-inline-end: 1px solid var(--aiws-line);
}
.aiws-modal-results {
	padding: 22px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	background: rgba(28, 26, 30, 0.02);
}

.aiws-field-group { margin-bottom: 22px; }
.aiws-field-label {
	display: block;
	font-size: 13.5px;
	font-weight: 700;
	margin-bottom: 10px;
	color: var(--aiws-ink);
}

.aiws-radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.aiws-radio-chip {
	position: relative;
	border: 1.5px solid var(--aiws-line);
	border-radius: 999px;
	padding: 8px 18px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--aiws-ink-soft);
	background: #fff;
	transition: all 0.15s ease;
	cursor: pointer;
}
.aiws-radio-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.aiws-radio-chip.is-active,
.aiws-radio-chip:has(input:checked) {
	background: var(--aiws-ink);
	border-color: var(--aiws-ink);
	color: var(--aiws-on-ink);
}

.aiws-upload-row { display: flex; gap: 12px; flex-wrap: wrap; }
.aiws-dropzone {
	flex: 1 1 160px;
	min-width: 150px;
	aspect-ratio: 4 / 5;
	max-height: 190px;
	border: 1.5px dashed var(--aiws-accent);
	border-radius: var(--aiws-radius-md);
	background: rgba(201, 162, 75, 0.06);
	position: relative;
	overflow: hidden;
	transition: background 0.15s ease, border-color 0.15s ease;
}
.aiws-dropzone.is-dragover { background: rgba(201, 162, 75, 0.16); border-color: var(--aiws-accent-dark); }
.aiws-dropzone-empty {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	text-align: center;
	color: var(--aiws-accent-dark);
	padding: 10px;
	cursor: pointer;
}
.aiws-dropzone-empty span { font-size: 13.5px; font-weight: 700; color: var(--aiws-ink); }
.aiws-dropzone-empty small { font-size: 11px; color: var(--aiws-ink-soft); line-height: 1.5; }
.aiws-dropzone-preview { position: absolute; inset: 0; }
.aiws-dropzone-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aiws-dropzone-remove {
	position: absolute;
	top: 6px;
	left: 6px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: none;
	background: rgba(28, 26, 30, 0.75);
	color: #fff;
	font-size: 15px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

.aiws-textarea,
.aiws-select-field select,
.aiws-gallery-tabs {
	width: 100%;
}
.aiws-textarea {
	border: 1.5px solid var(--aiws-line);
	border-radius: var(--aiws-radius-sm);
	padding: 12px 14px;
	font-size: 13.5px;
	resize: vertical;
	background: #fff;
	color: var(--aiws-ink);
}
.aiws-textarea:focus,
.aiws-select-field select:focus {
	outline: none;
	border-color: var(--aiws-accent);
	box-shadow: 0 0 0 3px rgba(201, 162, 75, 0.18);
}

.aiws-gallery-tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--aiws-line); margin-bottom: 12px; overflow-x: auto; }
.aiws-tab-btn {
	background: none;
	border: none;
	padding: 9px 4px;
	margin-inline-end: 18px;
	font-size: 13px;
	font-weight: 600;
	color: var(--aiws-ink-soft);
	border-bottom: 2px solid transparent;
	white-space: nowrap;
	transition: color 0.15s ease, border-color 0.15s ease;
}
.aiws-tab-btn.is-active { color: var(--aiws-ink); border-color: var(--aiws-accent); }

.aiws-gallery-panel {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
	gap: 8px;
	max-height: 220px;
	overflow-y: auto;
	padding-inline-end: 2px;
}
.aiws-gallery-item {
	position: relative;
	aspect-ratio: 3 / 4;
	border-radius: 10px;
	overflow: hidden;
	border: 2px solid transparent;
	background: var(--aiws-line);
	padding: 0;
}
.aiws-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aiws-gallery-item.is-selected { border-color: var(--aiws-accent); box-shadow: 0 0 0 2px rgba(201, 162, 75, 0.35); }
.aiws-gallery-item.is-selected::after {
	content: '✓';
	position: absolute;
	top: 4px;
	right: 4px;
	width: 18px;
	height: 18px;
	background: var(--aiws-accent);
	color: var(--aiws-ink);
	border-radius: 50%;
	font-size: 11px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
}
.aiws-gallery-empty { grid-column: 1 / -1; font-size: 12.5px; color: var(--aiws-ink-soft); padding: 14px 4px; text-align: center; }

.aiws-selected-template {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 12px;
	padding: 8px 10px;
	border-radius: var(--aiws-radius-sm);
	background: rgba(201, 162, 75, 0.1);
	font-size: 12.5px;
}
.aiws-selected-template img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.aiws-selected-template span { flex: 1; font-weight: 600; }
.aiws-selected-template button { background: none; border: none; color: var(--aiws-accent-dark); font-size: 12px; text-decoration: underline; font-weight: 600; }

.aiws-tool-settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.aiws-select-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--aiws-ink-soft); }
.aiws-select-field select {
	border: 1.5px solid var(--aiws-line);
	border-radius: var(--aiws-radius-sm);
	padding: 9px 10px;
	background: #fff;
	color: var(--aiws-ink);
	font-size: 13px;
}

.aiws-generate-btn {
	width: 100%;
	background: var(--aiws-ink);
	color: var(--aiws-on-ink);
	border: none;
	border-radius: 999px;
	padding: 15px 20px;
	font-size: 15px;
	font-weight: 700;
	transition: background 0.15s ease, opacity 0.15s ease;
}
.aiws-generate-btn:hover { background: #2b2830; }
.aiws-generate-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.aiws-error-msg {
	margin: 12px 0 0;
	padding: 10px 14px;
	border-radius: var(--aiws-radius-sm);
	background: rgba(122, 46, 58, 0.08);
	color: var(--aiws-accent-dark);
	font-size: 13px;
	font-weight: 600;
}

/* -------------------------------------------------- Results -------- */
.aiws-results-empty {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: var(--aiws-ink-soft);
	gap: 10px;
	min-height: 260px;
}
.aiws-results-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}
.aiws-result-card {
	position: relative;
	aspect-ratio: 3 / 4;
	border-radius: var(--aiws-radius-md);
	overflow: hidden;
	background: #efe8da;
}
.aiws-result-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aiws-result-card .aiws-result-actions {
	position: absolute;
	inset-inline-end: 8px;
	bottom: 8px;
	display: flex;
	gap: 6px;
	opacity: 0;
	transition: opacity 0.15s ease;
}
.aiws-result-card:hover .aiws-result-actions,
.aiws-result-card:focus-within .aiws-result-actions { opacity: 1; }
.aiws-result-actions button,
.aiws-result-actions a {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: rgba(28, 26, 30, 0.75);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	padding: 0;
}
.aiws-result-card.is-loading {
	display: flex;
	align-items: center;
	justify-content: center;
}
.aiws-loading-inner { text-align: center; padding: 10px; }
.aiws-spinner {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 3px solid rgba(201, 162, 75, 0.25);
	border-top-color: var(--aiws-accent);
	animation: aiws-spin 0.8s linear infinite;
	margin: 0 auto 10px;
}
@keyframes aiws-spin { to { transform: rotate(360deg); } }
.aiws-loading-text { font-size: 11.5px; color: var(--aiws-ink-soft); min-height: 2.6em; }
.aiws-result-card.is-error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px; text-align: center; background: rgba(122, 46, 58, 0.06); }
.aiws-result-card.is-error p { font-size: 11.5px; color: var(--aiws-accent-dark); margin: 0; }
.aiws-retry-btn {
	background: var(--aiws-ink);
	color: var(--aiws-on-ink);
	border: none;
	border-radius: 999px;
	padding: 6px 16px;
	font-size: 12px;
	font-weight: 700;
}
.aiws-regenerate-btn {
	margin-top: 14px;
	align-self: center;
	background: none;
	border: 1.5px solid var(--aiws-line);
	border-radius: 999px;
	padding: 9px 20px;
	font-size: 12.5px;
	font-weight: 700;
	color: var(--aiws-ink);
}
.aiws-regenerate-btn:hover { border-color: var(--aiws-accent); }

/* -------------------------------------------------- Lightbox -------- */
.aiws-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(17, 15, 18, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100001;
	padding: 30px;
}
.aiws-lightbox[hidden] { display: none; }
.aiws-lightbox img { max-width: 90vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.aiws-lightbox-close { position: absolute; top: 18px; left: 18px; background: rgba(255, 255, 255, 0.1); color: #fff; }

/* -------------------------------------------------- Responsive ----- */
@media (max-width: 860px) {
	.aiws-modal-body { grid-template-columns: 1fr; overflow-y: auto; }
	.aiws-modal-controls { border-inline-end: none; border-bottom: 1px solid var(--aiws-line); overflow-y: visible; }
	.aiws-modal-results { overflow-y: visible; }
	.aiws-tool-settings { grid-template-columns: 1fr 1fr; }
	.aiws-modal { max-height: 94vh; }
}
@media (max-width: 480px) {
	.aiws-tool-settings { grid-template-columns: 1fr; }
	.aiws-results-grid { grid-template-columns: 1fr 1fr; }
}

/* -------------------------------------------------- Motion --------- */
@media (prefers-reduced-motion: reduce) {
	.aiws-spinner { animation: none; border-top-color: var(--aiws-accent); }
	.aiws-cta-btn, .aiws-cta-btn svg, .aiws-result-actions { transition: none; }
}
