/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "Avenir Next", "Segoe UI", sans-serif;
	background: #f5f7fb;
	color: #1b2430;
}

a {
	color: #0b5ad7;
}

.top-nav {
	background: #101a2b;
	color: #fff;
}

.top-nav-inner {
	max-width: 1100px;
	margin: 0 auto;
	padding: 0.9rem 1rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.top-nav a {
	color: #fff;
	text-decoration: none;
}

.top-nav-links {
	display: flex;
	gap: 1rem;
}

.brand {
	font-weight: 700;
}

.page {
	max-width: 1100px;
	margin: 1.2rem auto;
	padding: 0 1rem 2rem;
}

.narrow {
	max-width: 700px;
}

.page-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
}

.actions {
	display: flex;
	gap: 0.6rem;
}

.btn {
	display: inline-block;
	text-decoration: none;
	border: none;
	background: #0b5ad7;
	color: #fff;
	padding: 0.55rem 0.9rem;
	border-radius: 0.45rem;
	font-size: 0.95rem;
	cursor: pointer;
}

.btn-secondary {
	background: #5f6d82;
}

.btn-danger {
	background: #b42318;
}

.stack {
	display: grid;
	gap: 1rem;
}

label {
	display: block;
	margin-bottom: 0.3rem;
	font-weight: 600;
}

input,
select {
	width: 100%;
	padding: 0.45rem 0.55rem;
	border: 1px solid #cfd5e2;
	border-radius: 0.4rem;
	background: #fff;
}

.split-2 {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 1rem;
}

.data-table {
	width: 100%;
	border-collapse: collapse;
	background: #fff;
	border-radius: 0.5rem;
	overflow: hidden;
}

.data-table th,
.data-table td {
	border-bottom: 1px solid #e6e9f2;
	padding: 0.6rem 0.55rem;
	text-align: left;
	font-size: 0.92rem;
}

.data-table th {
	background: #eef2fb;
}

.compact input,
.compact select {
	min-width: 4.7rem;
}

.table-wrap {
	overflow-x: auto;
}

.stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 0.8rem;
	margin-bottom: 1rem;
}

.stat-card {
	background: #fff;
	border-radius: 0.6rem;
	padding: 0.8rem;
	border: 1px solid #e5e9f2;
}

.stat-card--photo {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.4rem;
	overflow: hidden;
}

.stat-card--scoreboard {
	padding: 0.8rem 1rem;
}

.scoreboard-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.4rem 0;
	border-radius: 0.3rem;
}

.scoreboard-row--winner .scoreboard-team,
.scoreboard-row--winner .scoreboard-score {
	color: #1a56a0;
	font-weight: 800;
}

.scoreboard-team {
	font-size: 1rem;
	font-weight: 600;
	color: #46536a;
}

.scoreboard-score {
	font-size: 1.6rem;
	font-weight: 700;
	color: #46536a;
	min-width: 2.5rem;
	text-align: right;
}

.scoreboard-divider {
	height: 1px;
	background: #e5e9f2;
	margin: 0.2rem 0;
}

.stats-photo-thumb-link {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

.stats-photo-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 0.3rem;
	display: block;
}

.photo-lightbox {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.photo-lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.75);
}

.photo-lightbox-content {
	position: relative;
	z-index: 1;
	max-width: 90vw;
	max-height: 90vh;
}

.photo-lightbox-img {
	max-width: 90vw;
	max-height: 90vh;
	border-radius: 0.4rem;
	display: block;
}

.photo-lightbox-close {
	position: absolute;
	top: -2rem;
	right: 0;
	background: none;
	border: none;
	color: #fff;
	font-size: 2rem;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.stat-card h2 {
	font-size: 0.95rem;
	margin: 0;
	color: #46536a;
}

.stat-card p {
	margin: 0.4rem 0 0;
	font-size: 1.4rem;
	font-weight: 700;
}

.hint {
	margin-top: -0.5rem;
	color: #5f6d82;
}

.empty-state {
	background: #fff;
	border: 1px dashed #c5cede;
	border-radius: 0.5rem;
	padding: 1rem;
}

.alert {
	background: #fff5f5;
	color: #7a1a1a;
	border: 1px solid #f0caca;
	border-radius: 0.5rem;
	padding: 0.8rem;
}

.flash {
	max-width: 1100px;
	margin: 1rem auto;
	padding: 0.75rem 1rem;
	border-radius: 0.45rem;
}

.flash-notice {
	background: #eaf7ee;
	border: 1px solid #b8e0c4;
}

.flash-alert {
	background: #fff1f1;
	border: 1px solid #efc6c6;
}

.photo-block {
	margin: 1rem 0;
}

.stats-photo {
	max-width: 100%;
	border-radius: 0.6rem;
	border: 1px solid #d8deea;
}

.confidence-legend {
	display: flex;
	gap: 0.6rem;
	margin: 0.4rem 0 1rem;
}

.confidence-chip {
	display: inline-block;
	padding: 0.2rem 0.55rem;
	border-radius: 0.9rem;
	font-size: 0.78rem;
	font-weight: 600;
	border: 1px solid transparent;
}

.confidence-chip-high {
	background: #edf8f0;
	border-color: #b8e3c4;
	color: #205c34;
}

.confidence-chip-low {
	background: #fff1f1;
	border-color: #efb6b6;
	color: #7b1f1f;
}

.ocr-high-confidence {
	border-color: #b8e3c4;
	background: #fbfffc;
}

.ocr-low-confidence {
	border-color: #efb6b6;
	background: #fff5f5;
}

.ocr-debug {
	white-space: pre-wrap;
	word-break: break-word;
	background: #101a2b;
	color: #e9eef8;
	padding: 0.75rem;
	border-radius: 0.5rem;
	font-size: 0.82rem;
	overflow-x: auto;
}

/* Player page */

.player-header {
	align-items: flex-end;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid #dfe5f1;
	margin-bottom: 1rem;
}

.player-title {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0;
}

.player-initials {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.15rem 0.5rem;
	border-radius: 999px;
	font-size: 0.85rem;
	font-weight: 700;
	background: #e8f0fe;
	color: #174ea6;
	letter-spacing: 0.03em;
}

.player-section {
	margin-top: 1.1rem;
}

.section-title {
	margin: 0 0 0.6rem;
	font-size: 1.02rem;
	color: #2a3447;
}

.stats-grid--record,
.stats-grid--averages {
	grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
	margin-bottom: 0;
}

.stats-grid--record .stat-card,
.stats-grid--averages .stat-card {
	padding: 0.7rem;
	box-shadow: 0 1px 0 rgba(9, 30, 66, 0.08);
}

.stats-grid--averages .stat-card h2 {
	font-size: 0.82rem;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.stats-grid--averages .stat-card p {
	font-size: 1.22rem;
	margin-top: 0.35rem;
}

.player-table-wrap {
	border: 1px solid #dde4f0;
	border-radius: 0.65rem;
	background: #fff;
}

.player-stats-table {
	font-variant-numeric: tabular-nums;
	min-width: 920px;
}

.player-stats-table th {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #e7eefb;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #30415e;
}

.player-stats-table td {
	padding: 0.62rem 0.55rem;
	vertical-align: middle;
}

.player-stats-table th:nth-child(n+4),
.player-stats-table td:nth-child(n+4) {
	text-align: center;
}

.player-stats-table tbody tr:nth-child(odd) {
	background: #fbfcff;
}

.player-stats-table tbody tr:hover {
	background: #f2f6ff;
}

.player-stats-table .averages-row {
	background: #eef4ff;
	font-weight: 700;
}

.player-stats-table .averages-row:hover {
	background: #e7efff;
}

@media (max-width: 720px) {
	.player-title {
		flex-wrap: wrap;
	}

	.player-table-wrap {
		margin: 0 -0.2rem;
	}
}

/* ── Game form ────────────────────────────────────────────── */

.game-form {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.form-section {
	background: #fff;
	border: 1px solid #e0e5f0;
	border-radius: 0.6rem;
	padding: 1.25rem 1.5rem;
}

.form-section-title {
	font-size: 0.85rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #5f6d82;
	margin: 0 0 1rem;
}

.field {
	margin-bottom: 0.9rem;
}

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

.field label {
	display: block;
	font-size: 0.85rem;
	font-weight: 600;
	margin-bottom: 0.3rem;
	color: #3a4459;
}

.field input,
.field select {
	width: 100%;
	padding: 0.45rem 0.6rem;
	border: 1px solid #cfd5e2;
	border-radius: 0.4rem;
	background: #fff;
	font-size: 0.95rem;
}

.field--narrow {
	margin-bottom: 0;
}

.field--narrow label {
	font-size: 0.75rem;
	color: #5f6d82;
	margin-bottom: 0.2rem;
}

.field--narrow input {
	padding: 0.3rem 0.4rem;
	font-size: 0.9rem;
	text-align: center;
}

.field-hint {
	margin: 0.4rem 0 0;
	font-size: 0.83rem;
	color: #5f6d82;
}

.photo-upload-row {
	display: flex;
	align-items: flex-end;
	gap: 1rem;
}

.photo-upload-row .field {
	flex: 1;
	margin-bottom: 0;
}

.photo-upload-action {
	flex-shrink: 0;
	padding-bottom: 0.05rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	align-items: flex-start;
}

.ocr-engine-select {
	display: flex;
	gap: 1rem;
}

.players-section-toggle {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: none;
	border: none;
	font-size: 1rem;
	font-weight: 700;
	color: #2c3a50;
	cursor: pointer;
	padding: 0.5rem 0;
	width: 100%;
	text-align: left;
}

.players-section-toggle:hover {
	color: #1a56a0;
}

.players-toggle-icon {
	font-size: 0.85rem;
	color: #5f6d82;
}

.players-section-body {
	margin-top: 0.75rem;
}

.form-actions--players {
	margin-top: 1.5rem;
}

.ocr-engine-option {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	font-size: 0.85rem;
	color: #46536a;
	cursor: pointer;
}

.ocr-engine-badge {
	font-size: 0.7rem;
	font-weight: 600;
	background: #e8f0fe;
	color: #1a56a0;
	border-radius: 0.25rem;
	padding: 0.1rem 0.35rem;
}

.ocr-engine-badge--local {
	background: #e6f4ea;
	color: #1a6b35;
}

.ocr-model-select {
	font-size: 0.85rem;
	padding: 0.2rem 0.4rem;
	border: 1px solid #c5cede;
	border-radius: 0.25rem;
}

.ocr-source-label {
	font-size: 0.78rem;
	color: #5f6d82;
	margin: 0 0 0.5rem;
}

.team-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.25rem;
}

@media (max-width: 540px) {
	.team-grid {
		grid-template-columns: 1fr;
	}
}

.team-column--blue {
	border-left: 3px solid #3b82f6;
	padding-left: 0.75rem;
}

.team-column--red {
	border-left: 3px solid #ef4444;
	padding-left: 0.75rem;
}

.players-form {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.team-group {
	margin-bottom: 1.25rem;
}

.team-group:last-child {
	margin-bottom: 0;
}

.team-group-header {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 0.6rem;
	padding-bottom: 0.5rem;
	border-bottom: 2px solid;
	flex-wrap: wrap;
}

.team-group--blue .team-group-header {
	border-color: #3b82f6;
}

.team-group--red .team-group-header {
	border-color: #ef4444;
}

.team-group-name {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	min-width: 6rem;
}

.team-group--blue .team-group-name {
	color: #1d4ed8;
}

.team-group--red .team-group-name {
	color: #b91c1c;
}

.team-group-controls {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	flex: 1;
}

.team-group-controls select {
	flex: 1;
	min-width: 0;
	padding: 0.35rem 0.5rem;
	border: 1px solid #cfd5e2;
	border-radius: 0.4rem;
	background: #fff;
	font-size: 0.9rem;
}

.team-group-controls input[type="number"] {
	width: 5rem;
	padding: 0.35rem 0.5rem;
	border: 1px solid #cfd5e2;
	border-radius: 0.4rem;
	background: #fff;
	font-size: 0.9rem;
	text-align: center;
}

.player-stat-row {
	background: #f8f9fc;
	border: 1px solid #e0e5f0;
	border-radius: 0.5rem;
	padding: 1rem;
}

.player-stat-identity {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.player-stat-numbers {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
	gap: 0.5rem;
	padding: 0.75rem;
	background: #fff;
	border: 1px solid #e8ecf5;
	border-radius: 0.4rem;
	margin-bottom: 0.6rem;
}

.player-stat-remove {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.85rem;
	color: #5f6d82;
}

.player-stat-remove input[type="checkbox"] {
	width: auto;
}

.form-actions {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding-top: 0.25rem;
}

/* ── OCR loading overlay ──────────────────────────────────── */

#ocr-loading-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(16, 26, 43, 0.65);
	z-index: 9999;
	align-items: center;
	justify-content: center;
}

.ocr-loading-box {
	background: #fff;
	border-radius: 0.75rem;
	padding: 2.5rem 3rem;
	text-align: center;
	max-width: 360px;
	width: 90%;
	box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.ocr-spinner {
	width: 48px;
	height: 48px;
	border: 4px solid #e0e5f0;
	border-top-color: #0b5ad7;
	border-radius: 50%;
	animation: ocr-spin 0.8s linear infinite;
	margin: 0 auto 1.25rem;
}

@keyframes ocr-spin {
	to { transform: rotate(360deg); }
}

.ocr-loading-title {
	margin: 0 0 0.4rem;
	font-size: 1.1rem;
	font-weight: 700;
	color: #1b2430;
}

.ocr-loading-sub {
	margin: 0;
	font-size: 0.88rem;
	color: #5f6d82;
}

.players-row {
	background: #f9fafb;
}

.players-cell {
	padding: 0.4rem 0.55rem !important;
	font-size: 0.85rem;
}

.team-players {
	margin-top: 0.3rem;
	font-size: 0.85rem;
}

.text-muted {
	color: #7a8899;
}

/* Games Grid Layout */
.games-grid {
	display: flex;
	flex-direction: column;
	gap: 0;
	margin-bottom: 2rem;
}

.game-card {
	background: #fff;
	border-bottom: 1px solid #e6e9f2;
	overflow: visible;
	transition: background 0.2s ease;
	display: flex;
	flex-direction: column;
	padding: 0;
}

.game-card:last-child {
	border-bottom: none;
}

.game-card:hover {
	background: #fafbfc;
}

.game-card-header {
	background: transparent;
	padding: 1rem;
	border-bottom: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid #f0f2f7;
}

.game-date {
	font-weight: 600;
	color: #1b2430;
	font-size: 0.95rem;
}

.date-link {
	color: #0b5ad7;
	text-decoration: none;
	font-weight: 600;
}

.date-link:hover {
	text-decoration: underline;
}

.game-winner {
	background: transparent;
	padding: 0.3rem 0.8rem;
	border-radius: 0.3rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: #0b5ad7;
	border: 1px solid #d0dae8;
}

.game-card-body {
	padding: 0 1rem 1rem 1rem;
	flex-grow: 1;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
}

.team-section {
	margin-bottom: 0;
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.team-info {
	display: flex;
	justify-content: flex-start;
	align-items: baseline;
	margin-bottom: 0.3rem;
	gap: 1rem;
}

.team-name {
	font-weight: 600;
	color: #1b2430;
	font-size: 0.95rem;
}

.team-score {
	font-size: 1.4rem;
	font-weight: 700;
	color: #0b5ad7;
}

.team-players {
	margin-top: 0.2rem;
	font-size: 0.8rem;
	line-height: 1.4;
}

.vs-divider {
	text-align: center;
	color: #9ba7b5;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	padding: 0 1rem;
	margin: 0;
	letter-spacing: 0.1em;
}

.game-card-footer {
	background: transparent;
	padding: 0 1rem 1rem 1rem;
	border-top: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem;
}

.photo-badge {
	font-size: 0.8rem;
	color: #5f6d82;
	font-weight: 500;
}

.btn-sm {
	padding: 0.4rem 0.8rem;
	font-size: 0.8rem;
}

.btn-primary {
	background: #0b5ad7;
	color: #fff;
	border: none;
	padding: 0.75rem 1.5rem;
	border-radius: 0.4rem;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
	transition: background 0.3s ease;
}

.btn-primary:hover {
	background: #0a47ad;
}
