/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header ultra-compact */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.5rem 0;
    text-align: center;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header-content h1 {
    font-size: 1.4rem;
    color: #2c3e50;
    margin: 0;
}

.header-content h1 i {
    color: #e74c3c;
    margin-right: 0.3rem;
}

.header-content p {
    color: #7f8c8d;
    font-size: 0.8rem;
    margin: 0.2rem 0 0 0;
}

/* Section de recherche ultra-compacte */
.search-section {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 0.8rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.search-container {
    max-width: 1400px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    border-radius: 25px;
    overflow: hidden;
    max-width: 500px;
    margin: 0 auto 0.8rem auto;
}

.search-box input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: none;
    font-size: 0.9rem;
    outline: none;
    background: white;
}

.search-box input::placeholder {
    color: #bdc3c7;
}

.search-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: #2980b9;
}

/* Suggestions discrètes */
.quick-searches {
    text-align: center;
    margin-top: 0.5rem;
}

.quick-search-btn {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    margin: 0.1rem 0.2rem;
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    text-decoration: none;
    border-radius: 12px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(52, 152, 219, 0.2);
}

.quick-search-btn:hover {
    background: rgba(52, 152, 219, 0.2);
    transform: translateY(-1px);
}

/* Barre de logos sources - SOURCE-UX-001 */
.sources-logo-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 0.6rem;
    padding: 0.5rem 0;
}

.sources-label {
    font-size: 0.75rem;
    color: #7f8c8d;
    font-weight: 500;
}

.sources-logos {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.source-logo-link {
    display: block;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.9;
}

.source-logo-link:hover {
    transform: translateY(-2px) scale(1.05);
    opacity: 1;
}

.source-logo {
    height: 28px;
    width: auto;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Indicateur de chargement */
.loading-indicator {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    margin: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.spinner {
    width: 25px;
    height: 25px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Section des résultats - hauteur optimisée */
.results-section {
    flex: 1;
    padding: 0.8rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

/* Résumé ultra-compact */
.search-summary {
    background: rgba(255, 255, 255, 0.95);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
    flex-shrink: 0;
    height: auto;
}

.search-summary h3 {
    color: #2c3e50;
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
}

.summary-stats {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.stat-item {
    background: #ecf0f1;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    text-align: center;
}

.stat-number {
    font-size: 0.9rem;
    font-weight: bold;
    color: #3498db;
}

.stat-label {
    font-size: 0.6rem;
    color: #7f8c8d;
}

/* GRILLE 5 CARTES - HAUTEUR CALCULÉE */
.results-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
    flex: 1;
    min-height: 0;
}

/* Cartes des sources optimisées */
.source-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.source-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.source-header {
    padding: 0.8rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex-shrink: 0;
}

.source-info h3 {
    color: #2c3e50;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.source-info h3 i {
    margin-right: 0.3rem;
    font-size: 0.8rem;
}

.source-info p {
    color: #7f8c8d;
    font-size: 0.7rem;
    margin-bottom: 0.3rem;
    line-height: 1.2;
}

.source-count {
    background: #3498db;
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 35px;
    text-align: center;
}

.source-results {
    flex: 1;
    padding: 0.8rem;
    overflow-y: auto;
    font-size: 0.8rem;
}

.no-results {
    text-align: center;
    color: #7f8c8d;
    padding: 1rem 0.5rem;
}

.no-results i {
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
    display: block;
}

.no-results p {
    font-size: 0.75rem;
    line-height: 1.3;
}

/* Résultats individuels compacts */
.result-item {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 0.6rem;
    margin-bottom: 0.6rem;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    animation: slideInResult 0.3s ease-out;
}

.result-item:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.result-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.8rem;
    flex: 1;
    line-height: 1.2;
}

.result-cas {
    background: #e8f4fd;
    color: #3498db;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
}

.result-details {
    color: #7f8c8d;
    font-size: 0.75rem;
    line-height: 1.2;
}

.result-formula {
    font-family: monospace;
    background: #f8f9fa;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    margin-right: 0.2rem;
    font-size: 0.7rem;
}

/* Cartes spécifiques par source */
.inrs-card {
    border-top: 3px solid #e74c3c;
}

.inrs-card .source-count {
    background: #e74c3c;
}

.inrs-card .source-header {
    background: linear-gradient(135deg, #fee, #fdd);
}

.pubchem-card {
    border-top: 3px solid #3498db;
}

.pubchem-card .source-count {
    background: #3498db;
}

.pubchem-card .source-header {
    background: linear-gradient(135deg, #ebf3fd 0%, #d6eaf8 100%);
}

.agritox-card {
    border-top: 3px solid #27ae60;
}

.agritox-card .source-count {
    background: #27ae60;
}

.agritox-card .source-header {
    background: linear-gradient(135deg, #d4f1e6 0%, #c8e6db 100%);
}

.anses-card {
    border-top: 3px solid #f39c12;
}

.anses-card .source-count {
    background: #f39c12;
}

.anses-card .source-header {
    background: linear-gradient(135deg, #fef5e7 0%, #fcebdb 100%);
}

.echa-card {
    border-top: 3px solid #9b59b6;
}

.echa-card .source-count {
    background: #9b59b6;
}

.echa-card .source-header {
    background: linear-gradient(135deg, #f4f1f8 0%, #ebe4f2 100%);
}

/* ===== TOUS LES STYLES PUBCHEM ENRICHI PRÉSERVÉS ===== */

/* Badges de priorité et relevance pour PubChem */
.result-badges {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-end;
}

.result-priority {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-priority.high {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.result-priority.medium {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: white;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.result-priority.low {
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
    color: white;
    box-shadow: 0 2px 8px rgba(149, 165, 166, 0.3);
}

/* Style spécial pour les substances prioritaires HSE */
.pubchem-card .result-item.priority-substance {
    border-left: 4px solid #e74c3c;
    background: linear-gradient(90deg, rgba(231, 76, 60, 0.05), rgba(255, 255, 255, 0.8));
    position: relative;
    padding-left: 1.5rem;
}

.pubchem-card .result-item.priority-substance::before {
    content: "⭐";
    position: absolute;
    top: 0.5rem;
    left: 0.3rem;
    font-size: 0.8rem;
}

/* Enrichissement spécifique PubChem */
.pubchem-enriched-info {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border-left: 3px solid #3498db;
    font-size: 0.75rem;
}

.pubchem-enriched-info .info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.pubchem-enriched-info .info-row:last-child {
    margin-bottom: 0;
}

.pubchem-enriched-info .info-label {
    font-weight: 600;
    color: #2c3e50;
    margin-right: 0.5rem;
}

.pubchem-enriched-info .info-value {
    color: #7f8c8d;
}

/* Score de relevance médicale */
.medical-relevance-score {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #e8f4fd;
    color: #3498db;
    padding: 0.2rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.relevance-bar {
    width: 30px;
    height: 4px;
    background: #dee2e6;
    border-radius: 2px;
    overflow: hidden;
}

.relevance-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    transition: width 0.5s ease;
}

.relevance-bar-fill.high {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.relevance-bar-fill.medium {
    background: linear-gradient(90deg, #f39c12, #e67e22);
}

/* CID PubChem stylisé */
.pubchem-cid {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: monospace;
    display: inline-block;
    margin: 0.2rem 0;
}

/* Indicateurs HSE */
.hse-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.3rem;
}

.hse-indicator {
    background: #fff3cd;
    color: #856404;
    padding: 0.1rem 0.3rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 500;
    border: 1px solid #ffeaa7;
}

/* Cache local indicator pour PubChem */
.pubchem-card .source-header::after {
    content: "";
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}

.pubchem-card .source-header {
    position: relative;
}

.pubchem-cache-status {
    font-size: 0.7rem;
    color: #27ae60;
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.pubchem-cache-status::before {
    content: "⚡";
    font-size: 0.8rem;
}

/* Stratégie de recherche PubChem */
.pubchem-search-strategy {
    background: #e8f4fd;
    color: #3498db;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    border: 1px solid #bee5eb;
}

.strategy-local {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.strategy-local::before {
    content: "🏠 ";
}

.strategy-api::before {
    content: "🌐 ";
}

.strategy-fallback::before {
    content: "🎯 ";
}

/* Formule moléculaire enrichie */
.molecule-formula-enhanced {
    font-family: 'Courier New', monospace;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    display: inline-block;
    margin: 0.2rem 0;
}

/* Poids moléculaire avec unité */
.molecular-weight {
    background: #fff3cd;
    color: #856404;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
    margin: 0.2rem 0.2rem 0.2rem 0;
}

/* Synonymes PubChem */
.pubchem-synonyms {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: #6c757d;
    border-left: 2px solid #3498db;
}

.pubchem-synonyms .synonyms-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.2rem;
    display: block;
}

.synonym-item {
    display: inline-block;
    background: white;
    padding: 0.1rem 0.3rem;
    border-radius: 10px;
    margin: 0.1rem 0.2rem 0.1rem 0;
    border: 1px solid #e9ecef;
    font-size: 0.65rem;
}

/* Metadata PubChem en bas de carte */
.pubchem-metadata {
    background: #f8f9fa;
    padding: 0.5rem;
    font-size: 0.7rem;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
    margin-top: 0.5rem;
}

.pubchem-metadata .metadata-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.pubchem-metadata .metadata-item:last-child {
    margin-bottom: 0;
}

/* Animation pour les nouveaux résultats */
@keyframes slideInResult {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer ultra-compact */
.footer {
    background: rgba(44, 62, 80, 0.95);
    color: white;
    text-align: center;
    padding: 0.4rem;
    flex-shrink: 0;
    font-size: 0.7rem;
    height: 40px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    gap: 0.6rem;
}

.footer-links a {
    color: #bdc3c7;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 0.7rem;
}

.footer-links a:hover {
    color: white;
}

/* Messages d'erreur */
.error-message {
    background: #fee;
    color: #c0392b;
    padding: 0.8rem;
    border-radius: 6px;
    margin: 0.8rem 0;
    border-left: 4px solid #e74c3c;
    font-size: 0.8rem;
}

/* Responsive pour écrans plus petits - GARDE TOUJOURS 5 COLONNES */
@media (max-width: 1400px) {
    .results-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1200px) {
    .results-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 900px) {
    .results-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.4rem;
    }
    
    .search-section {
        padding: 0.6rem;
    }

    .source-header {
        padding: 0.6rem;
    }

    .source-info h3 {
        font-size: 0.8rem;
    }

    .source-info p {
        font-size: 0.65rem;
    }
    
    .result-badges {
        align-items: flex-start;
    }
    
    .pubchem-enriched-info {
        font-size: 0.7rem;
    }
    
    .hse-indicators {
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    .results-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.3rem;
    }
    
    .header-content h1 {
        font-size: 1.2rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 0.2rem;
    }

    .source-info h3 {
        font-size: 0.7rem;
    }

    .source-info p {
        font-size: 0.6rem;
    }

    .source-count {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
    
    .result-priority {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }
    
    .pubchem-card .result-item.priority-substance {
        padding-left: 1.2rem;
    }
    
    .molecular-weight,
    .pubchem-cid {
        font-size: 0.7rem;
    }
}