/* Contenedor principal */
.cp-timeline-wrapper {
	font-family: 'Inter', 'Roboto', sans-serif;
	max-width: 100%;
	margin: 20px auto;
	box-sizing: border-box;
}

.cp-timeline-wrapper * {
	box-sizing: border-box;
}

/* Filtros */
.cp-filters-container {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	background: #f8f9fa;
	padding: 20px;
	border-radius: 8px;
	margin-bottom: 30px;
	align-items: flex-end;
}

.cp-filter-group {
	flex: 1;
	min-width: 200px;
	display: flex;
	flex-direction: column;
}

.cp-filter-group label {
	font-weight: 600;
	margin-bottom: 8px;
	font-size: 14px;
	color: #333;
}

.cp-select {
	width: 100%;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
	background-color: #fff;
}

.cp-select[multiple] {
	display: none; /* Ocultar nativo si falla JS */
}

.cp-select:disabled {
	background-color: #eee;
	cursor: not-allowed;
}

/* Personalización de Select2 */
.cp-filter-group .select2-container--default .select2-selection--single {
	border: 1px solid #ddd !important;
	border-radius: 4px !important;
	height: 42px !important;
	font-family: inherit !important;
	font-size: 14px !important;
	background-color: #fff !important;
	display: flex !important;
	align-items: center !important;
	box-sizing: border-box !important;
}

.cp-filter-group .select2-container--default .select2-selection--multiple {
	border: 1px solid #ddd !important;
	border-radius: 4px !important;
	height: 42px !important;
	max-height: 42px !important;
	font-family: inherit !important;
	font-size: 14px !important;
	background-color: #fff !important;
	display: flex !important;
	align-items: center !important;
	overflow: hidden !important;
	box-sizing: border-box !important;
}

.cp-filter-group .select2-container--default .select2-selection--single .select2-selection__rendered {
	line-height: 40px !important;
	padding-left: 10px !important;
	padding-right: 30px !important; /* Espacio para la flecha */
	color: #333 !important;
	width: 100% !important;
}

/* Ocultar la flecha por defecto de Select2 y mantener solo la flecha de fondo del tema */
.cp-filter-group .select2-container--default .select2-selection--single .select2-selection__arrow {
	display: none !important;
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-selection__rendered {
	padding: 0 8px !important;
	margin: 0 !important;
	list-style: none !important;
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 6px !important;
	align-items: center !important;
	height: 40px !important;
	width: 100% !important;
	overflow-x: auto !important;
	scrollbar-width: none !important; /* Firefox */
	-ms-overflow-style: none !important; /* IE/Edge */
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-selection__rendered::-webkit-scrollbar {
	display: none !important; /* Chrome/Safari */
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-selection__choice {
	background-color: #e2f0d9 !important;
	border: 1px solid #c5dfb5 !important;
	color: #386927 !important;
	font-weight: 500 !important;
	border-radius: 3px !important;
	padding: 0 8px !important;
	margin: 0 !important;
	font-size: 12px !important;
	display: inline-flex !important;
	align-items: center !important;
	height: 28px !important;
	line-height: 28px !important;
	float: none !important;
	list-style: none !important;
	white-space: nowrap !important;
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
	color: #c0392b !important;
	margin-right: 5px !important;
	border: none !important;
	background: transparent !important;
	font-size: 14px !important;
	cursor: pointer !important;
	padding: 0 !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	height: auto !important;
	width: auto !important;
	float: none !important;
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
	background: none !important;
	color: #e74c3c !important;
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-search--inline {
	display: inline-flex !important;
	align-items: center !important;
	margin: 0 !important;
	padding: 0 !important;
	height: 28px !important;
	float: none !important;
}

.cp-filter-group .select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
	margin: 0 !important;
	padding: 0 !important;
	height: 28px !important;
	line-height: 28px !important;
	border: none !important;
	background: transparent !important;
	font-family: inherit !important;
	font-size: 14px !important;
}

.cp-filter-group .select2-container--default.select2-container--disabled .select2-selection--single,
.cp-filter-group .select2-container--default.select2-container--disabled .select2-selection--multiple {
	background-color: #eee !important;
	cursor: not-allowed !important;
}

/* Corregir doble flecha y padding/bordes duplicados por heredar la clase del select nativo */
.select2-container.cp-select {
	padding: 0 !important;
	border: none !important;
	background: transparent !important;
}

.select2-container.cp-select .select2-selection {
	background-image: none !important;
}

.cp-filter-action {
	flex: 0 0 auto;
}

.cp-btn {
	padding: 12px 24px;
	font-size: 16px;
	font-weight: bold;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: background-color 0.3s;
}

.cp-btn-primary {
	background-color: #5ab13f; /* Verde estilo Summit Agro */
	color: white;
}

.cp-btn-primary:hover:not(:disabled) {
	background-color: #4a9133;
}

.cp-btn-primary:disabled {
	background-color: #a5d697;
	cursor: not-allowed;
}

/* Leyenda */
.cp-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	margin-bottom: 20px;
	padding: 10px;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.cp-legend-item {
	display: flex;
	align-items: center;
	font-size: 13px;
	font-weight: bold;
	color: #555;
	text-transform: uppercase;
}

.cp-legend-color {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	margin-right: 8px;
	display: inline-block;
}

/* Gráfico Gantt */
.cp-gantt-wrapper {
	width: 100%;
	overflow-x: auto;
	background: #f0f8ff url('../images/sky_bg.png') center center / cover no-repeat; /* Imagen sintética de cielo generada */
	background-attachment: local; /* Permite que el fondo se mueva con el scroll horizontal */
	border-radius: 8px;
	padding-top: 20px;
	position: relative;
	box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Decoración de suelo */
.cp-gantt-grid::after {
	content: '';
	position: absolute;
	bottom: 30px; /* Deja 30px de espacio para los nombres de las etapas */
	left: 0;
	right: 0;
	height: 33px; /* Altura ajustada a 33px */
	background: #4b3621 url('../images/soil_bg.png') repeat center top; /* Textura de tierra oscura */
	z-index: 0;
}

.cp-gantt-grid {
	display: grid;
	gap: 5px 0; /* Espacio vertical entre productos, 0 horizontal para barras contiguas */
	padding-bottom: 150px; /* Espacio para las imágenes de plantas, suelo y nombres */
	position: relative;
	z-index: 1;
	min-width: max-content; /* Fuerza al contenedor a abarcar el ancho total de las columnas */
}

/* Columnas de fondo (Etapas) */
.cp-stage-col-bg {
	grid-row: 1 / 999; /* Sobrescrito por JS, pero dejado como fallback */
	border-left: 1px dashed #a0c4e4;
	position: relative;
	pointer-events: none;
}

/* Contenedor de la info (imagen + nombre) ubicado en el padding inferior */
.cp-stage-info {
	position: absolute;
	bottom: -150px; /* Ocupa exactamente los 150px del padding-bottom del grid */
	left: 0;
	width: 100%;
	height: 150px;
	border-left: 1px dashed #a0c4e4; /* Continúa la línea punteada hasta abajo */
	box-sizing: border-box;
}

/* Imagen de la planta */
.cp-stage-img {
	max-height: 90px;
	object-fit: contain;
	position: absolute;
	bottom: 40px; /* Superpone el suelo para que las raíces queden dentro del marrón */
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
}

/* Nombre de la etapa como celda inferior */
.cp-stage-name {
	height: 30px;
	line-height: 29px; /* Centrado vertical */
	background: linear-gradient(to bottom, #fcfcfc, #ececec);
	font-weight: 700;
	font-size: 11px;
	color: #444;
	border: none;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	border-left: 1px solid rgba(0, 0, 0, 0.08);
	box-sizing: border-box;
	width: 100%;
	text-align: center;
	position: absolute;
	bottom: 0;
	left: 0;
	text-transform: uppercase;
	z-index: 3;
}

.cp-stage-col-bg:first-child .cp-stage-name {
	border-left: none;
}

/* Barras de Productos */
.cp-product-bar {
	color: white;
	padding: 4px 10px;
	font-size: 12px;
	font-weight: bold;
	text-transform: uppercase;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border-radius: 4px;
	margin: 0 2px; /* Pequeña separación horizontal */
	transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
	text-decoration: none;
	z-index: 2;
	position: relative;
}

.cp-product-bar:hover {
	transform: translateY(-2px); /* Se mueve hacia arriba sin aumentar su ancho */
	box-shadow: 0 4px 8px rgba(0,0,0,0.3);
	color: white;
	filter: brightness(1.08); /* Aclara sutilmente el color original */
}

/* Lista de Productos Inferior */
.cp-products-list-wrapper {
	display: grid;
	grid-template-columns: repeat(var(--cp-total-cols, 4), 1fr);
	gap: 40px 20px;
	margin-top: 40px;
}

.cp-category-group {
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
}

.cp-products-grid {
	display: grid;
	grid-template-columns: repeat(var(--cp-grid-cols, 4), 1fr);
	gap: 20px;
	margin-top: 15px;
}

.cp-product-card {
	border: 1px solid #eaeaea;
	border-radius: 8px;
	padding: 15px;
	text-align: center;
	background: #fff;
	transition: box-shadow 0.3s;
	display: flex;
	flex-direction: column;
}

.cp-product-card:hover {
	box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.cp-product-card-img {
	width: 100%;
	height: 150px;
	object-fit: contain;
	margin-bottom: 15px;
}

.cp-product-card-title,
h4.cp-product-card-title {
	font-size: 16px !important;
	font-weight: bold !important;
	color: #333 !important;
	margin: 0 0 10px 0 !important;
	flex-grow: 1 !important;
	white-space: nowrap !important;
	overflow: hidden !important;
	text-overflow: ellipsis !important;
	width: 100% !important;
	box-sizing: border-box !important;
}

.cp-product-card-cat {
	display: block !important;
	font-size: 12px;
	color: #777;
	text-transform: uppercase;
	margin-bottom: 15px;
	white-space: nowrap !important;
	overflow: hidden !important;
	text-overflow: ellipsis !important;
	width: 100% !important;
	box-sizing: border-box !important;
}

.cp-product-card-btn {
	display: inline-block;
	padding: 8px 15px;
	background-color: #5ab13f;
	color: #ffffff;
	text-decoration: none;
	border-radius: 4px;
	font-weight: 600;
	font-size: 14px;
	transition: background-color 0.2s, color 0.2s;
}

.cp-product-card-btn:hover {
	background-color: #4a9133;
	color: #ffffff;
}

/* Títulos de agrupación por categoría general */
.cp-category-group-title {
	font-size: 18px;
	font-weight: 700;
	text-transform: uppercase;
	margin-top: 45px;
	margin-bottom: 20px;
	padding-bottom: 8px;
	border-bottom: 2px solid #eaeaea;
	letter-spacing: 0.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	width: 100%;
	box-sizing: border-box;
}

/* Responsive */
@media (max-width: 768px) {
	.cp-filters-container {
		flex-direction: column;
		align-items: stretch;
	}
	
	.cp-products-list-wrapper {
		grid-template-columns: repeat(2, 1fr) !important;
	}

	.cp-category-group {
		grid-column: span 2 !important;
	}

	.cp-products-grid {
		grid-template-columns: repeat(2, 1fr) !important;
	}
}

@media (max-width: 480px) {
	.cp-products-list-wrapper {
		grid-template-columns: 1fr !important;
	}

	.cp-category-group {
		grid-column: span 1 !important;
	}

	.cp-products-grid {
		grid-template-columns: 1fr !important;
	}
}
