/* ── Module: Contacts ─────────────────────────────────────────────────────── */

/* Toolbar */
.contacts-toolbar {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	margin-bottom: var(--sp-4);
	flex-wrap: wrap;
}
.contacts-toolbar__left {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	flex-wrap: wrap;
	flex: 1;
}
.contacts-filter-wrap {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
}

/* Bulk bar */
.contacts-bulk-bar {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--transition-fast);
}
.contacts-bulk-bar.is-visible {
	opacity: 1;
	pointer-events: auto;
}
#contacts-sel-label {
	font-size: var(--text-sm);
	font-weight: var(--weight-medium);
	color: var(--text-primary);
}

/* Table */
.contacts-table th,
.contacts-table td { vertical-align: middle; }

.contacts-table .col-check { width: 40px; }

/* Custom checkbox */
.contacts-table .col-check input[type="checkbox"],
.csv-import-selall input[type="checkbox"],
.csv-import-table input[type="checkbox"] {
	-webkit-appearance: none !important;
	appearance: none !important;
	width: 20px !important;
	height: 20px !important;
	min-height: 0 !important;
	padding: 0 !important;
	border: 2px solid var(--border-input) !important;
	border-radius: var(--radius-sm) !important;
	background: var(--bg-card) !important;
	background-color: var(--bg-card) !important;
	box-shadow: none !important;
	cursor: pointer;
	position: relative;
	transition: background var(--transition-fast), border-color var(--transition-fast);
	flex-shrink: 0;
	margin: 0;
	display: inline-block;
}
.contacts-table .col-check input[type="checkbox"]:checked,
.csv-import-selall input[type="checkbox"]:checked,
.csv-import-table input[type="checkbox"]:checked {
	background: #1C1D25 !important;
	background-color: #1C1D25 !important;
	border-color: #1C1D25 !important;
}
.contacts-table .col-check input[type="checkbox"]:checked::after,
.csv-import-selall input[type="checkbox"]:checked::after,
.csv-import-table input[type="checkbox"]:checked::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 6px;
	width: 5px;
	height: 9px;
	border: solid #ffffff;
	border-width: 0 2.5px 2.5px 0;
	transform: rotate(45deg);
}
[data-theme="dark"] .contacts-table .col-check input[type="checkbox"] {
	border-color: var(--border-input) !important;
	background: var(--bg-input) !important;
	background-color: var(--bg-input) !important;
}
[data-theme="dark"] .contacts-table .col-check input[type="checkbox"]:checked,
[data-theme="dark"] .csv-import-selall input[type="checkbox"]:checked,
[data-theme="dark"] .csv-import-table input[type="checkbox"]:checked {
	background: #ffffff !important;
	background-color: #ffffff !important;
	border-color: #ffffff !important;
}
[data-theme="dark"] .contacts-table .col-check input[type="checkbox"]:checked::after,
[data-theme="dark"] .csv-import-selall input[type="checkbox"]:checked::after,
[data-theme="dark"] .csv-import-table input[type="checkbox"]:checked::after {
	border-color: #1C1D25;
}

.contact-row.is-sel { background: var(--bg-hover); }

.contact-name-cell strong {
	display: block;
	font-weight: var(--weight-semibold);
}
.contact-country-label {
	font-size: var(--text-xs);
	color: var(--text-muted);
	margin-top: 1px;
	display: block;
}

/* Size badges */
.contact-sizes-cell { white-space: nowrap; }
.size-badge {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-1);
	padding: 3px 7px;
	border-radius: var(--radius-sm);
	font-size: var(--text-xs);
	font-weight: var(--weight-semibold);
	margin-right: 3px;
	vertical-align: middle;
}
.size-badge svg { width: 12px; height: 12px; flex-shrink: 0; }

.size-badge--upper { background: #1C1D25; color: #ffffff; }
.size-badge--lower { background: #1C1D25; color: #ffc107; }
.size-badge--shoe  { background: #1C1D25; color: #2dd4bf; }
[data-theme="dark"] .size-badge--upper { background: var(--bg-hover); color: var(--text-primary); }
[data-theme="dark"] .size-badge--lower { background: var(--bg-hover); color: #ffc107; }
[data-theme="dark"] .size-badge--shoe  { background: var(--bg-hover); color: #2dd4bf; }

/* Tag chips (in table) */
.contact-tag-chip {
	display: inline-block;
	padding: 2px 9px;
	border-radius: var(--radius-pill);
	background: var(--color-green-light);
	border: 1px solid #bbf7d0;
	color: var(--color-green-dark);
	font-size: var(--text-xs);
	margin-right: var(--sp-1);
}

/* Edit button */
.contact-actions-cell { width: var(--sp-12); text-align: right; }
.btn-edit-contact {
	background: none;
	border: none;
	cursor: pointer;
	padding: 5px;
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	transition: color var(--transition-fast), background var(--transition-fast);
}
.btn-edit-contact:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Empty state */
.contacts-empty {
	padding: var(--sp-12) var(--sp-6);
	text-align: center;
	color: var(--text-muted);
}

/* ── Contact Popup ────────────────────────────────────────────────────────── */
.contact-popup .rt-popup__body { padding: 0; }

.contact-popup__body {
	overflow-y: auto;
	max-height: calc(80vh - 130px);
}

/* Sections */
.contact-section {
	padding: var(--sp-5) var(--sp-6);
	border-bottom: 1px solid var(--border-color);
}
.contact-section:last-child { border-bottom: none; }
.contact-section--dark {
	background: #1C1D25;
	color: #ffffff;
	margin-left: calc(-1 * var(--sp-6));
	margin-right: calc(-1 * var(--sp-6));
	padding-left: calc(var(--sp-6) * 2);
	padding-right: calc(var(--sp-6) * 2);
}
.contact-section--dark .form-label { color: rgba(255,255,255,.7); }
.contact-section--dark .form-input,
.contact-section--dark select.form-input {
	background: rgba(255,255,255,.08);
	border-color: rgba(255,255,255,.15);
	color: #000;
}
.contact-section--dark .form-input option { background: #1C1D25; }

/* Dark mode: accent section becomes a subtle elevated surface instead */
[data-theme="dark"] .contact-section--dark {
	background: var(--bg-subtle);
	color: var(--text-primary);
}
[data-theme="dark"] .contact-section--dark .form-label {
	color: var(--text-muted);
}
[data-theme="dark"] .contact-section--dark .form-input,
[data-theme="dark"] .contact-section--dark select.form-input {
	background: var(--bg-input);
	border-color: var(--border-input);
	color: var(--text-primary);
}
[data-theme="dark"] .contact-section--dark .form-input option {
	background: var(--bg-card);
}

.contact-section__label {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: var(--text-sm);
	font-weight: var(--weight-semibold);
	margin-bottom: var(--sp-4);
	color: inherit;
}
.contact-section--dark .contact-section__label { color: inherit; }

/* Form grid */
.contact-form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px var(--sp-4);
}
.form-field--full { grid-column: 1 / -1; }

@media (max-width: 640px) {
	/* Stack form fields one per row, tighten section padding */
	.contact-form-grid { grid-template-columns: 1fr; }
	/* Drop the outer card padding on mobile — each section owns its padding */
	.ea-card { padding: 0; }
	.contact-section { padding: var(--sp-4); }
	/* Dark section no longer needs to break out of card padding (there isn't any) */
	.contact-section--dark {
		margin-left: 0;
		margin-right: 0;
		padding-left: var(--sp-4);
		padding-right: var(--sp-4);
	}
}

.form-label {
	display: block;
	font-size: var(--text-2xs);
	font-weight: var(--weight-semibold);
	letter-spacing: .5px;
	text-transform: uppercase;
	color: var(--text-muted);
	margin-bottom: 5px;
}
.form-label--icon {
	display: flex;
	align-items: center;
	gap: 5px;
}

/* Popup footer */
.rt-popup__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--sp-4) var(--sp-6);
	border-top: 1px solid var(--border-color);
}
.rt-popup__footer-actions {
	display: flex;
	gap: var(--sp-2);
}
.btn-danger {
	color: var(--color-red) !important;
	border-color: transparent !important;
}
.btn-danger:hover { background: var(--color-red-light) !important; }

/* Tags in popup */
.applied-tags-wrap {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	min-height: var(--sp-8);
	padding: 6px var(--sp-2);
	border: 1px solid var(--border-color);
	border-radius: var(--radius-md);
	background: var(--bg-subtle);
}
.tag-chip--applied {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 10px;
	border-radius: var(--radius-pill);
	background: var(--color-blue-light);
	border: 1px solid #bfdbfe;
	color: var(--color-blue-dark);
	font-size: var(--text-xs);
	font-weight: var(--weight-medium);
	cursor: default;
}
.tag-chip__remove {
	cursor: pointer;
	font-size: var(--text-base);
	line-height: 1;
	opacity: .6;
}
.tag-chip__remove:hover { opacity: 1; }

.existing-tags-wrap {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.tag-chip--existing {
	padding: var(--sp-1) var(--sp-3);
	border-radius: var(--radius-pill);
	background: var(--color-green-light);
	border: 1px solid #bbf7d0;
	color: var(--color-green-dark);
	font-size: var(--text-xs);
	cursor: pointer;
	transition: background .12s, border-color .12s;
}
.tag-chip--existing:hover { background: var(--color-green-light); border-color: #86efac; }
.tag-chip--existing.is-active { background: var(--color-green-dark); color: var(--text-inverted); border-color: var(--color-green-dark); }

.tag-chip--new {
	padding: var(--sp-1) var(--sp-3);
	border-radius: var(--radius-pill);
	background: none;
	border: 1px dashed var(--border-input);
	color: var(--text-muted);
	font-size: var(--text-xs);
	cursor: pointer;
	transition: border-color .12s;
}
.tag-chip--new:hover { border-color: var(--text-primary); color: var(--text-primary); }

.text-muted { color: var(--text-muted); }

/* ── Size Summary ─────────────────────────────────────────────────────────── */
.contacts-size-summary {
	margin-top: var(--sp-6);
	padding: 0;
	overflow: hidden;
}

.size-summary__heading {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	padding: var(--sp-4) var(--sp-5);
	font-size: var(--text-sm);
	font-weight: var(--weight-bold);
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--text-muted);
	border-bottom: 1px solid var(--border-color);
}

.size-summary__group {
	padding: var(--sp-5);
	border-bottom: 1px solid var(--border-color);
}
.size-summary__group:last-child { border-bottom: none; }

.size-summary__group-header {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin-bottom: var(--sp-4);
}
.size-summary__gender {
	font-size: 15px;
	font-weight: var(--weight-bold);
	color: var(--text-primary);
}
.size-summary__count {
	font-size: var(--text-xs);
	color: var(--text-muted);
}

.size-summary__cols {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--sp-6);
}

.size-summary__col-label {
	margin-bottom: var(--sp-3);
	font-size: var(--text-2xs);
}

.size-summary__rows { display: flex; flex-direction: column; gap: 6px; }

.size-summary__row {
	display: grid;
	grid-template-columns: 36px 1fr 28px;
	align-items: center;
	gap: var(--sp-2);
}
.size-summary__size {
	font-size: var(--text-xs);
	font-weight: var(--weight-bold);
	color: var(--text-primary);
	text-align: left;
}
.size-summary__bar {
	display: block;
	height: 6px;
	background: var(--border-color);
	border-radius: 99px;
	overflow: hidden;
}
.size-summary__bar span {
	display: block;
	height: 100%;
	background: var(--color-primary);
	border-radius: 99px;
	transition: width .3s ease;
}
.size-summary__num {
	font-size: var(--text-2xs);
	font-weight: var(--weight-semibold);
	color: var(--text-muted);
	text-align: right;
}
.size-summary__empty {
	font-size: var(--text-sm);
	color: var(--text-muted);
	margin: 0;
}

@media (max-width: 600px) {
	.size-summary__cols { grid-template-columns: 1fr; gap: var(--sp-4); }
}

/* ── CSV Import Preview Popup ───────────────────────────────────────────────── */
.rt-popup--xl { max-width: 900px; width: 96vw; }
.csv-import-popup__body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }

.csv-import-toolbar {
	display: flex;
	align-items: center;
	gap: var(--sp-4);
	padding: var(--sp-3) var(--sp-6);
	border-bottom: 1px solid var(--border-color);
	flex-shrink: 0;
	flex-wrap: wrap;
}
.csv-import-selall {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	font-size: var(--text-sm);
	font-weight: var(--weight-medium);
	cursor: pointer;
	user-select: none;
}
.csv-import-count {
	font-size: var(--text-sm);
	color: var(--text-muted);
	margin-left: auto;
}

.csv-import-table-wrap {
	overflow: auto;
	flex: 1;
	min-height: 0;
	max-height: 52vh;
}
.csv-import-table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--text-sm);
}
.csv-import-table thead th {
	position: sticky;
	top: 0;
	background: var(--bg-subtle);
	padding: 10px 14px;
	text-align: left;
	font-size: var(--text-2xs);
	font-weight: var(--weight-bold);
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--text-muted);
	border-bottom: 1px solid var(--border-color);
	white-space: nowrap;
}
.csv-import-table tbody tr { border-bottom: 1px solid var(--border-color); }
.csv-import-table tbody tr:last-child { border-bottom: none; }
.csv-import-table tbody tr:hover { background: var(--bg-subtle); }
.csv-import-table tbody td { padding: 9px 14px; color: var(--text-primary); vertical-align: middle; white-space: nowrap; }
.csv-import-table .csv-import-table__cb { width: 36px; text-align: center; padding-left: var(--sp-4); }
