/**
 * Shared tables: base design + responsive fixed first column.
 * Uses container queries with media query fallback.
 * Wrapper classes are doubled so theme table rules do not win.
 *
 * Load after theme-reset (table reset) and design-tokens.
 *
 * @package BasketApiPro
 */

/* ===== Container Setup ===== */
.bapro-table-container.bapro-table-container {
	container-type: inline-size;
	container-name: bapro-table;
}

/* ===== Table Wrapper ===== */
.bapro-table-wrapper.bapro-table-wrapper {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.bapro-table-wrapper.bapro-table-wrapper::-webkit-scrollbar {
	height: 8px;
}

.bapro-table-wrapper.bapro-table-wrapper::-webkit-scrollbar-track {
	background: var(--bapro-grey, #f2f2f2);
}

.bapro-table-wrapper.bapro-table-wrapper::-webkit-scrollbar-thumb {
	background: #888;
	border-radius: 4px;
}

.bapro-table-wrapper.bapro-table-wrapper::-webkit-scrollbar-thumb:hover {
	background: #555;
}

/* ===== Neutral plugin base ===== */
.bapro-table-wrapper.bapro-table-wrapper table.bapro-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	min-width: 600px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--bapro-text, #1a2a34);
	table-layout: auto !important; /* Override theme's table-layout: fixed */
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table th,
.bapro-table-wrapper.bapro-table-wrapper .bapro-table td {
	padding: 8px 10px;
	border-bottom: 1px solid var(--bapro-grey, #f2f2f2);
	color: var(--bapro-text, #1a2a34);
	vertical-align: middle;
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table thead th {
	background: var(--bapro-grey, #f2f2f2);
	color: var(--bapro-black, #091f2c);
	font-weight: 600;
	text-align: center;
	white-space: nowrap;
	border-bottom: 1px solid var(--bapro-border, #00a3e0);
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table thead th:first-child,
.bapro-table-wrapper.bapro-table-wrapper .bapro-table tbody td:first-child,
.bapro-table-wrapper.bapro-table-wrapper .bapro-table tfoot td:first-child {
	text-align: left;
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table tbody td,
.bapro-table-wrapper.bapro-table-wrapper .bapro-table tfoot td {
	text-align: center;
	background: #fff;
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table--striped tbody tr:nth-child(even) td {
	background: var(--bapro-grey, #f2f2f2);
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table tr.ba-pro-boxscore-aggregate td,
.bapro-table-wrapper.bapro-table-wrapper .bapro-table tfoot td {
	background: #e8e8e8;
	font-weight: 600;
	border-bottom-color: #ddd;
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table tbody tr:last-child td {
	border-bottom-color: #ddd;
}

/* Compact tables that do not need a wide min-width (quarter scores, small comparisons) */
.bapro-table-wrapper.bapro-table-wrapper table.ba-pro-game-quarter-scores-table,
.bapro-table-wrapper.bapro-table-wrapper table.ba-pro-game-graphicstats-table {
	min-width: 0;
}

/* ===== Fixed First Column (Fallback for older browsers) ===== */
@media (max-width: 800px) {
	.bapro-table-wrapper.bapro-table-wrapper th:first-child,
	.bapro-table-wrapper.bapro-table-wrapper td:first-child {
		position: sticky;
		left: 0;
		background: #fff;
		z-index: 10;
		padding-right: 1em;
	}

	.bapro-table-wrapper.bapro-table-wrapper.is-scrolled th:first-child,
	.bapro-table-wrapper.bapro-table-wrapper.is-scrolled td:first-child {
		box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
	}

	.bapro-table-wrapper.bapro-table-wrapper .bapro-table thead th:first-child {
		background: var(--bapro-grey, #f2f2f2);
		z-index: 11;
	}

	.bapro-table-wrapper.bapro-table-wrapper .bapro-table--striped tbody tr:nth-child(even) td:first-child {
		background: var(--bapro-grey, #f2f2f2);
	}

	.bapro-table-wrapper.bapro-table-wrapper .bapro-table tr.ba-pro-boxscore-aggregate td:first-child,
	.bapro-table-wrapper.bapro-table-wrapper .bapro-table tfoot td:first-child {
		background: #e8e8e8;
		font-weight: 600;
	}
}

/* ===== Container Query (Modern browsers) ===== */
@container bapro-table (max-width: 800px) {
	.bapro-table-wrapper.bapro-table-wrapper th:first-child,
	.bapro-table-wrapper.bapro-table-wrapper td:first-child {
		position: sticky;
		left: 0;
		background: #fff;
		z-index: 10;
		padding-right: 1em;
	}

	.bapro-table-wrapper.bapro-table-wrapper.is-scrolled th:first-child,
	.bapro-table-wrapper.bapro-table-wrapper.is-scrolled td:first-child {
		box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
	}

	.bapro-table-wrapper.bapro-table-wrapper .bapro-table thead th:first-child {
		background: var(--bapro-grey, #f2f2f2);
		z-index: 11;
	}

	.bapro-table-wrapper.bapro-table-wrapper .bapro-table--striped tbody tr:nth-child(even) td:first-child {
		background: var(--bapro-grey, #f2f2f2);
	}

	.bapro-table-wrapper.bapro-table-wrapper .bapro-table tr.ba-pro-boxscore-aggregate td:first-child,
	.bapro-table-wrapper.bapro-table-wrapper .bapro-table tfoot td:first-child {
		background: #e8e8e8;
		font-weight: 600;
	}
}

/* ===== Enhanced sticky column sizing ===== */
.bapro-table-wrapper.bapro-table-wrapper th:first-child,
.bapro-table-wrapper.bapro-table-wrapper td:first-child {
	white-space: nowrap;
	min-width: 120px;
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table thead th:first-child {
	z-index: 11;
}

.bapro-table-wrapper.bapro-table-wrapper .bapro-table tfoot td:first-child {
	z-index: 10;
}
