/* Custom overrides on top of Pico CSS */

/* Admin page — denser layout */
.admin-page section {
	margin-bottom: 0.5rem;
}

.admin-page h2,
.admin-page h3 {
	margin-bottom: 0.25rem;
}

.admin-page p {
	margin-bottom: 0.25rem;
}

.admin-page label {
	margin-bottom: 0.1rem;
}

.admin-page input[type="text"],
.admin-page textarea {
	margin-bottom: 0.4rem;
	padding: 0.35rem 0.5rem;
}

.admin-page hgroup {
	margin-bottom: 0.5rem;
}

.admin-page .grid {
	margin-top: 0.5rem;
}

.validation-hint {
	color: var(--pico-del-color);
	font-weight: 500;
}

/* ============================================
   Timer page — full-viewport app layout
   ============================================ */
html.timer-page,
body.timer-page {
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
}

/* Name entry overlay */
.name-overlay {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100vh;
	padding: 1rem;
}

.name-card {
	max-width: 400px;
	width: 100%;
	text-align: center;
}

.name-card input {
	margin-bottom: 0.75rem;
}

/* Timer app shell — flex column filling viewport */
.timer-app {
	display: flex;
	flex-direction: column;
	height: 100vh;
	height: 100dvh;
	/* dynamic viewport height for mobile */
	overflow: hidden;
}

/* Header bar */
.timer-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.4rem 0.75rem;
	background: var(--pico-primary-background);
	color: var(--pico-primary-inverse);
	font-size: 0.9rem;
	flex-shrink: 0;
}

/* Event dropdown row */
.event-row {
	padding: 0.4rem 0.75rem;
	flex-shrink: 0;
	border-bottom: 1px solid var(--pico-muted-border-color);
}

.event-dropdown {
	position: relative;
}

.event-dropdown input {
	margin-bottom: 0;
	cursor: pointer;
	padding: 0.4rem 0.6rem;
	font-size: 0.95rem;
}

.event-dropdown-list {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 100;
	background: var(--pico-card-background-color);
	border: 1px solid var(--pico-muted-border-color);
	border-top: none;
	border-radius: 0 0 var(--pico-border-radius) var(--pico-border-radius);
	max-height: 50vh;
	overflow-y: auto;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.event-option {
	padding: 0.5rem 0.75rem;
	cursor: pointer;
	font-size: 0.95rem;
}

.event-option:hover,
.event-option.active {
	background: var(--pico-primary-focus);
}

.event-option.selected {
	font-weight: bold;
	background: var(--pico-primary-focus);
}

/* Participant section — grows to fill space */
.participant-section {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	/* critical for flex overflow */
	padding: 0.4rem 0.75rem 0;
}

.participant-filter-input {
	flex-shrink: 0;
	margin-bottom: 0.3rem !important;
	padding: 0.4rem 0.6rem;
	font-size: 0.95rem;
}

.participant-list {
	flex: 1;
	overflow-y: auto;
	border: 1px solid var(--pico-muted-border-color);
	border-radius: var(--pico-border-radius);
	-webkit-overflow-scrolling: touch;
}

.participant-item {
	display: flex;
	align-items: center;
	padding: 0.45rem 0.6rem;
	margin: 0;
	cursor: pointer;
	border-bottom: 1px solid var(--pico-muted-border-color);
}

.participant-item:last-child {
	border-bottom: none;
}

.participant-item:hover {
	background: var(--pico-primary-focus);
}

.participant-item input[type="radio"] {
	margin: 0 0.5rem 0 0;
	flex-shrink: 0;
}

.participant-item span {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Timer + buttons pinned at bottom */
.timer-bottom {
	flex-shrink: 0;
	padding: 0.3rem 0.75rem 0.5rem;
	border-top: 1px solid var(--pico-muted-border-color);
}

/* Timer display */
.timer-display {
	font-size: 2.5rem;
	font-family: monospace;
	text-align: center;
	padding: 0.3rem;
	margin: 0.2rem 0;
	background: var(--pico-card-background-color);
	border-radius: var(--pico-border-radius);
	border: 2px solid var(--pico-muted-border-color);
}

/* Timer buttons */
.timer-buttons {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
	margin: 0.3rem 0 0;
}

.start-btn {
	background-color: #2ecc40;
	border-color: #2ecc40;
	color: #fff;
	font-size: 1.3rem;
	padding: 0.8rem;
	font-weight: bold;
}

.start-btn:hover:not([disabled]) {
	background-color: #27ae37;
	border-color: #27ae37;
}

.start-btn[disabled] {
	background-color: #ccc;
	border-color: #ccc;
	color: #888;
	opacity: 0.6;
}

.stop-btn {
	background-color: #e74c3c;
	border-color: #e74c3c;
	color: #fff;
	font-size: 1.3rem;
	padding: 0.8rem;
	font-weight: bold;
}

.stop-btn:hover:not([disabled]) {
	background-color: #c0392b;
	border-color: #c0392b;
}

.stop-btn[disabled] {
	background-color: #ccc;
	border-color: #ccc;
	color: #888;
	opacity: 0.6;
}



/* Error messages */
.error-msg {
	color: #e74c3c;
	margin-top: 1rem;
	padding: 0.5rem 1rem;
	border: 1px solid #e74c3c;
	border-radius: var(--pico-border-radius);
	background: #fdf0ef;
}

/* Confirm dialog tweaks */
#confirm-dialog article {
	max-width: 400px;
}

#confirm-dialog footer {
	display: flex;
	gap: 1rem;
	justify-content: flex-end;
}

/* ============================================
   Single Timer (Race mode) styles
   ============================================ */

/* Participant section — fills space above favourites */
.st-participant-section {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	padding: 0.4rem 0.75rem 0;
}

.st-participant-list {
	flex: 1;
	overflow-y: auto;
	border: 1px solid var(--pico-muted-border-color);
	border-radius: var(--pico-border-radius);
	-webkit-overflow-scrolling: touch;
}

/* Favourites section — sits between participants and timer */
.st-favourites-section {
	flex-shrink: 0;
	padding: 0 0.75rem;
	max-height: 30vh;
	overflow-y: auto;
	transition: none !important;
}

.st-favourites-header {
	font-weight: bold;
	font-size: 0.85rem;
	padding: 0.3rem 0;
	color: var(--pico-primary);
	border-bottom: 1px solid var(--pico-muted-border-color);
}

.st-favourites-list {
	border: 1px solid var(--pico-primary);
	border-radius: var(--pico-border-radius);
	background: var(--pico-card-background-color);
}

/* Participant/Favourite row */
.st-row {
	display: flex;
	align-items: center;
	padding: 0.35rem 0.5rem;
	border-bottom: 1px solid var(--pico-muted-border-color);
	gap: 0.4rem;
	transition: none !important;
}

.st-row:last-child {
	border-bottom: none;
}

.st-name {
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.95rem;
}

/* Star button */
.st-star {
	background: none;
	border: none;
	padding: 0.2rem;
	margin: 0;
	font-size: 1.2rem;
	cursor: pointer;
	color: var(--pico-muted-color);
	line-height: 1;
	flex-shrink: 0;
	width: auto;
	transition: none !important;
}

.st-star.is-fav {
	color: #f1c40f;
}

/* Stop button / time display */
.st-stop {
	background: none;
	border: 1px solid var(--pico-muted-border-color);
	border-radius: var(--pico-border-radius);
	padding: 0.25rem 0.5rem;
	margin: 0;
	font-size: 0.85rem;
	cursor: pointer;
	flex-shrink: 0;
	min-width: 4.5rem;
	text-align: center;
	font-family: monospace;
	width: auto;
	transition: none !important;
	display: flex;
	align-items: center;
	justify-content: center;
}

.st-stop .stop-icon {
	fill: var(--pico-muted-color);
}

.st-stop.has-time {
	background: var(--pico-primary-focus);
	border-color: var(--pico-primary);
	color: var(--pico-primary);
	font-weight: bold;
}

/* Send button (green like start) */
.send-btn {
	background-color: var(--pico-primary-background);
	border-color: var(--pico-primary-background);
	color: var(--pico-primary-inverse);
	font-size: 1.3rem;
	padding: 0.8rem;
	font-weight: bold;
}

.send-btn:hover:not([disabled]) {
	background-color: var(--pico-primary-hover-background);
	border-color: var(--pico-primary-hover-background);
}

.send-btn[disabled] {
	background-color: #ccc;
	border-color: #ccc;
	color: #888;
	opacity: 0.6;
}

/* Start button in reset mode */
.start-btn.reset-mode {
	background-color: #e67e22;
	border-color: #e67e22;
}

.start-btn.reset-mode:hover {
	background-color: #d35400;
	border-color: #d35400;
}

/* Edit time dialog fields */
.st-edit-fields {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.st-edit-fields input {
	text-align: center;
}

/* Dialog tweaks for single timer */
#send-dialog article,
#reset-dialog article,
#edit-dialog article {
	max-width: 400px;
}

#send-dialog footer,
#reset-dialog footer,
#edit-dialog footer {
	display: flex;
	gap: 0.75rem;
	justify-content: flex-end;
}