/* ===================== */
/* MISE À JOUR DU DESIGN */
/* ===================== */
:root {
    --primary-color: #0077B6;
    --background-light: #F8F9FA;
    --background-dark: #E9ECEF;
    --text-color: #343A40;
    --border-color: #DEE2E6;
    --card-bg: #FFFFFF;
}

/* Base */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* HEADER */
.site-header {
    background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('cave.png') no-repeat center center/cover;
    color: white;
    padding: 60px 20px;
    text-align: center;
    border-bottom: 5px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: relative; /* Nécessaire pour le positionnement de la nav */
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.site-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin: 0;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.7);
    position: relative;
    z-index: 2;
}

.site-slogan {
    font-size: 1.2em;
    font-style: italic;
    color: #f0f0f0;
    margin-top: 5px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    position: relative;
    z-index: 2;
}

nav {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    position: relative;
    z-index: 2;
}

nav a {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    padding: 8px 15px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.3s ease, transform 0.2s ease;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

/* MAIN CONTENT */
main {
    max-width: 900px;
    margin: 30px auto;
    padding: 30px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.disclaimer {
    font-size: 0.9em;
    color: #6C757D;
    text-align: center;
    margin-bottom: 20px;
}

/* Converter */
.mode-switch {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    padding: 12px 20px;
    font-size: 1em;
    border-radius: 25px;
    border: 2px solid var(--primary-color);
    background-color: var(--card-bg);
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 119, 182, 0.3);
}

.mode-btn:hover:not(.active) {
    background-color: var(--background-light);
}

.converter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    align-items: center;
}

#amount, #fromCurrency, #toCurrency {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    background-color: var(--background-light);
}

#convertBtn {
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#convertBtn:hover {
    background-color: #005F8D;
    transform: translateY(-2px);
}

#result {
    margin-top: 25px;
    padding: 25px;
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #00A6D6);
    color: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 119, 182, 0.4);
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sections d'information */
section {
    padding: 30px;
    margin-top: 30px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

section h2, section h3 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--background-dark);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

ul {
    padding-left: 20px;
}

/* CHART SECTION */
#evolution-dirham .chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    align-items: center;
}

#deviseSelect {
    flex-grow: 1;
    min-width: 180px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#generateChart {
    flex-grow: 0;
    white-space: nowrap;
}

#mad-chart-container {
    margin-top: 25px;
    height: 400px;
    position: relative;
}

/* FOOTER */
footer {
    padding: 25px;
    text-align: center;
    background-color: var(--background-dark);
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: #005F8D;
}

/* MEDIA QUERIES */
@media (max-width: 768px) {
    .site-header h1 {
        font-size: 2em;
    }
    nav a {
        padding: 6px 10px;
        font-size: 0.9em;
    }
    main {
        padding: 20px;
        margin: 20px auto;
    }
    .converter-form {
        grid-template-columns: 1fr;
    }
    #result {
        font-size: 1.5em;
    }
}

/* Style pour la nouvelle section de graphique */
.chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
}

#countrySelect {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--card-bg-color);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    max-width: 300px;
}

#generateComparisonChart {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    background-color: var(--primary-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#generateComparisonChart:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

.chart-container-large {
    position: relative;
    width: 100%;
    max-width: 900px; /* Limite la largeur du graphique sur les grands écrans */
    margin: 0 auto;
}

.source-info {
    font-size: 0.85rem;
    color: var(--text-color-secondary);
    text-align: center;
    margin-top: 15px;
}

/* Styles pour la section de comparaison économique */

/* Règle globale pour le conteneur de section afin de respecter le design des autres sections */
#ratings-pib {
    padding: 30px;
    margin-top: 30px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* Conteneur des cartes de détails pour une présentation visuelle */
.comparison-details-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
}

.country-details-card {
    background-color: var(--background-dark);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    flex: 1 1 250px; /* Flexbox pour gérer la taille sur différentes résolutions */
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

.country-details-card h4 {
    margin-top: 0;
    color: var(--primary-color);
}

.rating-badge {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.rating-agency {
    display: block;
    font-size: 0.75rem;
    font-weight: normal;
    opacity: 0.8;
}

.gdp-info {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

/* Ajustement pour que le select s'intègre mieux */
.chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
}

#countrySelect {
    padding: 10px;
    border-radius: 8px;
    background-color: var(--background-light);
    color: var(--text-color);
    font-size: 1em;
    border: 1px solid var(--border-color);
}