/* ===============================
   Variables and reset
   =============================== */
:root {
	--footer-height: 64px;
	--black: #000000;
	--dark: #111111;
	--dark-mid: #1a1a1a;
	--dark-card: #161616;
	--gold: #f0a800;
	--gold-light: #f5c040;
	--gold-pale: #2e2000;
	--white: #f2f2f2;
	--gray: #888888;
	--gray-light: #2a2a2a;
	--success: #4caf50;
	--success-bg: #1a2e1a;
	--error: #e53935;
	--error-bg: #2e1a1a;
	--shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
	--radius: 8px;
}

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family:
		system-ui,
		-apple-system,
		'Segoe UI',
		sans-serif;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--white);
	background: var(--black);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	padding-bottom: var(--footer-height);
}

main {
	flex: 1;
}

a {
	color: var(--gold-light);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
	color: var(--gold);
}

/* ===============================
   Layout
   =============================== */
.container {
	max-width: 1060px;
	margin: 0 auto;
	padding: 0 1rem;
}

/* ===============================
   Header
   =============================== */
.site-header {
	background: var(--dark);
	border-bottom: 2px solid var(--gold);
	padding: 0.8rem 0;
}

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

.site-logo {
	display: flex;
	align-items: center;
}

.site-logo-img {
	height: 34px;
	width: auto;
	display: block;
}

.site-nav {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
}

.site-nav a {
	color: rgba(242, 242, 242, 0.7);
	font-size: 0.9rem;
	transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
	color: var(--gold);
	text-decoration: none;
}

/* ===============================
   Hero
   =============================== */
.hero {
	padding: 2.5rem 0 1.5rem;
	text-align: center;
}

.hero h1 {
	font-size: 2rem;
	font-weight: 800;
	color: var(--gold);
	margin-bottom: 0.4rem;
	text-shadow: 0 0 30px rgba(201, 152, 42, 0.3);
}

.hero p {
	color: var(--gray);
	font-size: 1.05rem;
}

/* ===============================
   Search bar + view controls (index.php)
   =============================== */
.search-bar {
	margin: 0 0 1.25rem;
}

.search-bar input[type='search'] {
	width: 100%;
	max-width: 480px;
	display: block;
	margin: 0 auto;
	padding: 0.6rem 1rem;
	background: var(--dark-card);
	border: 1px solid var(--gray-light);
	border-radius: 6px;
	color: var(--white);
	font-size: 0.95rem;
	outline: none;
	transition: border-color 0.15s;
}

.search-bar input[type='search']:focus {
	border-color: var(--gold);
}

.search-bar input[type='search']::placeholder {
	color: var(--gray);
}

.view-controls {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 1.25rem;
	flex-wrap: wrap;
}

.view-controls .search-bar {
	flex: 1;
	min-width: 180px;
	margin: 0;
}

.view-toggles {
	display: flex;
	gap: 0.5rem;
	flex-shrink: 0;
	align-items: center;
}

.view-controls .search-bar input[type='search'] {
	max-width: none;
	margin: 0;
}

/* ===============================
   Competition cards (index.php)
   =============================== */
.competitions-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 1.25rem;
	padding: 1rem 0 3rem;
}

.competition-card {
	background: var(--dark-card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	border-top: 3px solid var(--gold);
	display: flex;
	flex-direction: column;
	transition:
		box-shadow 0.2s,
		transform 0.2s;
}

.competition-card:hover {
	box-shadow: 0 6px 24px rgba(201, 152, 42, 0.2);
	transform: translateY(-2px);
}

.competition-card-body {
	padding: 1.25rem 1.25rem 1rem;
	flex: 1;
}

.competition-meta {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-bottom: 0.75rem;
}

.badge-date,
.badge-city {
	font-size: 0.78rem;
	padding: 0.2rem 0.6rem;
	border-radius: 20px;
	font-weight: 600;
}

.badge-date {
	background: var(--gold-pale);
	color: var(--gold-light);
	border: 1px solid var(--gold);
}

.badge-city {
	background: var(--gray-light);
	color: #bbb;
}

.competition-name {
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--gold);
	margin-bottom: 0.3rem;
	line-height: 1.3;
}

.competition-club {
	font-size: 0.88rem;
	color: var(--gray);
}

.competition-card-footer {
	padding: 0 1.25rem 1.25rem;
}

/* ===============================
   Results (wyniki.php)
   =============================== */
.results-header {
	padding: 2rem 0 1.25rem;
}

.results-header-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

.results-header h1 {
	font-size: 1.75rem;
	font-weight: 800;
	color: var(--gold);
	margin-bottom: 0.4rem;
}

.results-meta {
	color: var(--gray);
	font-size: 0.95rem;
}

/* ===============================
   View toggle (lista_startowa.php)
   =============================== */
.view-toggle {
	display: flex;
	border: 1px solid var(--gold);
	border-radius: 6px;
	overflow: hidden;
	flex-shrink: 0;
	align-self: center;
}

.view-toggle-btn {
	padding: 0.35rem 0.85rem;
	font-size: 0.85rem;
	font-family: inherit;
	background: transparent;
	color: var(--gold);
	border: none;
	border-right: 1px solid var(--gold);
	cursor: pointer;
	transition:
		background 0.15s,
		color 0.15s;
	line-height: 1.4;
}

.view-toggle-btn:last-child {
	border-right: none;
}

.view-toggle-btn.active {
	background: var(--gold);
	color: var(--black);
	font-weight: 600;
}

.view-toggle-btn:hover:not(.active) {
	background: var(--gold-pale);
}

.block {
	background: var(--dark-card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	margin-bottom: 1.75rem;
	overflow: hidden;
	max-width: 100%;
}

.block-header {
	background: var(--dark-mid);
	border-left: 4px solid var(--gold);
	color: var(--white);
	padding: 0.85rem 1.25rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.block-header h2 {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--gold);
	margin: 0;
}

.block-meta {
	display: flex;
	gap: 1rem;
	font-size: 0.85rem;
	color: #aaa;
	flex-wrap: wrap;
}

.table-wrapper {
	/* no horizontal scroll — table switches to cards on mobile */
}

.results-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}

.results-table th {
	background: var(--dark-mid);
	color: var(--gold);
	font-weight: 700;
	text-align: left;
	padding: 0.65rem 1rem;
	border-bottom: 1px solid var(--gold);
	font-size: 0.82rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.results-table td {
	padding: 0.6rem 1rem;
	border-bottom: 1px solid #2a2a2a;
	vertical-align: middle;
	color: var(--white);
}

.results-table tbody tr:last-child td {
	border-bottom: none;
}
.results-table tbody tr:nth-child(even) {
	background: rgba(255, 255, 255, 0.03);
}
.results-table tbody tr:hover {
	background: var(--gold-pale);
}

.results-table .athlete {
	font-weight: 600;
	color: var(--white);
	vertical-align: middle;
}

.results-table .athlete .last-name {
	display: block;
	font-weight: 400;
}

.results-table .athlete .first-name {
	display: block;
	font-weight: 700;
}

.results-table .time {
	font-family: monospace;
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--gold-light);
}
.text-center {
	text-align: center;
}

/* ===============================
   Compact table on mobile
   =============================== */
@media (max-width: 680px) {
	.results-table {
		font-size: 0.75rem;
		table-layout: fixed;
		width: 100%;
	}

	/* Column widths: Athlete | Event | Heat | Time | Lane */
	.results-table th:nth-child(1),
	.results-table td:nth-child(1) {
		width: 32%;
	}

	.results-table th:nth-child(2),
	.results-table td:nth-child(2) {
		width: 24%;
	}

	.results-table th:nth-child(3),
	.results-table td:nth-child(3) {
		width: 20%;
	}

	.results-table th:nth-child(4),
	.results-table td:nth-child(4) {
		width: 16%;
	}

	.results-table th:nth-child(5),
	.results-table td:nth-child(5) {
		width: 8%;
	}

	.results-table th {
		padding: 0.4rem 0.3rem;
		font-size: 0.65rem;
		white-space: nowrap;
	}

	.results-table td {
		padding: 0.4rem 0.3rem;
		word-break: break-word;
		overflow-wrap: break-word;
	}

	/* Smaller font in the Event column */
	.results-table td:nth-child(2) {
		font-size: 0.68rem;
	}

	/* Time must not wrap */
	.results-table td:nth-child(4) {
		white-space: nowrap;
	}

	/* 6-col tables: search results + flat table view */
	#search-results .results-table th:nth-child(1),
	#search-results .results-table td:nth-child(1),
	#view-table .results-table th:nth-child(1),
	#view-table .results-table td:nth-child(1) {
		width: 28%;
	}

	#search-results .results-table th:nth-child(2),
	#search-results .results-table td:nth-child(2),
	#view-table .results-table th:nth-child(2),
	#view-table .results-table td:nth-child(2) {
		width: 22%;
	}

	#search-results .results-table th:nth-child(3),
	#search-results .results-table td:nth-child(3),
	#view-table .results-table th:nth-child(3),
	#view-table .results-table td:nth-child(3) {
		width: 8%;
	}

	#search-results .results-table th:nth-child(4),
	#search-results .results-table td:nth-child(4),
	#view-table .results-table th:nth-child(4),
	#view-table .results-table td:nth-child(4) {
		width: 18%;
	}

	#search-results .results-table th:nth-child(5),
	#search-results .results-table td:nth-child(5),
	#view-table .results-table th:nth-child(5),
	#view-table .results-table td:nth-child(5) {
		width: 16%;
		white-space: nowrap;
	}

	#search-results .results-table th:nth-child(6),
	#search-results .results-table td:nth-child(6),
	#view-table .results-table th:nth-child(6),
	#view-table .results-table td:nth-child(6) {
		width: 8%;
	}
}

/* ===============================
   Show-time button (lista_startowa.php)
   =============================== */
.btn-show-time {
	display: inline-block;
	margin-top: 0.25rem;
	padding: 0.12rem 0.45rem;
	font-size: 0.7rem;
	font-family: inherit;
	background: transparent;
	color: var(--gold);
	border: 1px solid var(--gold);
	border-radius: 4px;
	cursor: pointer;
	line-height: 1.4;
	transition:
		background 0.15s,
		color 0.15s;
}

.btn-show-time:hover {
	background: var(--gold-pale);
}

.time-display {
	display: inline-block;
	margin-top: 0.25rem;
	font-family: monospace;
	font-size: 0.82rem;
	font-weight: 700;
}

.time-result {
	color: var(--white);
}
.time-seed {
	color: var(--gray);
}
.time-better {
	color: var(--success);
}
.time-worse {
	color: var(--error);
}

.tr-time-display td {
	padding-top: 0;
	padding-bottom: 0.5rem;
	border-top: none;
}

.back-link {
	padding: 1rem 0 2.5rem;
}

/* ===============================
   Buttons
   =============================== */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.55rem 1.2rem;
	border-radius: 6px;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	border: 2px solid transparent;
	text-decoration: none;
	transition:
		background 0.15s,
		color 0.15s,
		border-color 0.15s;
	white-space: nowrap;
}

.btn-primary {
	background: var(--gold);
	color: var(--black);
	border-color: var(--gold);
}
.btn-primary:hover {
	background: var(--gold-light);
	border-color: var(--gold-light);
	color: var(--black);
	text-decoration: none;
}

.btn-outline {
	background: transparent;
	color: var(--gold);
	border-color: var(--gold);
}
.btn-outline:hover {
	background: var(--gold-pale);
	text-decoration: none;
	color: var(--gold-light);
}

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

.btn-full {
	width: 100%;
}

.btn-coming-soon {
	display: inline-block;
	padding: 0.55rem 1.25rem;
	font-size: 0.9rem;
	font-style: italic;
	color: #888;
	border: 1px dashed #ccc;
	border-radius: 6px;
	letter-spacing: 0.03em;
}

/* ===============================
   Alerts
   =============================== */
.alert {
	padding: 0.85rem 1rem;
	border-radius: var(--radius);
	margin-bottom: 1.25rem;
	font-size: 0.9rem;
}

.alert ul {
	margin: 0.25rem 0 0 1.2rem;
}

.alert-success {
	background: var(--success-bg);
	color: var(--success);
	border: 1px solid #2e5c2e;
}
.alert-error {
	background: var(--error-bg);
	color: #f88;
	border: 1px solid #5c2e2e;
}

/* ===============================
   Empty state
   =============================== */
.empty-state {
	text-align: center;
	padding: 3rem 1rem;
	color: var(--gray);
	font-size: 1rem;
}

/* ===============================
   Footer
   =============================== */
.site-footer {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1000;
	background: var(--dark);
	border-top: 1px solid #2a2a2a;
	color: #555;
	text-align: center;
	padding: 1rem;
	font-size: 0.85rem;
	min-height: var(--footer-height);
}

.site-footer a {
	color: var(--gold);
	text-decoration: none;
}

.site-footer a:hover {
	color: var(--gold-light);
	text-decoration: underline;
}

.footer-madeby {
	display: block;
	font-size: 0.75rem;
	margin-top: 0.2rem;
	color: #444;
}

/* ===============================
   Responsive
   =============================== */
/* index.php tabular view — auto layout, no fixed column widths */
.index-table {
	table-layout: auto;
}

@media (max-width: 600px) {
	.hero h1 {
		font-size: 1.5rem;
	}
	.competitions-grid {
		grid-template-columns: 1fr;
	}
	.block-header {
		flex-direction: column;
		align-items: flex-start;
	}
	.results-table {
		font-size: 0.82rem;
	}
	.results-table th,
	.results-table td {
		padding: 0.5rem 0.65rem;
	}
	.view-controls {
		gap: 0.5rem;
	}
	.view-toggles {
		gap: 0.35rem;
	}
	.view-toggle-btn {
		padding: 0.35rem 0.55rem;
		font-size: 0.8rem;
	}

	#view-table .index-table thead {
		display: none;
	}
	#view-table .index-table tbody tr {
		display: block;
		border-bottom: 1px solid rgba(255, 255, 255, 0.08);
		padding: 0.65rem 0.5rem;
	}
	#view-table .index-table tbody tr:last-child {
		border-bottom: none;
	}
	/* data, miejsce, klub — inline w jednej linii */
	#view-table .index-table tbody td {
		display: inline;
		width: auto;
		padding: 0;
		border: none;
		font-size: 0.82rem;
		color: var(--text-muted);
		white-space: normal;
	}
	/* separator między data · miejsce · klub */
	#view-table .index-table tbody td:nth-child(3)::before,
	#view-table .index-table tbody td:nth-child(4)::before {
		content: ' · ';
	}
	/* nazwa — pełna szerokość, zawija się */
	#view-table .index-table tbody td:first-child {
		display: block;
		width: 100%;
		box-sizing: border-box;
		font-weight: 600;
		font-size: 0.95rem;
		color: var(--white);
		margin-bottom: 0.2rem;
		white-space: normal;
		word-break: break-word;
	}
	/* przycisk lista — nowa linia */
	#view-table .index-table tbody td:last-child {
		display: block;
		width: auto;
		margin-top: 0.45rem;
	}
}

@media print {
	body {
		background: #fff;
		color: #000;
	}
	.site-header,
	.site-footer,
	.back-link,
	.site-nav {
		display: none;
	}
	.block {
		box-shadow: none;
		border: 1px solid #ccc;
	}
	.block-header {
		background: #eee;
		border-left: 3px solid #333;
	}
	.block-header h2,
	.results-table th {
		color: #000;
	}
	.results-table .time {
		color: #000;
	}
}
