/* ========================================
   SCROLLBAR
   ======================================== */

::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

::-webkit-scrollbar-track {
	background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
	background: var(--border-light);
	border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
	background: var(--text-muted);
}

/* ========================================
   TEXT UTILITIES
   ======================================== */

.text-muted {
	color: var(--text-muted) !important;
}

.text-success {
	color: var(--accent-primary) !important;
}

.text-danger {
	color: var(--accent-danger) !important;
}

.text-primary {
	color: var(--accent-secondary) !important;
}

/* ========================================
   LOADING STATES & ANIMATIONS
   ======================================== */

@keyframes pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.5;
	}
}

.loading {
	animation: pulse 1.5s ease-in-out infinite;
}

/* Stagger card animations */
.row.g-3 .col-12:nth-child(1) .card {
	animation-delay: 0s;
}
.row.g-3 .col-12:nth-child(2) .card {
	animation-delay: 0.05s;
}
.row.g-3 .col-12:nth-child(3) .card {
	animation-delay: 0.1s;
}
.row.g-3 .col-12:nth-child(4) .card {
	animation-delay: 0.15s;
}
.row.g-3 .col-12:nth-child(5) .card {
	animation-delay: 0.2s;
}
.row.g-3 .col-12:nth-child(6) .card {
	animation-delay: 0.25s;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
	.main-content {
		padding: 1rem 0.75rem 2rem;
	}

	.users-panel {
		border-radius: var(--radius-md);
	}

	.card {
		border-radius: var(--radius-md) !important;
	}

	.panel-header,
	.user-item {
		padding: 1rem;
	}

	/* Block card responsive */
	.block-body {
		flex-direction: column;
		gap: 1rem;
	}

	.block-roles-section {
		align-items: flex-start;
		width: 100%;
	}

	.block-roles {
		justify-content: flex-start;
	}

	.block-time-display .time-start,
	.block-time-display .time-end {
		font-size: 1.25rem;
	}

	.block-header {
		padding: 0.875rem 1rem;
		position: relative;
		gap: 0.75rem;
	}

	/* Card-level duplicate button for admins */
	.btn-duplicate-card {
		position: absolute;
		top: 8px;
		right: 8px;
		width: 36px;
		height: 36px;
		border: none;
		background: rgba(99, 102, 241, 0.08);
		border-radius: 8px;
		color: var(--accent-primary);
		cursor: pointer;
		display: flex;
		align-items: center;
		justify-content: center;
		transition: all 0.15s ease;
	}

	.btn-duplicate-card:hover {
		background: var(--accent-primary);
		color: white;
		transform: scale(1.05);
	}

	/* ensure duplicate button sits above header content on small screens */
	.btn-duplicate-card {
		z-index: 4;
	}

	/* Day header add button (admin) - keep only positioning; visual styles are shared with .admin-duplicate-btn in modals.css */
	.admin-add-day-btn {
		/* On small screens place the button inline in the header to avoid overlap */
		position: static;
		margin-left: 0.5rem;
		margin-right: 0.5rem;
		width: 36px;
		height: 36px;
		align-self: center;
		z-index: 3;
	}

	/* If we ever need extra small adjustment for very narrow devices */
	@media (max-width: 480px) {
		.admin-add-day-btn {
			width: 32px;
			height: 32px;
			margin-left: 0.25rem;
		}
	}

	.block-location {
		font-size: 0.85rem;
	}

	.block-location i {
		font-size: 1rem;
	}

	.signed-badge {
		padding: 0.4rem 0.75rem;
		font-size: 0.8rem;
	}

	.signed-badge i {
		font-size: 0.9rem;
	}

	.signed-block-group {
		gap: 0.35rem;
	}

	.btn-unassign-small {
		width: 28px;
		height: 28px;
	}

	.btn-unassign-small i {
		font-size: 0.75rem;
	}

	.btn-join-block {
		padding: 0.4rem 0.75rem;
		font-size: 0.8rem;
	}

	/* Assigned users - stack vertically on mobile */
	.block-footer {
		padding: 0.75rem 1rem;
	}

	.card:not(.block-card) .assigned-users-list {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.4rem;
	}

	.card:not(.block-card) .role-divider {
		display: none;
	}

	.card:not(.block-card) .role-assignment {
		display: block;
		width: 100%;
		padding: 0.25rem 0;
		border-bottom: 1px solid var(--border-color);
	}

	.card:not(.block-card) .role-assignment:last-child {
		border-bottom: none;
		padding-bottom: 0;
	}
}

@media (max-width: 576px) {
	.navbar {
		padding: 0.75rem 0;
	}

	.modal-body {
		padding: 1.5rem !important;
	}

	/* Admin modal responsive */
	.admin-form-row,
	.admin-datetime-grid {
		grid-template-columns: 1fr;
	}

	.admin-datetime-row {
		flex-direction: column;
	}

	.admin-date,
	.admin-time {
		flex: 1;
	}

	.admin-modal-header {
		padding: 1rem;
	}

	.admin-modal-body {
		padding: 1rem;
	}
}

/* Extra small screens */
@media (max-width: 480px) {
	.block-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.5rem;
	}

	.block-header > * {
		width: 100%;
	}

	/* Keep the join button wrapper tightly sized so corner stamp stays attached */
	.block-header > .join-block-wrapper {
		width: max-content;
		min-width: 0;
		align-self: flex-start;
	}

	/* Slightly nudge the stamp when header stacks to avoid clipping */
	.block-header > .join-block-wrapper .overlap-stamp {
		right: -6px;
		top: -2px;
	}

	.block-time-display {
		justify-content: flex-start;
	}

	/* Make card duplicate button behave responsively when header stacks */
	.btn-duplicate-card {
		position: static;
		width: 36px;
		height: 36px;
		align-self: flex-end; /* place to the right when stacked */
		margin: 0;
		order: 2;
		z-index: 4;
	}

	/* Ensure it doesn't become full-width due to .block-header > * rule */
	.block-header > .btn-duplicate-card {
		width: auto !important;
	}

	/* For the very smallest phones, position the duplicate button at the top-right of the card */
	@media (max-width: 480px) {
		.btn-duplicate-card {
			position: absolute;
			top: 8px;
			right: 8px;
			width: 36px;
			height: 36px;
			margin: 0;
			align-self: auto;
			order: 0;
			z-index: 6;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.block-header {
			padding-top: 1.25rem; /* ensure space for absolute button */
		}

		/* Prevent the header children from expanding under the absolute button */
		.block-header > * {
			z-index: 1;
		}
	}
	.signed-block-group,
	.signed-badge,
	.btn-join-block {
		justify-content: center;
		width: auto;
		align-self: flex-start;
	}

	.block-location {
		justify-content: flex-start;
	}

	.block-time-display .time-start,
	.block-time-display .time-end {
		font-size: 1.1rem;
	}

	.block-body {
		padding: 0.875rem 1rem;
	}

	.block-main h6 {
		font-size: 1rem;
	}

	.block-info {
		font-size: 0.8rem;
	}
}

/* Mid-size devices: ensure duplicate button doesn't overlap header content */
@media (max-width: 768px) and (min-width: 481px) {
	.btn-duplicate-card {
		position: static;
		width: 36px;
		height: 36px;
		margin-left: auto;
		align-self: center;
		order: 2;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 4;
	}

	/* prevent full-width stretching by the general header rule */
	.block-header > .btn-duplicate-card {
		width: 36px !important;
	}

	/* center the icon inside the button on small and mid screens */
	.btn-duplicate-card i {
		display: block;
		margin: 0 auto;
		line-height: 1;
	}
}
