// Styles pour le planning Formdev

.formdev-planning-general,
.formdev-planning-formation,
.formdev-planning-detail {
	padding: 30px 0;
	
	h2 {
		font-size: 28px;
		font-weight: bold;
		margin-bottom: 25px;
		color: #333;
	}
	
	h3 {
		font-size: 22px;
		font-weight: bold;
		margin-bottom: 15px;
		color: #444;
	}
	
	h4 {
		font-size: 18px;
		font-weight: 600;
		margin-bottom: 10px;
		color: #555;
	}
}

.planning-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 20px;
	margin-top: 20px;
}

.planning-formation-card {
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 20px;
	transition: box-shadow 0.3s ease;
	
	&:hover {
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
	}
	
	h3 {
		margin-top: 0;
		
		a {
			color: #005a87;
			text-decoration: none;
			
			&:hover {
				text-decoration: underline;
			}
		}
	}
}

.planning-session {
	margin-top: 15px;
	padding-top: 15px;
	border-top: 1px solid #ddd;
	
	&:first-child {
		border-top: none;
		padding-top: 0;
		margin-top: 0;
	}
}

.modules-list {
	list-style: none;
	padding: 0;
	margin: 15px 0;
	
	.module-item {
		padding: 12px 0;
		border-bottom: 1px solid #e0e0e0;
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		gap: 10px;
		
		&:last-child {
			border-bottom: none;
		}
		
		.module-date {
			font-weight: 600;
			color: #005a87;
			min-width: 140px;
			flex-shrink: 0;
		}
		
		.module-name {
			flex: 1;
			font-weight: 500;
			color: #333;
		}
		
		.module-time {
			font-size: 14px;
			color: #666;
			margin-left: 10px;
			font-weight: normal;
		}
		
		.module-location {
			font-size: 14px;
			color: #666;
			margin-left: auto;
			flex-basis: 100%;
			margin-top: 5px;
			padding-left: 150px;
			
			@media (max-width: 768px) {
				padding-left: 0;
			}
		}
	}
	
	// Ancien format (pour compatibilité)
	ul {
		list-style: none;
		padding: 0;
		margin: 0;
		
		li {
			padding: 8px 0;
			border-bottom: 1px solid #eee;
			
			&:last-child {
				border-bottom: none;
			}
			
			.module-title {
				display: block;
				margin-top: 5px;
				font-weight: 500;
			}
			
			.module-location {
				display: block;
				margin-top: 5px;
				font-size: 14px;
				color: #666;
			}
		}
	}
}

.sessions-list {
	display: flex;
	flex-direction: column;
	gap: 20px;
	margin-top: 20px;
}

.session-card {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 20px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
	
	.session-location {
		margin: 10px 0;
		color: #666;
		font-size: 14px;
	}
}

.modules-detail {
	margin-top: 15px;
}

.modules-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 15px;
	background: #fff;
	
	thead {
		background: #f5f5f5;
		
		th {
			padding: 12px;
			text-align: left;
			font-weight: 600;
			border-bottom: 2px solid #ddd;
			color: #333;
		}
	}
	
	tbody {
		tr {
			border-bottom: 1px solid #eee;
			
			&:hover {
				background: #f9f9f9;
			}
			
			&:last-child {
				border-bottom: none;
			}
		}
		
		td {
			padding: 12px;
			vertical-align: top;
			
			small {
				display: block;
				color: #666;
				font-size: 12px;
				margin-top: 4px;
			}
		}
	}
}

.modules-detail-list {
	margin-top: 20px;
}

.button.view-details {
	display: inline-block;
	margin-top: 15px;
	padding: 10px 20px;
	background: #005a87;
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	transition: background 0.3s ease;
	
	&:hover {
		background: #004070;
		color: #fff;
	}
}

// Styles pour la vue calendrier
.formdev-planning-calendar {
	padding: 30px 0;
	margin: 30px 0;
	
	.calendar-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 25px;
		flex-wrap: wrap;
		
		h2 {
			margin: 0;
			font-size: 28px;
		}
		
		.calendar-navigation {
			display: flex;
			align-items: center;
			gap: 15px;
			
			.calendar-nav-btn {
				padding: 8px 15px;
				background: #005a87;
				color: #fff;
				text-decoration: none;
				border-radius: 4px;
				transition: all 0.3s ease;
				border: none;
				cursor: pointer;
				font-size: 14px;
				position: relative;
				
				&:hover:not(:disabled):not(.loading) {
					background: #004070;
					color: #fff;
					transform: translateY(-1px);
					box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
				}
				
				&.loading {
					opacity: 0.7;
					cursor: wait;
					
					&::after {
						content: '';
						position: absolute;
						width: 14px;
						height: 14px;
						margin: auto;
						border: 2px solid transparent;
						border-top-color: #fff;
						border-radius: 50%;
						animation: spin 0.8s linear infinite;
						right: 8px;
						top: 50%;
						transform: translateY(-50%);
					}
				}
				
				&:disabled {
					opacity: 0.5;
					cursor: not-allowed;
				}
			}
			
			.current-month {
				font-weight: 600;
				font-size: 18px;
				min-width: 200px;
				text-align: center;
			}
		}
	}
	
	.calendar-container {
		overflow-x: auto;
		overflow-y: visible;
		margin-bottom: 20px;
		position: relative;
		min-height: auto;
		-webkit-overflow-scrolling: touch;
		
		.calendar-loader {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			background: rgba(255, 255, 255, 0.98);
			backdrop-filter: blur(2px);
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			z-index: 100;
			border-radius: 4px;
			opacity: 0;
			transition: opacity 0.3s ease-in-out;
			
			&.loading {
				opacity: 1;
			}
			
			.loader-spinner {
				width: 60px;
				height: 60px;
				border: 5px solid rgba(0, 90, 135, 0.1);
				border-top: 5px solid #005a87;
				border-right: 5px solid #005a87;
				border-radius: 50%;
				animation: spin 0.8s linear infinite;
				margin-bottom: 20px;
				box-shadow: 0 2px 10px rgba(0, 90, 135, 0.2);
			}
			
			p {
				color: #005a87;
				font-size: 15px;
				font-weight: 600;
				margin: 0;
				animation: pulse 1.5s ease-in-out infinite;
			}
		}
	}
	
	@keyframes spin {
		0% { transform: rotate(0deg); }
		100% { transform: rotate(360deg); }
	}
	
	@keyframes pulse {
		0%, 100% { opacity: 1; }
		50% { opacity: 0.6; }
	}
	
	.calendar-table {
		width: 100%;
		border-collapse: collapse;
		background: #fff;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		
		thead {
			background: #f5f5f5;
			
			th {
				padding: 12px;
				text-align: center;
				font-weight: 600;
				border: 1px solid #ddd;
				color: #333;
			}
		}
		
		tbody {
			td {
				border: 1px solid #ddd;
				padding: 0;
				vertical-align: top;
				width: 14.28%;
				height: auto;
				position: relative;
				
				&.empty-day {
					background: #f9f9f9;
				}
				
				&.today {
					background: #e3f2fd;
					
					.day-number {
						background: #005a87;
						color: #fff;
						font-weight: bold;
					}
				}
				
				&.has-events {
					background: #f0f8ff;
					cursor: pointer;
					
					&:hover {
						background: #e0f0ff;
					}
				}
				
				.day-number {
					padding: 5px;
					font-weight: 500;
					font-size: 14px;
				}
				
				.day-events-link {
					display: block !important;
					text-decoration: none !important;
					color: inherit !important;
					cursor: pointer !important;
					position: relative;
					z-index: 10;
					transition: opacity 0.2s ease;
					
					&:hover {
						opacity: 0.9;
						
						.day-events {
							background: #f0f8ff;
						}
					}
					
					// S'assurer que tous les éléments enfants héritent du comportement de lien
					* {
						pointer-events: none; // Désactiver les événements sur les enfants pour que le clic remonte au lien
					}
				}
				
				.day-events {
					padding: 5px;
					font-size: 11px;
					transition: background 0.2s ease;
					
					.event-count {
						display: block;
						background: #005a87;
						color: #fff;
						padding: 2px 5px;
						border-radius: 3px;
						margin-bottom: 5px;
						font-weight: 600;
					}
					
					.formation-name-header {
						margin-bottom: 6px;
						padding-bottom: 4px;
						border-bottom: 1px solid rgba(0, 90, 135, 0.2);
						
						strong {
							font-size: 11px;
							line-height: 13px;
							color: #005a87;
							font-weight: 600;
							display: block;
						}
					}
					
					.calendar-module-item {
						padding: 6px;
						margin-bottom: 6px;
						background: #fff;
						border-left: 3px solid #4caf50;
						border-radius: 3px;
						
						&:last-child {
							margin-bottom: 0;
						}
						
						.module-title {
							display: block;
							font-size: 10px;
							color: #333;
							margin-bottom: 4px;
							font-weight: 600;
							line-height: 12px;
						}
						
						strong {
							display: block;
							font-size: 11px;
							color: #333;
							margin-bottom: 4px;
							line-height: 13px;
							display: block;
						}
						
						small {
							display: block;
							color: #666;
							font-size: 10px;
							line-height: 1.4;
						}
					}
					
					.events-list {
						display: none;
						position: absolute;
						top: 100%;
						left: 0;
						right: 0;
						background: #fff;
						border: 1px solid #ddd;
						border-radius: 4px;
						box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
						z-index: 10;
						padding: 10px;
						margin-top: 5px;
						max-height: 300px;
						overflow-y: auto;
					}
					
					&:hover .events-list {
						display: block;
					}
					
					.calendar-event {
						padding: 8px;
						margin-bottom: 8px;
						background: #f9f9f9;
						border-radius: 4px;
						
						&:last-child {
							margin-bottom: 0;
						}
						
						&.calendar-module {
							border-left: 4px solid #4caf50;
							background: #f1f8e9;
						}
						
						.event-type-badge {
							display: inline-block;
							padding: 2px 6px;
							background: #005a87;
							color: #fff;
							font-size: 9px;
							font-weight: 600;
							text-transform: uppercase;
							border-radius: 3px;
							margin-bottom: 4px;
						}
						
						.calendar-module .event-type-badge {
							background: #4caf50;
						}
						
						strong {
							display: block;
							margin-bottom: 4px;
							color: #333;
							margin-top: 4px;
						}
						
						small {
							display: block;
							color: #666;
							font-size: 11px;
							line-height: 1.4;
							
							&.formation-name {
								margin-top: 4px;
								font-style: italic;
								color: #005a87;
								font-weight: 500;
							}
						}
					}
				}
			}
		}
	}
	
	// Vue planning : Sessions × Jours (une colonne Sessions, une colonne par jour, carrés modules)
	.calendar-months-wrapper {
		position: relative;
	}
	
	.calendar-table.calendar-table-sessions-view {
		table-layout: fixed;
		
		// Chaque mois est une table différente ; on n'affiche que le mois actif
		&.calendar-month {
			display: none;
			
			&.is-active {
				display: table;
			}
		}
		
		.calendar-col-sessions {
			width: 220px;
			min-width: 180px;
			max-width: 280px;
			padding: 10px 14px;
			font-weight: 600;
			background: #f5f5f5;
			border: 1px solid #ddd;
			vertical-align: middle;
		}
		
		.session-label-link {
			color: #005a87;
			text-decoration: none;
			
			&:hover {
				text-decoration: underline;
			}
		}
		
		thead .calendar-col-day {
			padding: 8px 4px !important;
			font-size: 12px !important;
			min-width: 32px;
			max-width: 32px;
			width: 32px !important;
			
			.day-letter {
				color: #666;
				margin-right: 1px;
			}
			
			&.weekend .day-letter {
				color: #005a87;
				font-weight: 600;
			}
		}
		
		.day-cell {
			padding: 6px 4px;
			vertical-align: middle;
			text-align: center;
			min-width: 32px;
			max-width: 32px;
			width: 32px;
			
			&.today {
				background: #e3f2fd;
			}
			
			&.weekend {
				background: #f9f9f9;
			}
			
			&.today.weekend {
				background: #d6eaf8;
			}
		}
		
		.day-modules-squares {
			display: flex;
			flex-wrap: wrap;
			gap: 4px;
			justify-content: center;
			align-items: center;
			min-height: 24px;
		}
		
		.module-square {
			display: inline-block;
			width: 14px;
			height: 14px;
			border-radius: 3px;
			flex-shrink: 0;
			border: 1px solid rgba(0, 0, 0, 0.12);
			
			&:hover {
				transform: scale(1.15);
				box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
			}
		}
		
		// Colonne Sessions fixe au scroll horizontal (mobile)
		.calendar-col-sessions {
			position: sticky;
			left: 0;
			z-index: 2;
			box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
		}
		
		thead .calendar-col-sessions {
			z-index: 3;
		}
	}
	
	.calendar-legend {
		display: flex;
		gap: 20px;
		margin-top: 20px;
		padding: 15px;
		background: #f9f9f9;
		border-radius: 4px;
		flex-wrap: wrap;
		
		.legend-item {
			display: flex;
			align-items: center;
			gap: 8px;
			
			.legend-color {
				width: 20px;
				height: 20px;
				border-radius: 3px;
				border: 1px solid #ddd;
				
				&.today {
					background: #e3f2fd;
					border-color: #005a87;
				}
				
				&.has-events {
					background: #f0f8ff;
					border-color: #005a87;
				}
				
				&.session {
					background: #e3f2fd;
					border-left: 4px solid #005a87;
				}
				
				&.module {
					background: #f1f8e9;
					border-left: 4px solid #4caf50;
				}
			}
		}
	}
}
#content-area table td.calendar-day{
	padding: 0;
}

// Responsive
@media (max-width: 768px) {
	.planning-list {
		grid-template-columns: 1fr;
	}
	
	.formdev-planning-calendar {
		.calendar-header {
			flex-direction: column;
			align-items: flex-start;
			gap: 15px;
			
			.calendar-navigation {
				width: 100%;
				justify-content: space-between;
				
				.current-month {
					font-size: 16px;
					min-width: auto;
				}
				
				.calendar-nav-btn {
					padding: 6px 12px;
					font-size: 14px;
				}
			}
		}
		
		// Scroll horizontal sur mobile : le tableau ne rétrécit pas, on fait défiler les jours
		.calendar-container {
			overflow-x: auto;
			-webkit-overflow-scrolling: touch;
			margin-left: -10px;
			margin-right: -10px;
			padding-left: 10px;
			padding-right: 10px;
		}
		
		.calendar-months-wrapper {
			position: relative;
		}
		
		.calendar-table.calendar-table-sessions-view {
			min-width: 1200px;
			table-layout: auto;
			
			&.calendar-month {
				display: none;
				
				&.is-active {
					display: table;
				}
			}
			
			.calendar-col-sessions {
				min-width: 160px;
				width: 160px;
			}
			
			.calendar-col-day,
			.day-cell {
				min-width: 32px;
				max-width: 32px;
				width: 32px;
			}
		}
		
		.calendar-table {
			tbody {
				td {
					height: 80px;
					
					.day-events {
						.event-count {
							font-size: 10px;
							padding: 1px 3px;
						}
						
						.events-list {
							position: fixed;
							top: 50%;
							left: 50%;
							transform: translate(-50%, -50%);
							width: 90%;
							max-width: 400px;
							max-height: 70vh;
							z-index: 1000;
						}
					}
				}
			}
		}
	}
	
	.modules-table {
		display: block;
		overflow-x: auto;
		white-space: nowrap;
		
		thead, tbody, tr, th, td {
			display: block;
		}
		
		thead {
			display: none;
		}
		
		tbody {
			tr {
				margin-bottom: 15px;
				border: 1px solid #ddd;
				border-radius: 4px;
				padding: 10px;
				
				td {
					padding: 8px 0;
					border-bottom: 1px solid #eee;
					
					&:before {
						content: attr(data-label) ": ";
						font-weight: 600;
						display: inline-block;
						width: 120px;
					}
					
					&:last-child {
						border-bottom: none;
					}
				}
			}
		}
	}
}
