/* 
 * SimuBrick Investment Calculator - Custom Styles
 * Fallback styles and custom components for Tailwind CSS implementation
 * 
 * Color Palette:
 * - Body Background: #192b37 (Dark blue-gray)
 * - Primary: #116b76 (Primary teal)
 * - Hover: #22999f (Bright teal)
 * - Accent 1: #2ca9ab (Medium teal)
 * - Accent 2: #5dc7c3 (Light teal)
 */

/* Global reset and base styles - Fallback for when Tailwind doesn't load */
* {
    box-sizing: border-box;
}

/* Fallback styles in case Tailwind CSS doesn't load */
.fallback-body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #192b37;
    color: white;
    min-height: 100vh;
}

/* Custom animations and utilities */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* Custom focus styles for better accessibility */
.custom-focus:focus {
    outline: 2px solid #5dc7c3;
    outline-offset: 2px;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #116b76;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #22999f;
}

/* Mode Toggle Switch Styles */
#mode-toggle + label {
    position: relative;
    display: inline-block;
    margin: 0 1rem; /* Ajouter de l'espace autour du toggle */
}

#mode-toggle + label .block {
    display: block !important;
    width: 3.5rem !important; /* w-14 */
    height: 2rem !important; /* h-8 */
    background-color: #d1d5db !important; /* bg-gray-300 */
    border-radius: 9999px !important; /* rounded-full */
    transition: background-color 0.3s ease !important;
    cursor: pointer;
}

#mode-toggle:checked + label .block {
    background-color: #116b76 !important; /* Primary color */
}

#mode-toggle + label .dot {
    position: absolute !important;
    top: 0.25rem !important; /* top-1 */
    left: 0.25rem !important; /* left-1 */
    width: 1.5rem !important; /* w-6 */
    height: 1.5rem !important; /* h-6 */
    background-color: white !important;
    border-radius: 9999px !important; /* rounded-full */
    transition: transform 0.3s ease !important;
    transform: translateX(0) !important;
}

#mode-toggle:checked + label .dot {
    transform: translateX(1.5rem) !important; /* Move to right */
}

/* Mode labels styling with proper spacing */
#simple-mode-label {
    transition: all 0.3s ease;
    color: #116b76 !important;  /* Active par défaut (Estimation rapide) */
    font-weight: 600 !important;
    margin-right: 1rem; /* Espace à droite du label */
}

#complete-mode-label {
    transition: all 0.3s ease;
    color: #6b7280 !important;  /* Inactif par défaut (Analyse complète) */
    font-weight: 500 !important;
    margin-left: 1rem; /* Espace à gauche du label */
}

/* When toggle is checked (complete mode active) */
#mode-toggle:checked ~ #simple-mode-label {
    color: #6b7280 !important;
    font-weight: 500 !important;
}

#mode-toggle:checked ~ #complete-mode-label {
    color: #116b76 !important;
    font-weight: 600 !important;
}

/* Container spacing fix */
.flex.items-center.space-x-4 {
    gap: 1rem !important; /* Force un espacement uniforme */
}

/* Currency Toggle Switch Styles (similar to mode-toggle) */
#constant-currency-switch + label {
    position: relative;
    display: inline-block;
    margin: 0 1rem;
}

#constant-currency-switch + label .currency-toggle-bg {
    display: block !important;
    width: 3.5rem !important; /* w-14 */
    height: 2rem !important; /* h-8 */
    background-color: #d1d5db !important; /* bg-gray-300 */
    border-radius: 9999px !important; /* rounded-full */
    transition: background-color 0.3s ease !important;
    cursor: pointer;
}

#constant-currency-switch:checked + label .currency-toggle-bg {
    background-color: #9333ea !important; /* Purple-600 for constant currency */
}

#constant-currency-switch + label .currency-toggle-dot {
    position: absolute !important;
    top: 0.25rem !important;
    left: 0.25rem !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
    background-color: white !important;
    border-radius: 9999px !important;
    transition: transform 0.3s ease !important;
    transform: translateX(0) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

#constant-currency-switch:checked + label .currency-toggle-dot {
    transform: translateX(1.5rem) !important; /* Move to right */
}

/* Currency labels styling */
#nominal-currency-label {
    transition: all 0.3s ease;
    color: #116b76 !important;  /* Active by default */
    font-weight: 600 !important;
}

#constant-currency-label {
    transition: all 0.3s ease;
    color: #6b7280 !important;  /* Inactive by default */
    font-weight: 500 !important;
}

/* When toggle is checked (constant currency active) */
#constant-currency-switch:checked ~ #nominal-currency-label {
    color: #6b7280 !important;
    font-weight: 500 !important;
}

#constant-currency-switch:checked ~ #constant-currency-label {
    color: #9333ea !important;  /* Purple-600 */
    font-weight: 600 !important;
}

/* Smooth transitions for form fields */
.form-field {
    transition: all 0.3s ease;
}

.form-field.hidden {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Form field animations for mode switching */
.simple-mode .advanced-field {
    display: none !important;
}

.complete-mode .simple-field {
    display: block;
}

/* Loading spinner for future use */
.spinner {
    border: 3px solid #2ca9ab;
    border-top: 3px solid #5dc7c3;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    /* Hide navigation and non-essential elements */
    header,
    nav,
    footer,
    #hero-section,
    #form-container,
    .navigation-buttons,
    .mode-switch-container,
    #currency-mode-toggle,
    button {
        display: none !important;
    }
    
    /* Basic print styles */
    body {
        background: white !important;
        color: black !important;
    }
    
    /* Remove background colors for better printing */
    .bg-body-bg,
    .bg-primary,
    .bg-gradient-to-br,
    .bg-gradient-to-r {
        background: white !important;
    }
    
    /* Ensure charts print well */
    canvas {
        page-break-inside: avoid;
    }
    
    /* Better page breaks */
    .chart-container {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-body-bg {
        background-color: #000000 !important;
    }
    
    .text-white {
        color: #ffffff !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Form validation styles */
.invalid-input {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.valid-input {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* Tooltip styles for future implementation */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 400px;
    background-color: #116b76;
    color: white;
    text-align: left;
    border-radius: 6px;
    padding: 12px 16px;
    position: fixed;  /* ← SOLUTION DÉFINITIVE */
    z-index: 999999;
    top: 125%;
    left: 50%;
    margin-left: -200px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 14px;
    line-height: 1.4;
    white-space: normal;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Masquer les tooltips sur mobile */
@media (max-width: 768px) {
    .tooltip .tooltiptext {
        display: none;
    }
}

/* Mobile-specific styles - CORRECTION DES PROBLÈMES DE DÉBORDEMENT */
@media (max-width: 640px) {
    .mobile-padding {
        padding: 1rem !important;
    }
    
    .mobile-text-sm {
        font-size: 0.875rem !important;
    }
    
    /* CORRECTION PRINCIPALE : Container responsive */
    .container {
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* CORRECTION : Titres responsive */
    h1 {
        font-size: 1.5rem !important; /* Réduire drastiquement la taille */
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    h3 {
        font-size: 1.125rem !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* CORRECTION : Texte général responsive */
    p, span, div {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
    }
    
    /* CORRECTION : Bouton flottant Avis */
    .fixed.bottom-4.right-4 {
        bottom: 1rem !important;
        right: 1rem !important;
        z-index: 50 !important;
    }
    
    /* CORRECTION : Navigation responsive */
    nav ul {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    nav li {
        margin: 0 !important;
        width: 100% !important;
    }
    
    nav a {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 0.75rem !important;
    }
    
    /* CORRECTION : Header responsive */
    header {
        padding: 0.5rem !important;
    }
    
    header img {
        max-width: 80px !important;
        height: auto !important;
    }
    
    /* CORRECTION : Main content responsive */
    main {
        padding: 1rem !important;
    }
    
    /* CORRECTION : Fieldset responsive */
    fieldset {
        width: 100% !important;
        max-width: 100% !important;
        margin: 1rem auto !important;
        padding: 0.5rem !important;
    }
    
    legend {
        font-size: 1.25rem !important;
        text-align: center !important;
    }
}

/* CORRECTION SPÉCIFIQUE pour très petits écrans (360px et moins) */
@media (max-width: 360px) {
    .container {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    h1 {
        font-size: 1.25rem !important;
    }
    
    h2 {
        font-size: 1rem !important;
    }
    
    h3 {
        font-size: 0.875rem !important;
    }
    
    main {
        padding: 0.5rem !important;
    }
    
    fieldset {
        padding: 0.25rem !important;
    }
    
    /* Bouton Avis encore plus petit */
    .fixed.bottom-4.right-4 {
        bottom: 0.5rem !important;
        right: 0.5rem !important;
        transform: scale(0.9) !important;
    }
}

/* CORRECTION SPÉCIFIQUE POUR LES CLASSES TAILWIND */
@media (max-width: 640px) {
    /* Correction des classes Tailwind qui causent le débordement */
    .text-4xl, .text-5xl, .text-6xl {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    .text-2xl, .text-3xl {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
    }
    
    .text-xl {
        font-size: 1.125rem !important;
        line-height: 1.3 !important;
    }
    
    /* Correction des paddings Tailwind */
    .px-8, .px-12, .px-16 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Correction des marges Tailwind */
    .mx-auto {
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* Correction des largeurs Tailwind */
    .max-w-6xl {
        max-width: 100% !important;
    }
    
    .max-w-4xl {
        max-width: 100% !important;
    }
    
    .max-w-3xl {
        max-width: 100% !important;
    }
    
    /* Correction des flexbox Tailwind */
    .flex {
        flex-wrap: wrap !important;
    }
    
    .space-x-4 > * + * {
        margin-left: 0 !important;
        margin-top: 0.5rem !important;
    }
    
    .space-x-6 > * + * {
        margin-left: 0 !important;
        margin-top: 0.75rem !important;
    }
    
    /* Correction des grilles Tailwind */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Correction des boutons Tailwind */
    .btn, button {
        width: 100% !important;
        max-width: 100% !important;
        word-wrap: break-word !important;
    }
}

/* Dark mode support (already implemented but for future reference) */
@media (prefers-color-scheme: dark) {
    /* Our design is already dark, so this maintains consistency */
    .auto-dark {
        background-color: #192b37;
        color: white;
    }
}

/* Utility classes for specific use cases */
.glass-effect {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hover-lift {
    transition: transform 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
}

/* Chart container styles for future implementation */
.chart-container {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 2rem 0;
}

.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    background: rgba(17, 107, 118, 0.1);
    border-radius: 12px;
}

/* Custom button variants */
.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
}

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* ✅ CORRECTION : Empêche le scroll horizontal */
    height: 100%;
    max-width: 100vw; /* ✅ CORRECTION : Limite la largeur à la viewport */
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #fff5e5;
    /*padding-bottom: 60px;*/
	 margin: 0;
}

/* Legacy header/nav styles — scoped to .legacy-layout to avoid overriding the modern Tailwind header */
.legacy-layout header {
    padding: 1em;
    color: #2054a8;
    background: linear-gradient(to top right, #f3d8b9 30%, #fff5e5 100%);
    box-shadow: 1em 0.5em 1em 1em #968550;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.legacy-layout header img {
    width: 100px;
    height: 100px;
    margin-bottom: 1em;
}

/* Nav Links Styling — scoped */
.legacy-layout nav { margin-top: 0; }
.legacy-layout nav a { margin: 0 1em; padding: 0.5em; text-decoration: none; color: black; font-size: 14pt; font-family: "Arial";}
/* ... other link styles */
	
.logo-section {
    text-align: center;
    width: 100%;
}

hr {
    display: block;
    margin-top: 30px;
    margin-bottom: 0;
    border: none;
    border-top: 2px inset #ccc;
    width: 100%;
}

.legacy-layout nav {
    margin-top: 2px;
    margin-bottom: -1em;
}

main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    padding: 20px;
}

fieldset {
    margin: auto;
    width: 75em;
    padding: 1em;
}

legend {
    font-size: 22pt;
}

main { /* The key:  Let the main content expand to push down footer*/
  flex-grow: 1; 
}

footer {
  /* ... your regular footer styles ... */
  background-color: #02033C;
  color: white;
  text-align: right;
  align-items: center;         /* Vertically center */
  padding: 1em;
}

footer a {  /* Style the footer link */
    color: white;
    text-decoration: none;

}

.link1 {
    display: inline-block;
    position: relative;
    color: black;
    text-decoration: none;
    margin: 0 1em;
    padding: 0.5em 0;
}

.link1:after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: #0087ca;
    transform-origin: bottom right;
    transition: transform 0.25s ease-out;
}

.link1:hover:after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.link1:active {
    text-decoration: none;
    color: #1569c2;
}

table.a {
    font-size: 14pt;
    font-style: bold;
}

div.body_2 {
    height: 100em;
    background-color: #fff5e5;
    margin: 0;
    padding: 0;
}

div.center {
    margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

div.upper {
    margin: 0;
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translate(-50%, -50%);
}

r1, r2, r3, r4, r5 {
    font-size: 14pt;
    color: black;
    white-space: nowrap;
    font-family: "Arial";
    font-style: bold;
    padding: 1em;
}

.btn {
    background: #3498db;
    border-radius: 28px;
    font-family: Arial;
    color: #ffffff;
    font-size: 18px;
    padding: 10px 20px;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: #3cb0fd;
}

.btncv {
    background: #3498db;
    border-radius: 28px;
    font-family: Arial;
    color: #ffffff;
    font-size: 14px;
    padding: 10px 20px;
    text-decoration: none;
    cursor: pointer;
    margin: 15px 0px 7px 70px;
}

.valuePadding {
    border: 0px inset #ccc;
}

.valuePadding input {
    padding: 0px;
    outline: none;
    border-style: solid;
    border-width: 1px;
}

.champ {
    border: 1px solid #ccc;
    border-radius: 4px;
    float: right;
    background-color: #fff;
    height: 32px;
    box-sizing: border-box;
    position: relative;
    font-size: 0.9em;
    min-width: 130px;
    text-align: right;
}


.champ > .unite {
    float: left;
    height: 100%;
    line-height: 31px;
    width: 54px;
    padding: 0;
    font-size: 1em;
    font-weight: 400;
    color: #555;
    background-color: #eee;
    border: 0px solid #ccc;
    border-radius: 4px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    vertical-align: middle;
    text-align: center;
    position: absolute;
    right: 0;
}

p {
    margin: 0;
}

/* ✅ GARDER : Tous les autres styles nécessaires */
.je-ne-sais-pas-btn {
    position: relative;
    z-index: 999999;
}

/* ✅ NOUVEAU : Styles pour le bloc "Montant total à rembourser" */
.montant-total-rembourser {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border-radius: 0.75rem;
    padding: 2rem;
    color: white;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    margin-bottom: 2rem;
}

.montant-total-rembourser h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.montant-total-rembourser .montant {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.montant-total-rembourser .description {
    font-size: 1.125rem;
    opacity: 0.9;
}

/* Navigation optimisée - Organisation symétrique */
.nav-symmetrical {
    display: grid;
    grid-template-columns: auto 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.nav-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.nav-category-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Responsive navigation */
@media (max-width: 768px) {
    .nav-symmetrical {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .nav-column {
        width: 100%;
    }
}

/* Navigation Grid - Organisation symétrique */
.nav-grid {
    display: grid;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.nav-grid-4 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 4xl;
}

.nav-grid-3 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 3xl;
}

.nav-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.nav-item {
    text-align: center;
    width: 100%;
}

/* Responsive */
@media (max-width: 1024px) {
    .nav-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .nav-grid-4,
    .nav-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Navigation spacing fix - FORCER L'ESPACEMENT */
/* ❌ SUPPRIMER OU COMMENTER ces règles qui causent le débordement (lignes 700-741) */

/*
.nav-link {
    margin: 0 0.75rem !important;
    min-width: fit-content;
    display: inline-block;
}

.flex.gap-6 > * {
    margin-right: 1.5rem !important;
}

.flex.gap-6 > *:last-child {
    margin-right: 0 !important;
}

.nav-link {
    padding: 0.5rem 1rem !important;
    margin: 0 0.5rem !important;
    border: 1px solid transparent;
}

.nav-link:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 1024px) {
    .nav-link {
        margin: 0 0.25rem !important;
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem !important;
    }
}

@media (max-width: 768px) {
    .nav-link {
        margin: 0.25rem 0 !important;
        width: 100%;
    }
}
*/

/* Alternative avec padding */
.nav-link {
    border: 1px solid transparent;
}

.nav-link:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 1024px) {
    .nav-link {
        margin: 0 0.25rem !important;
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem !important;
    }
}

@media (max-width: 768px) {
    .nav-link {
        margin: 0.25rem 0 !important;
        width: 100%;
    }
}