/* =========================================
   VARIABLES & RESET (THÈME VERT ÉCO)
   ========================================= */
:root {
    --primary-dark: #49911a;
    --primary-light: #9ecf2b;
    --primary-mid: #7da326;
    --primary-hover: #5e7a1d;
    
    --bg-color: #f4f7f6;
    --text-color: #333333;
    --text-muted: #666666;
    --white: #ffffff;
    --border-color: #e0e0e0;
    
    --success: #28a745;
    --success-bg: #d4edda;
    --danger: #dc3545;
    --danger-bg: #f8d7da;
    
    --shadow: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-hover: 0 5px 15px rgba(0,0,0,0.1);
    --radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 1rem;
}

main, .container {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    padding-bottom: 2rem;
}

/* =========================================
   HEADER (DÉGRADÉ VERT)
   ========================================= */
header {
    flex: 1; 
    background: linear-gradient(90deg, var(--primary-dark) 0%, var(--primary-light) 100%); 
    padding: 1.2rem 2rem; 
    border-radius: 0 8px 8px 0; 
    box-shadow: 0 4px 12px rgba(46, 92, 16, 0.3); 
    color: white; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin: 0;
}

header h1 {
    color: var(--white);
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    border: none;
    padding: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logout {
    font-size: 0.9rem;
    color: var(--white);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.logout:hover {
    background: rgba(255, 255, 255, 0.35);
    color: var(--white);
}

#langSwitcher {
    background: rgba(255, 255, 255, 0.2) url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") no-repeat right 10px top 50%;
    background-size: 10px auto;
    color: white;
    border: 1px solid rgba(255,255,255,0.5);
    font-weight: bold;
    cursor: pointer;
    padding: 5px 30px 5px 10px;
    border-radius: 4px;
    outline: none;
}

#langSwitcher option {
    color: #333;
    background: white;
}

/* =========================================
   FORMULAIRES & SEARCH
   ========================================= */
.search-box, .upload-section, .admin-search {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid rgba(0,0,0,0.05);
}

.search-box form, .admin-search form {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
    width: 100%;
}

.search-box input[type="text"], 
.admin-search input[type="text"] {
    flex: 2;
    min-width: 150px;
    white-space: nowrap;
}

.search-box select, 
.admin-search select {
    flex: 1;
    min-width: 120px;
    white-space: nowrap;
    cursor: pointer;
}

.search-box button, 
.admin-search button {
    flex: 0 0 auto;
    white-space: nowrap;
}

input[type="text"], 
input[type="url"], 
input[type="password"],
input[type="number"],
textarea, 
select {
    padding: 10px 12px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(148, 193, 45, 0.25);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-size: 0.95rem;
}

/* =========================================
   BOUTONS
   ========================================= */
button {
    background: var(--primary-mid);
    color: var(--white);
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

button:hover {
    background: var(--primary-hover);
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

button.delete-btn {
    background: var(--danger);
    padding: 6px 12px;
    font-size: 0.85rem;
}

button.delete-btn:hover {
    background: #a71d2a;
}

/* =========================================
   RÉSULTATS (CARDS) - MODIFIÉ POUR NOUVEAU TITRE
   ========================================= */
.result {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    padding-top: 2.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.result-badge, .badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--white);
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.std, .badge-std { background: var(--success); }
.non-std, .badge-non-std { background: var(--danger); }
.other, .badge-other { background: var(--text-muted); }


.result h3 {
    margin-top: 0;
    margin-bottom: 0.2rem; /* Réduit pour coller les refs */
    color: var(--primary-dark);
    font-size: 1.35rem; /* Titre légèrement plus grand */
    font-weight: 700;
    text-align: left;
    display: block; /* On repasse en block pour que les refs passent dessous */
    padding-right: 100px; /* Espace pour le badge Type */
    word-wrap: break-word;
}

.result-title {
    display: block;
    word-break: break-word;
}

.result-refs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    font-size: 0.9em; /* Taille réduite pour ne pas dominer le titre */
}

.ref-label {
    color: var(--text-muted);
    font-weight: 400; /* Enlève le gras */
    font-size: 0.9em;
}

.result .meta strong {
    color: var(--text-color);
    font-weight: 600; /* Gras modéré */
    font-size: 0.95rem; /* Même taille que le texte environnant */
}

.result .meta {
    font-size: 0.95rem; /* Taille de base unifiée */
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.result p {
    margin-bottom: 0.8rem;
    color: var(--text-color);
}

.result a {
    display: inline-block;
    color: #004d99;
    text-decoration: none;
    font-weight: 600;
    margin-top: 0.5rem;

    transition: border-color 0.3s, color 0.3s;
}

.result a:hover {
    border-bottom-color: #004d99;
    color: #003366;
}

/* =========================================
   ÉLÉMENTS DE RÉFÉRENCE (ID & VERSION)
   ========================================= */
.meta-id-small {
    color: var(--text-color);
    font-family: monospace;
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e1e4e8;
    font-weight: 600;
}

.version-tag {
    background: #eef2f7;
    color: var(--primary-dark);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
    border: 1px solid #dde2e9;
    text-transform: uppercase;
}

.meta-row {
    margin-bottom: 4px;
}

.link-source {
    font-size: 0.85em;
    margin-left: 5px;
    color: var(--primary-light);
    text-decoration: underline;
}

/* =========================================
   FICHIERS (STYLE GITHUB ASSETS)
   ========================================= */
.files-accordion {
    margin-top: 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #f8f9fa;
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    background: #f1f3f5;
    border: none;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    font-weight: 500; /* Diminué de 600/700 à 500 */
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem; /* Taille légèrement réduite */
    transition: background 0.2s;
}

.accordion-header:hover {
    background: #e9ecef;
}

.accordion-header .icon-chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
    stroke: var(--text-muted);
}

.files-accordion.open .icon-chevron {
    transform: rotate(180deg);
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: var(--white);
}

.files-accordion.open .file-list {
    max-height: 500px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px; /* Padding augmenté pour donner de l'air au bouton */
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.95rem;
    min-height: 50px; /* Force une hauteur minimale pour la ligne */
}

.file-item:last-child {
    border-bottom: none;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-icon {
    font-size: 1.2rem;
}

.file-name {
    font-weight: 500;
    color: var(--primary-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 5px;
}

.btn-download-small {
    background: var(--white);
    border: 1px solid #ccc; /* Bordure un peu plus visible */
    color: var(--text-color);
    padding: 8px 16px; /* Bouton plus haut et large */
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    margin-left: 15px;
    min-height: 36px; /* Hauteur minimale garantie */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-download-small:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* =========================================
   TABLEAUX (ADMIN)
   ========================================= */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    color: var(--primary-dark);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #fbfbfb;
}

td .badge {
    position: static;
    display: inline-block;
    box-shadow: none;
    padding: 3px 8px;
}

/* =========================================
   ALERTES & STATS
   ========================================= */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    border-left: 5px solid;
    font-weight: 500;
}

.alert.success, .alert-success {
    background: var(--success-bg);
    color: #155724;
    border-color: var(--success);
}

.alert.error, .alert-error {
    background: var(--danger-bg);
    color: #721c24;
    border-color: var(--danger);
}

.stats {
    margin-bottom: 1.5rem;
    font-style: italic;
    color: var(--text-muted);
    background: var(--white);
    padding: 0.8rem;
    border-radius: 4px;
    border: 1px solid #eee;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    display: none;
    padding: 2rem;
    font-weight: 500;
}

.error-msg {
    color: #721c24;
    background: var(--danger-bg);
    padding: 1rem;
    border-radius: 4px;
    display: none;
    margin-bottom: 1rem;
    border: 1px solid #f5c6cb;
}

/* =========================================
   FOOTER
   ========================================= */
footer {
    margin-top: auto;
    border-top: 1px solid #eee;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    width: 100%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

footer strong {
    color: var(--primary-light);
}

/* =========================================
   BOUTON INFO & MODAL
   ========================================= */
.info-btn {
    background: #ffffff;
    border: none;
    color: var(--primary-light);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: pulse-info 2s infinite;
}

.info-btn svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
}

.info-btn:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    background: #f0f8ff;
    animation: none;
}

.info-btn:active {
    transform: scale(0.95);
}

@keyframes pulse-info {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(49, 49, 49, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    overflow-y: auto;
    padding: 2rem 1rem;
}

.modal-content {
    background-color: var(--white);
    margin: 0 auto;
    max-width: 800px;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    animation: slideDown 0.3s ease-out;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, var(--primary-dark) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: white;
    border: none;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    color: var(--text-color);
    line-height: 1.8;
}

.modal-body h3 {
    color: var(--primary-dark);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    border-left: 4px solid var(--primary-light);
    padding-left: 10px;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    margin-bottom: 1rem;
    text-align: justify;
}

.modal-body .highlight {
    background: #eef2f7;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--success);
    font-style: italic;
    margin-top: 1.5rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    background: #f9f9f9;
    border-radius: 0 0 var(--radius) var(--radius);
}

.btn-primary {
    background: var(--success);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-primary:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.5rem;
    }

    header h1 {
        justify-content: center;
        font-size: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .result h3 {
        padding-right: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .result-title {
        min-width: auto;
        width: 100%;
    }

    .result-badge {
        position: static;
        float: right;
        margin-bottom: 5px;
    }

    .search-box form, .admin-search form {
        flex-wrap: wrap;
    }
    
    .search-box input[type="text"], 
    .admin-search input[type="text"],
    .search-box select, 
    .admin-search select,
    .search-box button, 
    .admin-search button {
        flex: 1 1 100%;
        margin-bottom: 5px;
    }

    .modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        text-align: center;
    }
}