/* Reset et styles de base */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: Arial, sans-serif;
	background-color: #f0f2f5;
	padding: 20px;
}

.container {
	max-width: 1400px;
	margin: 0 auto;
	background: white;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.1);
	overflow: hidden;
}

h1 {
	background: #5a6c7d;
	color: white;
	padding: 20px;
	text-align: center;
}

/* Sélecteur d'année */
.year-selector {
	padding: 15px;
	background: #f7fafc;
	display: flex;
	align-items: center;
	gap: 15px;
	flex-wrap: wrap;
}

.year-selector label {
	font-weight: bold;
	color: #5a6c7d;
}

.year-selector button {
	padding: 6px 12px;
	border: 2px solid #cbd5e0;
	background: white;
	color: #5a6c7d;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 500;
	transition: all 0.2s;
	min-width: 60px;
	text-align: center;
}

.year-selector button:hover {
	border-color: #5a6c7d;
	color: #5a6c7d;
}

.year-selector button.selected-year {
	background: #5a6c7d;
	color: white;
	border-color: #5a6c7d;
}

.year-selector button.selected-year:hover {
	color: white;
	background-color: #4b515c;
}

/* Tableau récapitulatif */
.table-container {
	overflow-x: auto;
	padding: 20px;
}

table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 30px;
}

th {
	background: #5a6c7d;
	color: white;
	padding: 12px;
	text-align: center;
	font-weight: bold;
	border: 1px solid #5a6c7d;
}

td {
	padding: 10px;
	text-align: center;
	border: 1px solid #e2e8f0;
}

tr:nth-child(even) {
	background-color: #f7fafc;
}

.type-cell {
	background: #cbd5e0;
	font-weight: bold;
	text-align: left;
	padding-left: 15px;
	color: #4a5568;
}

.budget-row {
	background: #5a6c7d !important;
	color: white;
	font-weight: bold;
}

.budget-row td {
	border-color: #2d3748;
}

.positive {
	color: #38a169;
	font-weight: bold;
}

.negative {
	color: #e53e3e;
	font-weight: bold;
}

/* Couleurs par catégorie pour le tableau récapitulatif */
.amount-salaire {
	color: #38a169;
	font-weight: bold;
}

.amount-revenus {
	color: #1FCC6E;
	font-weight: bold;
}

.amount-mensualite {
	color: #690000;
	font-weight: bold;
}

.amount-depense {
	color: #B00000;
	font-weight: bold;
}

.amount-achat {
	color: #166EB5;
	font-weight: bold;
}

/* Section données détaillées */
.data-section {
	margin-top: 30px;
	padding: 0 20px 20px 20px;
}

.data-header {
	display: flex;
	align-items: center;
	gap: 15px;
	margin-bottom: 15px;
	flex-wrap: wrap;
}

.toggle-button {
	background-color: #5a6c7d;
	color: white;
	padding: 12px 24px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 16px;
	transition: background 0.2s;
	font-weight: bold;
}

.toggle-button:hover {
	background-color: #4B515C;
}

.search-container {
	flex: 1;
	min-width: 250px;
	max-width: 400px;
	position: relative;
}

.search-input {
	width: 100%;
	padding: 10px 40px 10px 15px;
	border: 2px solid #cbd5e0;
	border-radius: 4px;
	font-size: 14px;
	transition: border-color 0.2s;
}

.search-input:focus {
	outline: none;
	border-color: #5a6c7d;
}

.search-input::placeholder {
	color: #a0aec0;
}

.clear-search {
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	color: #a0aec0;
	cursor: pointer;
	font-size: 18px;
	padding: 5px;
	display: none;
	transition: color 0.2s;
}

.clear-search:hover {
	color: #5a6c7d;
}

.clear-search.visible {
	display: block;
}

.data-content {
	display: none;
	animation: slideDown 0.3s ease;
}

.data-content.active {
	display: block;
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Barre de filtrage par mois */
.filter-bar {
	margin-bottom: 20px;
	padding: 15px;
	background: #f7fafc;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 15px;
}

.month-filters {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.month-btn {
	padding: 6px 12px;
	border: 2px solid #cbd5e0;
	background: white;
	color: #5a6c7d;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 500;
	transition: all 0.2s;
	min-width: 40px;
	text-align: center;
}

.month-btn:hover:not(.disabled) {
	border-color: #5a6c7d;
	color: #5a6c7d;
}

.month-btn.active {
	background: #5a6c7d;
	color: white;
	border-color: #5a6c7d;
}

.month-btn.disabled {
	background: #e2e8f0;
	color: #a0aec0;
	cursor: not-allowed;
	border-color: #e2e8f0;
}

.month-btn.active:hover {
	color: white;
	background-color: #4b515c;
}

.transaction-count {
	color: #666;
	font-size: 14px;
}

/* Container avec scroll pour les transactions */
.transactions-scroll-container {
	max-height: 540px;
	overflow-y: auto;
	overflow-x: auto;
	position: relative;
	border: 1px solid #e2e8f0;
	border-radius: 4px;
	max-width: 640px;
	margin: 0 auto;
}

/* Wrapper pour le tableau avec scroll */
.table-wrapper-scroll {
	position: relative;
	overflow: visible;
}

/* Tableau des transactions détaillées avec en-têtes fixes */
.transactions-table {
	width: 100%;
	min-width: 600px;
	border-collapse: collapse;
	background: white;
	table-layout: fixed;
}

.transactions-table thead {
	position: sticky;
	top: 0;
	z-index: 10;
}

.transactions-table th,
.transactions-table td {
	padding: 10px 15px;
	text-align: left;
	border-bottom: 1px solid #e2e8f0;
}

.transactions-table th {
	background-color: #5a6c7d;
	color: white;
	font-weight: bold;
	border: 1px solid #5a6c7d;
}

.transactions-table tbody tr:hover {
	background-color: #f7fafc;
}

.transactions-table td:first-child,
.transactions-table th:first-child {
	width: 100px;
}

.transactions-table td:nth-child(2),
.transactions-table th:nth-child(2) {
	width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.transactions-table td:nth-child(3),
.transactions-table th:nth-child(3) {
	width: 120px;
}

.transactions-table td:last-child,
.transactions-table th:last-child {
	width: 120px;
	text-align: right;
}

/* Couleurs par catégorie pour les transactions */
.cat-salaire {
	color: #38a169;
	font-weight: bold;
}

.cat-revenus {
	color: #1FCC6E;
	font-weight: bold;
}

.cat-mensualite {
	color: #690000;
	font-weight: bold;
}

.cat-depense {
	color: #B00000;
	font-weight: bold;
}

.cat-achat {
	color: #166EB5;
	font-weight: bold;
}

.no-data {
	text-align: center;
	padding: 40px;
	color: #a0aec0;
	font-style: italic;
}

/* Formulaire d'ajout */
.form-section {
	background: #edf2f7;
	padding: 30px;
	border-top: 3px solid #5a6c7d;
}

.form-section h2 {	
	color: #4a5568;
	margin-bottom: 20px;
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 15px;
	margin-bottom: 20px;
}

.form-group {
	display: flex;
	flex-direction: column;
}

label {
	font-weight: bold;
	margin-bottom: 5px;
	color: #5a6c7d;
}

input, select {
	padding: 10px;
	border: 1px solid #cbd5e0;
	border-radius: 4px;
	font-size: 14px;
}

input:focus, select:focus {
	outline: none;
	border-color: #5a6c7d;
	box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.btn {
	background: #5a6c7d;
	color: white;
	padding: 12px 30px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 16px;
	font-weight: bold;
	transition: background 0.3s;
}

.btn:hover {
	background: #4B515C;
}

/* Menu principal */
.main-menu {
	background: linear-gradient(135deg, #5a6c7d 0%, #4a5568 100%);
	padding: 0;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.menu-container {
	max-width: 1400px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	padding: 0 20px;
}

.menu-nav {
	display: flex;
	gap: 5px;
	align-items: center;
}

.menu-item {
	color: white;
	text-decoration: none;
	padding: 15px 20px;
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
	font-size: 15px;
	transition: all 0.3s ease;
	position: relative;
	border-radius: 4px;
}

.menu-item:hover {
	background: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
	background: rgba(255, 255, 255, 0.15);
	font-weight: 600;
}

.menu-item.active::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 20px;
	right: 20px;
	height: 3px;
	background: white;
	border-radius: 3px 3px 0 0;
}

.menu-icon {
	font-size: 18px;
}

/* Menu mobile */
.menu-toggle {
	display: none;
	background: none;
	border: none;
	color: white;
	font-size: 24px;
	cursor: pointer;
	padding: 10px;
}

/* ============================================ */
/* RESPONSIVE - MOBILE & IPHONE */
/* ============================================ */

@media (max-width: 768px) {
	/* Body et container mobile */
	body {
		padding: 0;
	}
	
	.container {
		border-radius: 0;
	}
	
	/* Menu mobile */
	.menu-toggle {
		display: block;
	}

	.menu-nav {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		background: #5a6c7d;
		flex-direction: column;
		gap: 0;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease;
		box-shadow: 0 4px 6px rgba(0,0,0,0.1);
	}

	.menu-nav.active {
		max-height: 300px;
	}

	.menu-item {
		width: 100%;
		padding: 15px 20px;
		border-radius: 0;
	}

	.menu-item.active::after {
		left: 0;
		right: 0;
	}

	.menu-container {
		position: relative;
	}
}

/* ============================================ */
/* EXERCICES */
/* ============================================ */
.success-message {
	background: #38a169;
	color: white;
	padding: 15px;
	border-radius: 4px;
	margin: 20px;
	text-align: center;
	font-weight: bold;
}

/* Les sélecteurs de semaine et séance utilisent maintenant year-selector */
.seance-content {
	padding: 20px;
}

/* Styles spécifiques pour les boutons de séance (2 lignes) */
.session-btn {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 12px !important;
	min-width: 100px;
	line-height: 1.3;
	height: auto;
}

.session-number {
	font-weight: 600;
	font-size: 13px;
}

.session-name {
	font-size: 11px;
	font-weight: 400;
	opacity: 0.85;
}

.session-btn.selected-year .session-name {
	opacity: 1;
}

.set-container {
	background: #f7fafc;
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 20px;
	border: 2px solid #cbd5e0;
}

.set-header {
	background: #5a6c7d;
	color: white;
	padding: 12px 20px;
	border-radius: 6px;
	margin-bottom: 15px;
	font-weight: bold;
	font-size: 16px;
}

.exercice-table {
	width: 100%;
	background: white;
	border-radius: 4px;
	overflow: hidden;
	margin-bottom: 15px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.exercice-name {
	background: #edf2f7;
	padding: 12px 15px;
	font-weight: bold;
	color: #4a5568;
	border-bottom: 2px solid #cbd5e0;
}

.exercice-inputs {
	padding: 15px;
}

/* MODIFICATION PRINCIPALE : champs côte à côte */
.input-row {
	display: flex;
	gap: 8px;
	margin-bottom: 10px;
	align-items: center;
	flex-wrap: nowrap;
}

.input-row label {
	width: 110px;
	min-width: 110px;
	font-weight: bold;
	color: #5a6c7d;
	font-size: 14px;
	flex-shrink: 0;
}

.input-row input {
	flex: 1;
	padding: 8px 4px;
	border: 1px solid #cbd5e0;
	border-radius: 4px;
	font-size: 14px;
	text-align: center;
	min-width: 50px;
	max-width: 70px;
}

.save-button-container {
	position: sticky;
	bottom: 0;
	background: white;
	padding: 20px;
	border-top: 3px solid #5a6c7d;
	box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
	z-index: 100;
}

.save-button {
	width: 100%;
	background: #38a169;
	color: white;
	padding: 15px;
	border: none;
	border-radius: 6px;
	font-size: 18px;
	font-weight: bold;
	cursor: pointer;
	transition: background 0.3s;
}

.save-button:hover {
	background: #2f855a;
}

.historique-section {
	padding: 20px;
	margin-top: 20px;
}

.historique-toggle {
	background: #5a6c7d;
	color: white;
	padding: 12px 24px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 16px;
	font-weight: bold;
	margin-bottom: 15px;
}

.historique-content {
	display: none;
	background: #f7fafc;
	border-radius: 8px;
	padding: 20px;
	max-height: 500px;
	overflow-y: auto;
}

.historique-content.active {
	display: block;
}

.historique-seance {
	background: white;
	border-radius: 6px;
	padding: 15px;
	margin-bottom: 15px;
	border-left: 4px solid #5a6c7d;
}

.historique-header {
	font-weight: bold;
	color: #5a6c7d;
	margin-bottom: 10px;
	padding-bottom: 10px;
	border-bottom: 2px solid #edf2f7;
}

.historique-exercice {
	padding: 8px 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid #edf2f7;
}

.historique-exercice:last-child {
	border-bottom: none;
}

.historique-details {
	font-size: 13px;
	color: #666;
}

/* Onglets historique */
.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-button {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #5a6c7d;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #4a5568;
}

.tab-button.active {
    color: #5a6c7d;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #5a6c7d;
    border-radius: 3px 3px 0 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.current-session-info {
    background: #f7fafc;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #5a6c7d;
}

.current-session-info h3 {
    color: #5a6c7d;
    margin-bottom: 8px;
}

.history-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #edf2f7;
}

.history-date {
    font-weight: bold;
    color: #5a6c7d;
    font-size: 16px;
}

.time-ago {
    color: #a0aec0;
    font-size: 13px;
}

.exercise-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f7fafc;
}

.exercise-row:last-child {
    border-bottom: none;
}

.exercise-name {
    font-weight: 600;
    color: #4a5568;
}

.exercise-stats {
    display: flex;
    gap: 15px;
    font-size: 14px;
}

.stat-item {
    color: #666;
}

.stat-value {
    font-weight: bold;
    color: #5a6c7d;
}

.exercise-selector {
    background: #f7fafc;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.exercise-selector label {
    display: block;
    font-weight: bold;
    color: #5a6c7d;
    margin-bottom: 8px;
}

.exercise-selector select {
    width: 100%;
    padding: 10px;
    border: 2px solid #cbd5e0;
    border-radius: 4px;
    font-size: 14px;
    color: #4a5568;
    background: white;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #5a6c7d 0%, #4a5568 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-card-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: bold;
}

.stat-card-unit {
    font-size: 14px;
    opacity: 0.8;
}

.chart-container {
    background: #f7fafc;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.chart-title {
    font-weight: bold;
    color: #5a6c7d;
    margin-bottom: 15px;
    font-size: 16px;
}

.chart {
    position: relative;
    height: 300px;
    background: white;
    border-radius: 6px;
    padding: 30px 20px 40px 60px;
}

.chart-grid {
    position: absolute;
    top: 30px;
    left: 60px;
    right: 20px;
    bottom: 40px;
}

.grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid #e2e8f0;
}

.grid-label {
    position: absolute;
    left: -45px;
    transform: translateY(-50%);
    font-size: 11px;
    color: #a0aec0;
}

.chart-line {
    position: absolute;
    top: 30px;
    left: 60px;
    right: 20px;
    bottom: 40px;
}

.chart-line svg {
    width: 100%;
    height: 100%;
}

.line-path {
    fill: none;
    stroke: #5a6c7d;
    stroke-width: 2;
}

.chart-axis {
    position: absolute;
    bottom: 10px;
    left: 60px;
    right: 20px;
    display: flex;
    justify-content: space-between;
}

.axis-label {
    font-size: 11px;
    color: #a0aec0;
    text-align: center;
}

/* Responsive mobile pour l'historique */
@media (max-width: 768px) {
    .tabs-container {
        overflow-x: auto;
    }
    
    .tab-button {
        padding: 10px 16px;
        font-size: 14px;
        white-space: nowrap;
    }
    
    .chart {
        padding: 30px 15px 40px 50px;
    }
    
    .chart-grid {
        left: 50px;
        right: 15px;
    }
    
    .chart-line {
        left: 50px;
        right: 15px;
    }
    
    .chart-axis {
        left: 50px;
        right: 15px;
    }
    
    .history-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .exercise-stats {
        flex-direction: column;
        gap: 5px;
    }
    
    .stats-summary {
        grid-template-columns: 1fr;
    }
}

/* RESPONSIVE MOBILE OPTIMISÉ */
@media (max-width: 768px) {
	/* Optimisation des boutons semaines et séances */
	.year-selector {
		padding: 10px 5px;
		gap: 4px;
		justify-content: space-between;
	}
	
	.year-selector button {
		padding: 8px 6px;
		font-size: 12px;
		min-width: 0;
		flex: 1;
		max-width: 24%;
	}
	
	/* Boutons de séance compacts */
	.session-btn {
		padding: 6px 4px !important;
		min-width: 0 !important;
		flex: 1;
		max-width: 24%;
	}
	
	.session-number {
		font-size: 11px;
	}
	
	.session-name {
		font-size: 9px;
		line-height: 1.2;
	}
	
	/* Champs d'exercices */
	.input-row {
		gap: 2px;
		flex-direction: row !important; /* Garde les champs côte à côte */
		flex-wrap: nowrap !important;
	}
	
	.input-row label {
		width: 60px;
		min-width: 60px;
		font-size: 13px;
	}
	
	.input-row input {
		padding: 10px 4px;
		font-size: 16px; /* Évite le zoom iOS */
		min-width: 45px;
		max-width: 60px;
	}
	
	.exercice-inputs {
		padding: 12px 10px;
	}
	
	.save-button-container {
		padding: 15px;
	}
	
	.set-container {
		padding: 12px;
	}
	
	.exercice-name {
		padding: 10px 12px;
		font-size: 14px;
	}
}

/* Très petits écrans (iPhone SE) */
@media (max-width: 375px) {
	.input-row label {
		width: 80px;
		min-width: 80px;
		font-size: 12px;
	}
	
	.input-row input {
		min-width: 40px;
		max-width: 50px;
		padding: 8px 2px;
		font-size: 15px;
	}
	
	.input-row {
		gap: 4px;
	}
}