/* ===========================
   CONTENEDOR PRINCIPAL
   =========================== */
.boletos-container {
	display: flex;
	gap: 2rem;
	padding: 2rem;
	min-height: 100vh;
	background: #fafafa;
	position: relative;
}

/* Fix para scroll en mobile */
body:has(.boletos-container) {
	overflow-x: hidden;
}

@media (max-width: 1199px) {
	body:has(.boletos-container) {
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}
}

/* ===========================
   GRID DE BOLETOS
   =========================== */
.boletos-grid {
	flex: 1;
	padding: 2rem;
	background: transparent;
	border-radius: 15px;
	box-shadow: none;
	overflow-y: auto;
	max-height: calc(100vh - 4rem);
}

.grid-boletos {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
	gap: 15px;
	padding: 1rem;
}

/* ===========================
   DISEÑO DEL BOLETO (TICKET)
   =========================== */
.boleto {
	position: relative;
	cursor: pointer;
	transition: all 0.3s ease;
	height: 110px;
	background: transparent;
	border: 2px solid #28a745;
	border-radius: 8px;
	overflow: visible;
	box-shadow: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	outline: none;
}

.boleto:hover {
	transform: translateY(-2px);
	border-color: #1e7e34;
	border-width: 2px;
	z-index: 10;
}

.boleto:active {
	transform: scale(0.98);
}

/* Parte Superior del Boleto */
.boleto-superior {
	background: transparent;
	height: 60%;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	padding: 0.5rem;
	border-bottom: none;
}

.boleto-numero {
	color: #28a745;
	font-size: 1.1rem;
	font-weight: 700;
	text-shadow: none;
	letter-spacing: 0.5px;
}

/* Línea de Perforación */
.boleto-perforacion {
	height: 1px;
	background: repeating-linear-gradient(
		to right,
		#28a745 0px,
		#28a745 3px,
		transparent 3px,
		transparent 8px
	);
	position: relative;
	z-index: 2;
	margin: 0 10%;
}

.boleto-perforacion::before,
.boleto-perforacion::after {
	content: '';
	position: absolute;
	width: 8px;
	height: 8px;
	background: transparent;
	border: 2px solid #28a745;
	border-radius: 50%;
	top: 50%;
	transform: translateY(-50%);
}

.boleto-perforacion::before {
	left: -12px;
}

.boleto-perforacion::after {
	right: -12px;
}

/* Parte Inferior del Boleto */
.boleto-inferior {
	background: transparent;
	height: 40%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.3rem;
}

.boleto-precio {
	color: #28a745;
	font-size: 0.65rem;
	font-weight: 600;
	text-shadow: none;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* Estados del Boleto */
.boleto.seleccionado {
	background: transparent;
	border-color: #28a745;
	border-width: 3px;
	transform: scale(1.05);
	animation: pulse 0.5s ease;
}

.boleto.seleccionado::before,
.boleto.seleccionado::after {
	border-width: 3px;
	border-color: #28a745;
}

.boleto.seleccionado .boleto-superior {
	background: transparent;
}

.boleto.seleccionado .boleto-numero {
	color: #28a745;
	font-weight: 900;
	font-size: 1.5rem;
}

.boleto.seleccionado .boleto-inferior {
	background: transparent;
}

.boleto.seleccionado .boleto-precio {
	color: #28a745;
	font-weight: 700;
}

.boleto.seleccionado .boleto-perforacion {
	background: repeating-linear-gradient(
		to bottom,
		#28a745 0px,
		#28a745 4px,
		transparent 4px,
		transparent 8px
	);
}

/* Checkmark para boleto seleccionado */
.boleto.seleccionado > .boleto-superior::after {
	content: '✓';
	position: absolute;
	top: 5px;
	right: 5px;
	background: transparent;
	color: #28a745;
	width: 18px;
	height: 18px;
	border: 2px solid #28a745;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	font-size: 0.8rem;
	z-index: 3;
}

.boleto.vendido {
	background: transparent;
	border-color: #ccc;
	cursor: not-allowed;
	opacity: 0.5;
}

.boleto.vendido::before,
.boleto.vendido::after {
	border-color: #ccc;
}

.boleto.vendido .boleto-superior {
	background: transparent;
}

.boleto.vendido .boleto-numero {
	color: #999;
}

.boleto.vendido .boleto-perforacion {
	background: repeating-linear-gradient(
		to bottom,
		#ccc 0px,
		#ccc 3px,
		transparent 3px,
		transparent 8px
	);
}

.boleto.vendido .boleto-perforacion::before,
.boleto.vendido .boleto-perforacion::after {
	border-color: #ccc;
}

.boleto.vendido .boleto-inferior {
	background: transparent;
}

.boleto.vendido .boleto-precio {
	color: #999;
}

.boleto.vendido:hover {
	transform: none;
	border-color: #ccc;
}

.boleto.vendido > .boleto-superior::after {
	content: '✕';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: #ccc;
	font-size: 2rem;
	font-weight: bold;
	z-index: 3;
	border: none;
	width: auto;
	height: auto;
}

/* ===========================
   PANEL DE CONFIGURACIÓN FIXED
   =========================== */
.panel-configuracion {
	position: sticky;
	top: 2rem;
	right: 2rem;
	width: 350px;
	height: fit-content;
	max-height: calc(100vh - 4rem);
	background: white;
	border-radius: 15px;
	border: 2px solid #e0e0e0;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	overflow: hidden;
	z-index: 100;
}

/* Handle visual para móvil */
.panel-configuracion::before {
	content: '';
	display: none;
	position: absolute;
	top: 8px;
	left: 50%;
	transform: translateX(-50%);
	width: 40px;
	height: 4px;
	background: #d0d0d0;
	border-radius: 2px;
	z-index: 1001;
}

.panel-header {
	background: transparent;
	color: #28a745;
	padding: 1.5rem;
	text-align: center;
	border-bottom: 2px solid #28a745;
}

.panel-header h3 {
	margin: 0;
	font-size: 1.5rem;
	text-shadow: none;
}

.panel-body {
	padding: 1.5rem;
	overflow-y: auto;
	max-height: calc(100vh - 12rem);
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.config-section {
	margin-bottom: 1.5rem;
}

.config-section:last-child {
	margin-bottom: 0;
	padding-bottom: 0.5rem;
}

.config-section label {
	color: #333;
	margin-bottom: 0.5rem;
	font-size: 0.95rem;
}

.config-section .form-control {
	border: 2px solid #e0e0e0;
	border-radius: 8px;
	padding: 0.75rem;
	font-size: 1rem;
	transition: all 0.3s ease;
}

.config-section .form-control:focus {
	border-color: #28a745;
	box-shadow: none;
	outline: 2px solid #28a745;
}

/* ===========================
   BOTONES
   =========================== */
.btn-aleatorio {
	background: transparent;
	color: #28a745;
	border: 2px solid #28a745;
	padding: 0.85rem 1.5rem;
	border-radius: 8px;
	font-weight: 600;
	font-size: 1rem;
	transition: all 0.3s ease;
	box-shadow: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.btn-aleatorio:hover {
	background: #28a745;
	color: white;
	transform: none;
}

.btn-aleatorio:active {
	transform: scale(0.98);
}

.btn-pagar {
	background: #28a745;
	color: white;
	border: 2px solid #28a745;
	padding: 1rem 1.5rem;
	border-radius: 8px;
	font-weight: 700;
	font-size: 1.1rem;
	transition: all 0.3s ease;
	box-shadow: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.btn-pagar:hover:not(:disabled) {
	background: #1e7e34;
	border-color: #1e7e34;
	transform: none;
}

.btn-pagar:active:not(:disabled) {
	transform: scale(0.98);
}

.btn-pagar:disabled {
	background: transparent;
	border-color: #ccc;
	color: #ccc;
	cursor: not-allowed;
	opacity: 0.6;
}

.btn-limpiar {
	background: transparent;
	color: #000;
	border: 2px solid #000;
	padding: 0.75rem 1.5rem;
	border-radius: 8px;
	font-weight: 600;
	font-size: 0.95rem;
	transition: all 0.3s ease;
	box-shadow: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.btn-limpiar:hover {
	background: #000;
	color: white;
	transform: none;
}

.btn-limpiar:active {
	transform: scale(0.98);
}

/* ===========================
   RESUMEN
   =========================== */
.resumen {
	background: transparent;
	padding: 1rem;
	border-radius: 8px;
	border: 1px solid #e9ecef;
}

.resumen h5 {
	color: #333;
	margin-bottom: 1rem;
	border-bottom: 1px solid #28a745;
	padding-bottom: 0.5rem;
}

.boletos-seleccionados {
	max-height: 150px;
	overflow-y: auto;
	margin-bottom: 1rem;
}

.boleto-chip {
	display: inline-block;
	background: transparent;
	color: #28a745;
	border: 1px solid #28a745;
	padding: 0.4rem 0.8rem;
	margin: 0.25rem;
	border-radius: 15px;
	font-size: 0.85rem;
	font-weight: 600;
	box-shadow: none;
}

.resumen-total {
	border-top: 1px solid #dee2e6;
	padding-top: 1rem;
}

.resumen-total .badge {
	font-size: 1rem;
	padding: 0.5rem 0.75rem;
}

/* ===========================
   SCROLLBAR PERSONALIZADO
   =========================== */
.boletos-grid::-webkit-scrollbar,
.panel-body::-webkit-scrollbar,
.boletos-seleccionados::-webkit-scrollbar {
	width: 8px;
}

.boletos-grid::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track,
.boletos-seleccionados::-webkit-scrollbar-track {
	background: #f1f1f1;
	border-radius: 10px;
}

.boletos-grid::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb,
.boletos-seleccionados::-webkit-scrollbar-thumb {
	background: #28a745;
	border-radius: 10px;
}

.boletos-grid::-webkit-scrollbar-thumb:hover,
.panel-body::-webkit-scrollbar-thumb:hover,
.boletos-seleccionados::-webkit-scrollbar-thumb:hover {
	background: #1e7e34;
}

/* ===========================
   ANIMACIONES
   =========================== */
@keyframes pulse {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.1);
	}
	100% {
		transform: scale(1.05);
	}
}

/* ===========================
   RESPONSIVE
   =========================== */

/* Tablet Large y Desktop Small (1200px - 1400px) */
@media (max-width: 1400px) {
	.panel-configuracion {
		width: 320px;
	}
	
	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
	}
}

/* Tablet (768px - 1199px) */
@media (max-width: 1199px) {
	.boletos-container {
		flex-direction: column;
		padding: 1rem;
		gap: 0;
	}

	.boletos-grid {
		padding: 1rem;
		max-height: none;
		margin-bottom: 0;
		padding-bottom: calc(60vh + 2rem);
	}

	.panel-configuracion {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		top: auto;
		width: 100%;
		max-height: 55vh;
		border-radius: 20px 20px 0 0;
		z-index: 900;
		box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
		border: 2px solid #e0e0e0;
		border-bottom: none;
		overscroll-behavior: contain;
		transition: transform 0.25s ease-in-out;
	}

	/* Estado oculto: desaparece por completo con slide hacia abajo */
	.panel-configuracion.hidden {
		transform: translateY(100%);
		pointer-events: none;
		visibility: hidden;
	}

	.panel-configuracion .panel-header .btn {
		padding: 0.25rem 0.6rem;
		font-size: 0.85rem;
	}

	/* Botón flotante para reabrir el panel */
	.panel-float-toggle {
		position: fixed;
		top: 12px;
		right: 12px;
		z-index: 950;
		background: #28a745;
		color: #fff;
		border: 0;
		border-radius: 10px;
		width: 44px;
		height: 44px;
		display: none;
		align-items: center;
		justify-content: center;
		box-shadow: 0 4px 12px rgba(0,0,0,.2);
	}

	.panel-float-toggle i { font-size: 18px; }

	/* Mostrar el handle en móvil */
	.panel-configuracion::before {
		display: block;
	}

	.panel-header {
		padding: 1.5rem 1.5rem 1rem;
		position: sticky;
		top: 0;
		background: white;
		z-index: 10;
	}

	.panel-header h3 {
		font-size: 1.3rem;
	}

	.panel-body {
		max-height: calc(55vh - 5.5rem);
		padding: 1rem 1.5rem 1.5rem;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
	}

	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
		gap: 12px;
		padding: 1rem 0.5rem;
	}

	.boleto {
		height: 100px;
	}

	.boleto-numero {
		font-size: 1rem;
	}

	.boleto-precio {
		font-size: 0.6rem;
	}
}

/* Cuando el panel está oculto, reducir padding extra de la grilla para usar todo el alto */
@media (max-width: 1199px) {
	.panel-config-hidden .boletos-grid {
		padding-bottom: 1rem !important;
	}
}

/* Mobile Large (576px - 767px) */
@media (max-width: 767px) {
	.boletos-container {
		padding: 0.5rem;
	}

	.boletos-grid {
		padding: 0.5rem;
		padding-bottom: calc(50vh + 1rem);
	}

	.boletos-grid h2 {
		font-size: 1.3rem;
		margin-bottom: 1rem;
	}

	/* Diseño de boleto compacto para mobile */
	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
		gap: 8px;
		padding: 0.5rem;
	}

	.boleto {
		height: 50px;
		border-radius: 6px;
		display: flex;
		align-items: center;
		justify-content: center;
		border-width: 2px;
	}

	/* Ocultar estructura de ticket en mobile */
	.boleto-superior {
		height: 100%;
		width: 100%;
		border-bottom: none;
		padding: 0;
	}

	.boleto-perforacion {
		display: none;
	}

	.boleto-inferior {
		display: none;
	}

	.boleto-numero {
		font-size: 0.85rem;
		font-weight: 700;
	}

	.boleto.seleccionado {
		border-width: 3px;
		transform: scale(1.02);
	}

	.boleto.seleccionado .boleto-numero {
		font-size: 0.95rem;
		font-weight: 900;
	}

	.boleto.seleccionado > .boleto-superior::after {
		width: 14px;
		height: 14px;
		font-size: 0.65rem;
		top: 2px;
		right: 2px;
		border-width: 1.5px;
	}

	.boleto.vendido > .boleto-superior::after {
		font-size: 1.2rem;
	}

	/* Panel más compacto */
	.panel-configuracion {
		max-height: 50vh;
		border-radius: 15px 15px 0 0;
	}

	.panel-configuracion::before {
		top: 6px;
	}

	.panel-header {
		padding: 1.25rem 1rem 0.75rem;
	}

	.panel-header h3 {
		font-size: 1.1rem;
	}

	.panel-body {
		max-height: calc(50vh - 4rem);
		padding: 0.75rem 1rem 1rem;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.config-section {
		margin-bottom: 0.75rem;
	}

	.config-section label {
		font-size: 0.85rem;
		margin-bottom: 0.35rem;
	}

	.config-section small {
		font-size: 0.75rem;
	}

	.config-section .form-control {
		padding: 0.5rem;
		font-size: 0.9rem;
	}

	.btn-aleatorio,
	.btn-limpiar {
		padding: 0.65rem 0.85rem;
		font-size: 0.85rem;
	}

	.btn-pagar {
		padding: 0.75rem 0.85rem;
		font-size: 0.95rem;
	}

	.resumen {
		padding: 0.75rem;
		margin-bottom: 0.75rem;
	}

	.resumen h5 {
		font-size: 0.95rem;
		margin-bottom: 0.75rem;
	}

	.boletos-seleccionados {
		max-height: 80px;
		margin-bottom: 0.75rem;
	}

	.boleto-chip {
		padding: 0.25rem 0.5rem;
		font-size: 0.75rem;
		margin: 0.15rem;
	}

	.resumen-total {
		padding-top: 0.75rem;
	}

	.resumen-total .badge {
		font-size: 0.85rem;
		padding: 0.35rem 0.55rem;
	}

	.resumen-total .fs-5 {
		font-size: 1rem !important;
	}

	.resumen-total .d-flex {
		margin-bottom: 0.5rem;
	}

	.resumen-total .d-flex:last-child {
		margin-bottom: 0;
	}
}

/* Mobile Medium (481px - 575px) */
@media (max-width: 575px) {
	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
		gap: 7px;
	}

	.boleto {
		height: 48px;
	}

	.boleto-numero {
		font-size: 0.8rem;
	}

	.boleto.seleccionado .boleto-numero {
		font-size: 0.9rem;
	}

	.panel-configuracion {
		max-height: 48vh;
	}

	.panel-body {
		max-height: calc(48vh - 4rem);
		padding: 0.65rem 0.85rem 0.85rem;
	}
}

/* Mobile Small (320px - 480px) */
@media (max-width: 480px) {
	.boletos-grid h2 {
		font-size: 1.1rem;
		margin-bottom: 0.75rem;
	}

	.boletos-grid {
		padding-bottom: calc(48vh + 0.5rem);
	}

	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
		gap: 6px;
		padding: 0.25rem;
	}

	.boleto {
		height: 46px;
		border-radius: 5px;
	}

	.boleto-numero {
		font-size: 0.75rem;
		letter-spacing: 0.2px;
	}

	.boleto.seleccionado {
		transform: scale(1.01);
	}

	.boleto.seleccionado .boleto-numero {
		font-size: 0.85rem;
	}

	.boleto.seleccionado > .boleto-superior::after {
		width: 12px;
		height: 12px;
		font-size: 0.6rem;
		top: 1px;
		right: 1px;
		border-width: 1.5px;
	}

	.boleto.vendido > .boleto-superior::after {
		font-size: 1rem;
	}

	.panel-header h3 {
		font-size: 1rem;
	}

	.config-section label {
		font-size: 0.8rem;
	}

	.config-section small {
		font-size: 0.7rem;
	}

	.btn-aleatorio i,
	.btn-pagar i,
	.btn-limpiar i {
		margin-right: 0.25rem;
		font-size: 0.9rem;
	}

	.resumen h5 {
		font-size: 0.9rem;
	}

	.boleto-chip {
		padding: 0.2rem 0.45rem;
		font-size: 0.7rem;
	}
}

/* Muy Mobile (max 360px) */
@media (max-width: 360px) {
	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
		gap: 5px;
	}

	.boleto {
		height: 44px;
	}

	.boleto-numero {
		font-size: 0.7rem;
	}

	.boleto.seleccionado .boleto-numero {
		font-size: 0.8rem;
	}

	.panel-configuracion {
		max-height: 48vh;
	}

	.panel-body {
		max-height: calc(48vh - 3.5rem);
	}
}

/* Landscape Mobile */
@media (max-height: 600px) and (orientation: landscape) {
	.panel-configuracion {
		max-height: 75vh;
	}

	.panel-body {
		max-height: calc(75vh - 4rem);
	}

	.boletos-grid {
		padding-bottom: calc(75vh + 1rem);
	}
}

/* Landscape Mobile - Pantallas muy bajas */
@media (max-height: 500px) and (orientation: landscape) {
	.panel-configuracion {
		max-height: 85vh;
	}

	.panel-body {
		max-height: calc(85vh - 3.5rem);
	}

	.boletos-grid {
		padding-bottom: calc(85vh + 0.5rem);
	}

	.panel-header {
		padding: 0.75rem 1rem 0.5rem;
	}

	.panel-header h3 {
		font-size: 0.95rem;
	}

	.config-section {
		margin-bottom: 0.5rem;
	}

	.resumen {
		padding: 0.5rem;
	}

	.boletos-seleccionados {
		max-height: 60px;
	}
}

/* iPad Pro y Tablets Grandes */
@media (min-width: 1024px) and (max-width: 1366px) {
	.panel-configuracion {
		width: 340px;
	}

	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
		gap: 14px;
	}
}

/* Desktop Large */
@media (min-width: 1600px) {
	.panel-configuracion {
		width: 380px;
	}

	.grid-boletos {
		grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
		gap: 16px;
	}

	.boleto {
		height: 115px;
	}

	.boleto-numero {
		font-size: 1.2rem;
	}
}

/* ===========================
   LOADING INDICATOR
   =========================== */
#loading-indicator {
	grid-column: 1 / -1;
	padding: 2rem;
	text-align: center;
}

#loading-indicator .spinner-border {
	width: 3rem;
	height: 3rem;
	border-width: 0.3em;
}

#loading-indicator p {
	margin-top: 1rem;
	color: #6c757d;
	font-size: 0.95rem;
}

/* ===========================
   MENSAJE RIFA INACTIVA - RESPONSIVE
   =========================== */
@media (max-width: 767px) {
	.boletos-container .container {
		padding: 1rem;
	}

	.boletos-container .card {
		border-radius: 15px !important;
	}

	.boletos-container .card-body {
		padding: 2rem 1.5rem !important;
	}

	.boletos-container .bi-clock-history {
		font-size: 3.5rem !important;
	}

	.boletos-container h2 {
		font-size: 1.3rem !important;
	}

	.boletos-container .lead {
		font-size: 0.95rem !important;
	}

	.boletos-container .btn-lg {
		font-size: 0.95rem !important;
		padding: 0.65rem 1.5rem !important;
		margin-bottom: 0.5rem;
	}

	.boletos-container .btn-lg.me-2 {
		margin-right: 0 !important;
		margin-bottom: 0.75rem;
	}

	.boletos-container .mt-4 {
		display: flex;
		flex-direction: column;
		align-items: stretch;
	}
}

@media (max-width: 480px) {
	.boletos-container .card-body {
		padding: 1.5rem 1rem !important;
	}

	.boletos-container .bi-clock-history {
		font-size: 3rem !important;
	}

	.boletos-container h2 {
		font-size: 1.1rem !important;
	}

	.boletos-container .lead {
		font-size: 0.9rem !important;
	}

	.boletos-container .alert {
		font-size: 0.85rem !important;
		padding: 0.5rem 0.75rem;
	}
}
