/* Container and base styles */
.table-container {
	overflow: hidden;
	container-type: inline-size;
	container-name: table;
	gap: clamp(0.25rem, 1cqw, 0.5rem);
	display: flex;
	flex-direction: column;
}

.table-wrapper {
	overflow-x: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--color-gray-300) transparent;
}

.data-table {
	width: 100%;
	border-collapse: collapse;
	font-family: var(--font-atkinson);
	font-size: clamp(0.625rem, 1.5cqw + 0.4rem, 0.75rem);
	line-height: 1.2;
}

/* Typography styles */
.table-title {
	font-weight: 700;
	color: var(--color-foreground);
	line-height: 1.25;
	font-family: var(--font-atkinson);
	letter-spacing: -0.025em;
}

.table-subtitle {
	color: var(--color-gray-600);
	max-width: 600px;
	text-wrap: balance;
	line-height: 1.4;
	font-family: var(--font-atkinson);
}

.table-source {
	font-size: clamp(0.5625rem, 1cqw + 0.4rem, 0.6875rem);
	color: var(--color-gray-500);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	padding-top: clamp(0.25rem, 1cqw, 0.5rem);
	font-family: var(--font-atkinson);
	font-weight: 600;
}

/* Cell styles */
.table-cell {
	padding: clamp(0.2rem, 0.9cqw, 0.35rem) clamp(0.35rem, 1.1cqw, 0.45rem);
	font-size: clamp(0.65rem, 1.2cqw + 0.4rem, 0.75rem);
	color: var(--color-sepia-brown);
	vertical-align: middle;
	border-bottom: 1px solid var(--color-sepia-dark);
	font-family: var(--font-atkinson);
	line-height: 1.25;
	transition: background-color 0.15s cubic-bezier(0.075, 0.82, 0.165, 1);
}

.table-cell.numeric {
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-weight: 500;
}

.table-cell.color-coded {
	font-weight: 550;
	position: relative;
}

.table-cell.high-contrast {
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Header styles */
.table-head {
	background: var(--color-sepia-light);
}

.table-header-cell {
	padding: clamp(0.1875rem, 0.8cqw, 0.25rem) clamp(0.25rem, 1cqw, 0.375rem);
	text-align: left;
	font-size: clamp(0.5rem, 1cqw + 0.35rem, 0.625rem);
	font-weight: 700;
	color: var(--color-sepia-brown);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-family: var(--font-sans);
	line-height: 1.1;
	vertical-align: bottom;
	border-bottom: none;
}

.table-header-cell.numeric {
	text-align: right;
}

.table-header-cell.sortable {
	cursor: pointer;
	transition: background-color 0.15s ease;
	user-select: none;
}

.table-header-cell.sortable:hover {
	background: var(--color-sepia-med);
}

.table-header-cell.active {
	font-weight: 900;
}

/* Row styles */
.table-row {
	transition: background-color 0.15s ease;
}

.table-row:hover {
	background: var(--color-sepia-med);
}

.table-row.even:hover {
	background: var(--color-sepia-med);
}

/* Column group styles */
.group-header-empty {
	border: none;
	padding: 0;
	width: auto;
}

.group-header-cell {
	padding: clamp(0.1875rem, 0.8cqw, 0.275rem) clamp(0.3125rem, 1.2cqw, 0.5rem);
	text-align: center;
	font-size: clamp(0.5rem, 1cqw + 0.35rem, 0.625rem);
	font-weight: 600;
	color: var(--color-sepia-brown);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-family: var(--font-sans);
	border-bottom: 1px solid var(--color-sepia-dark);
	line-height: 1.1;
	position: relative;
}

.column-header-row {
	border-bottom: 2px solid var(--color-sepia-brown);
}

/* Links and interactive elements */
.cell-link {
	color: var(--color-sepia-brown);
	text-decoration: none;
	transition: color 0.15s ease;
}

.cell-link:hover {
	color: var(--color-red);
	text-decoration: underline;
}

.cell-content.bold,
.cell-link.bold {
	font-weight: 650;
}

/* Header content layout */
.header-content {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: clamp(0.1875rem, 0.6cqw, 0.25rem);
	min-width: 0;
}

.header-content .header-label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.table-header-cell.numeric .header-content {
	justify-content: flex-end;
}

.table-header-cell.numeric .header-label {
	flex: none;
}

/* Sort icon styles */
.sort-icon {
	transition: opacity 0.15s ease;
	flex-shrink: 0;
	width: clamp(10px, 2.5cqw, 12px);
	height: clamp(10px, 2.5cqw, 12px);
}

.table-header-cell.sortable:hover .sort-icon {
	opacity: 1 !important;
}

/* Container query breakpoints - Mobile First */
@container table (max-width: 400px) {
	.data-table {
		font-size: clamp(0.5rem, 1.2cqw + 0.35rem, 0.625rem);
	}

	.table-source {
		font-size: clamp(0.5rem, 0.8cqw + 0.35rem, 0.575rem);
	}

	.table-cell {
		padding: clamp(0.3rem, 1cqw, 0.4rem) clamp(0.4rem, 1.2cqw, 0.5rem);
		font-size: clamp(0.75rem, 1.3cqw + 0.4rem, 0.85rem);
	}

	.group-header-cell {
		padding: clamp(0.125rem, 0.6cqw, 0.1875rem) clamp(0.25rem, 1cqw, 0.3125rem);
		font-size: clamp(0.75rem, 1.3cqw + 0.4rem, 0.85rem);
		letter-spacing: 0.08em;
	}

	.table-header-cell {
		padding: clamp(0.125rem, 0.6cqw, 0.1875rem) clamp(0.1875rem, 0.8cqw, 0.25rem);
		font-size: clamp(0.75rem, 1.3cqw + 0.4rem, 0.85rem);
		letter-spacing: 0.04em;
	}

	.header-content {
		gap: clamp(0.125rem, 0.5cqw, 0.1875rem);
	}

	.sort-icon {
		width: clamp(8px, 2cqw, 10px);
		height: clamp(8px, 2cqw, 10px);
	}
}

@container table (max-width: 280px) {
	.table-container {
		padding: clamp(0.375rem, 1.5cqw, 0.625rem);
	}

	.table-title {
		font-size: clamp(0.75rem, 2cqw + 0.4rem, 0.875rem);
		line-height: 1.1;
	}

	.table-subtitle {
		font-size: clamp(0.55rem, 1cqw + 0.4rem, 0.65rem);
	}

	.data-table {
		font-size: clamp(0.45rem, 1cqw + 0.3rem, 0.55rem);
	}

	.table-cell {
		padding: clamp(0.25rem, 0.8cqw, 0.35rem) clamp(0.35rem, 1cqw, 0.45rem);
		font-size: clamp(0.7rem, 1.1cqw + 0.35rem, 0.8rem);
		line-height: 1.25;
	}

	.group-header-cell {
		padding: clamp(0.1rem, 0.5cqw, 0.125rem) clamp(0.1875rem, 0.8cqw, 0.25rem);
		font-size: clamp(0.375rem, 0.6cqw + 0.2rem, 0.4375rem);
		letter-spacing: 0.06em;
	}

	.table-header-cell {
		padding: clamp(0.1rem, 0.5cqw, 0.125rem) clamp(0.125rem, 0.6cqw, 0.1875rem);
		font-size: clamp(0.375rem, 0.6cqw + 0.2rem, 0.4375rem);
		letter-spacing: 0.03em;
	}

	.header-content {
		gap: clamp(0.1rem, 0.4cqw, 0.125rem);
	}

	.sort-icon {
		width: clamp(6px, 1.5cqw, 8px);
		height: clamp(6px, 1.5cqw, 8px);
	}

	.group-header-cell:not(:last-child) {
		margin-right: clamp(0.125rem, 0.4cqw, 0.1875rem);
		border-right: clamp(0.25rem, 1cqw, 0.375rem) solid var(--color-sepia-light);
	}
}

/* Compact variant styles */
.table-container.compact {
	margin-bottom: clamp(1rem, 3cqw, 1.5rem);
}

.table-container.compact .data-table {
	font-size: clamp(0.625rem, 1.2cqw + 0.4rem, 0.75rem);
	line-height: 1.25;
}

.table-container.compact .table-source {
	font-size: clamp(0.5rem, 1cqw + 0.375rem, 0.625rem);
	padding: clamp(0.375rem, 1cqw, 0.5rem) clamp(0.75rem, 2.5cqw, 1.25rem);
}

.table-container.compact .table-cell {
	padding: clamp(0.25rem, 1.2cqw, 0.5rem) clamp(0.375rem, 1.8cqw, 0.75rem);
	font-size: clamp(0.625rem, 1.2cqw + 0.4rem, 0.75rem);
	line-height: 1.25;
}

.table-container.compact .table-row:hover {
	background: rgba(249, 250, 251, 0.6);
}

.table-container.compact .group-header-cell {
	padding: clamp(0.1875rem, 0.8cqw, 0.25rem) clamp(0.25rem, 1cqw, 0.375rem);
	font-size: clamp(0.4375rem, 0.9cqw + 0.3rem, 0.5625rem);
}

.table-container.compact .table-header-cell {
	padding: clamp(0.125rem, 0.7cqw, 0.1875rem) clamp(0.1875rem, 0.9cqw, 0.3125rem);
	font-size: clamp(0.4375rem, 0.9cqw + 0.3rem, 0.5625rem);
	letter-spacing: 0.025em;
}
