/**
 * Card Collection - formulaire de saisie
 *
 * Deux colonnes : visuels a gauche, champs a droite. Les zones de
 * depot respectent le format 64 x 89 mm, si bien que l'apercu montre
 * exactement le cadrage qui sera applique.
 *
 * @copyright (c) 2024, Verturin
 * @license GNU General Public License, version 2 (GPL-2.0)
 */

.cc-form {
	--cc-form-ink: #1c1f26;
	--cc-form-muted: #6b7280;
	--cc-form-line: rgba(0, 0, 0, .12);
	--cc-form-surface: rgba(255, 255, 255, .72);
	--cc-form-accent: #3b82f6;
}

@media (prefers-color-scheme: dark) {
	.cc-form {
		--cc-form-ink: #e5e7eb;
		--cc-form-muted: #9ca3af;
		--cc-form-line: rgba(255, 255, 255, .16);
		--cc-form-surface: rgba(255, 255, 255, .05);
	}
}

/* =============================================================
 * MISE EN PAGE
 * ============================================================= */

.cc-form-grid {
	display: grid;
	grid-template-columns: 260px minmax(0, 1fr);
	gap: 30px;
	align-items: start;
}

@media (max-width: 800px) {
	.cc-form-grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 24px;
	}
}

.cc-form-visual {
	position: sticky;
	top: 16px;
}

@media (max-width: 800px) {
	.cc-form-visual {
		position: static;
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
		gap: 16px;
	}
}

/* =============================================================
 * ZONES DE DEPOT D'IMAGE
 * ============================================================= */

.cc-card-panel {
	margin-bottom: 18px;
}

.cc-panel-label {
	display: block;
	margin-bottom: 6px;
	font-size: .78em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--cc-form-muted);
}

/* Le champ fichier natif est masque : le clic passe par le label */
.cc-file {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

.cc-drop {
	position: relative;
	display: block;
	aspect-ratio: 64 / 89;
	border: 2px dashed var(--cc-form-line);
	border-radius: 12px;
	background: var(--cc-form-surface);
	cursor: pointer;
	overflow: hidden;
	transition: border-color .18s ease, background .18s ease;
}

.cc-drop:hover,
.cc-drop.is-dragging {
	border-color: var(--cc-form-accent);
	background: rgba(59, 130, 246, .07);
}

.cc-file:focus-visible + .cc-drop {
	outline: 2px solid var(--cc-form-accent);
	outline-offset: 2px;
}

/* L'apercu occupe toute la pochette, cadre comme le sera l'import */
.cc-drop-preview {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

.cc-drop-hint {
	position: absolute;
	inset: auto 0 0 0;
	padding: 10px 8px;
	background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0));
	color: #fff;
	font-size: .74em;
	line-height: 1.35;
	text-align: center;
	opacity: 0;
	transition: opacity .18s ease;
}

/* Sans image, l'invite est toujours lisible sur fond clair */
.cc-drop:not(.has-image) .cc-drop-hint {
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: none;
	color: var(--cc-form-muted);
	opacity: 1;
}

.cc-drop.has-image:hover .cc-drop-hint,
.cc-drop:focus-within .cc-drop-hint {
	opacity: 1;
}

.cc-kept {
	margin: 7px 0 0;
	font-size: .78em;
	font-weight: 600;
	color: #059669;
}

.cc-sticker-note {
	padding: 10px 12px;
	border-radius: 8px;
	border-left: 3px solid #a855f7;
	background: rgba(168, 85, 247, .08);
	font-size: .82em;
}

.cc-format-note {
	margin-top: 12px;
	font-size: .76em;
	line-height: 1.45;
	color: var(--cc-form-muted);
}

/* =============================================================
 * CHAMPS
 * ============================================================= */

.cc-fieldset {
	margin: 0 0 22px;
	padding: 18px 20px;
	border: 1px solid var(--cc-form-line);
	border-radius: 12px;
	background: var(--cc-form-surface);
}

.cc-fieldset legend {
	padding: 0 8px;
	font-size: .82em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--cc-form-muted);
}

.cc-fieldset-help {
	margin: 0 0 16px;
	font-size: .85em;
	color: var(--cc-form-muted);
}

.cc-field {
	margin-bottom: 16px;
	min-width: 0;
}

.cc-field:last-child {
	margin-bottom: 0;
}

.cc-field label {
	display: block;
	margin-bottom: 5px;
	font-size: .88em;
	font-weight: 600;
}

.cc-field label em {
	color: #ef4444;
	font-style: normal;
}

.cc-field input[type="text"],
.cc-field input[type="url"],
.cc-field input[type="number"],
.cc-field select,
.cc-field textarea {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--cc-form-line);
	border-radius: 8px;
	background: #fff;
	color: var(--cc-form-ink);
	font: inherit;
	transition: border-color .15s ease, box-shadow .15s ease;
}

@media (prefers-color-scheme: dark) {
	.cc-field input,
	.cc-field select,
	.cc-field textarea {
		background: rgba(255, 255, 255, .06);
	}
}

.cc-field input:focus,
.cc-field select:focus,
.cc-field textarea:focus {
	outline: none;
	border-color: var(--cc-form-accent);
	box-shadow: 0 0 0 3px rgba(59, 130, 246, .16);
}

.cc-field textarea {
	resize: vertical;
	min-height: 90px;
}

.cc-field small {
	display: block;
	margin-top: 5px;
	font-size: .78em;
	line-height: 1.4;
	color: var(--cc-form-muted);
}

.cc-mono {
	font-family: ui-monospace, Menlo, Consolas, monospace !important;
	letter-spacing: .06em;
	text-transform: uppercase;
}

/* Champs cote a cote */
.cc-field-row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
	margin-bottom: 16px;
}

.cc-field-row-3 {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cc-field-row .cc-field {
	margin-bottom: 0;
}

@media (max-width: 560px) {
	.cc-field-row,
	.cc-field-row-3 {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Boutons radio en cartes cliquables */
.cc-choice {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 10px;
}

.cc-choice-item {
	display: flex;
	align-items: center;
	gap: 9px;
	margin: 0;
	padding: 11px 14px;
	border: 1px solid var(--cc-form-line);
	border-radius: 9px;
	background: #fff;
	font-weight: 400 !important;
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease;
}

@media (prefers-color-scheme: dark) {
	.cc-choice-item { background: rgba(255, 255, 255, .04); }
}

.cc-choice-item:hover {
	border-color: var(--cc-form-accent);
}

.cc-choice-item:has(input:checked) {
	border-color: var(--cc-form-accent);
	background: rgba(59, 130, 246, .09);
}

.cc-choice-item input {
	margin: 0;
	flex: 0 0 auto;
}

.cc-choice-item span {
	font-size: .88em;
}

/* =============================================================
 * ACTIONS
 * ============================================================= */

.cc-form-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding-top: 4px;
}

/* =============================================================
 * SUGGESTIONS DE DOUBLONS
 * ============================================================= */

.cc-search-results {
	margin-top: 9px;
	padding: 11px 13px;
	border: 1px solid rgba(245, 158, 11, .35);
	border-radius: 9px;
	background: rgba(245, 158, 11, .07);
}

.cc-search-title {
	margin: 0 0 8px;
	font-size: .82em;
	font-weight: 700;
	color: #b45309;
}

.cc-search-results ul {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cc-search-results li a {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 5px 10px;
	border-radius: 7px;
	background: rgba(255, 255, 255, .9);
	font-size: .82em;
	text-decoration: none;
	color: inherit;
}

.cc-search-results li a:hover {
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

.cc-search-results li img {
	width: 22px;
	aspect-ratio: 64 / 89;
	object-fit: cover;
	border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.cc-drop,
	.cc-drop-hint,
	.cc-field input,
	.cc-choice-item {
		transition: none;
	}
}
