/* === DESIGN SYSTEM & RESET === */
:root {
    /* Typographie */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --font-serif: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", "Droid Serif", Times, "Source Serif Pro", serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --font-mono: "SF Mono", "Menlo", "Consolas", "Roboto Mono", "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
    
    --scale-0: 0.8rem; --scale-1: 1rem; --scale-2: 1.25rem; --scale-3: 1.563rem; --scale-4: 1.953rem; --scale-5: 2.441rem;
    
    /* Espacement & Grille */
    --space-xs: 0.25rem; --space-s: 0.5rem; --space-m: 1rem; --space-l: 1.5rem; --space-xl: 2rem; --space-xxl: 4rem;
    
    /* Rayons & Ombres */
    --radius-s: 4px; --radius-m: 8px; --radius-l: 16px;
    --shadow-s: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-m: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-l: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-std: 300ms ease-in-out;

    /* Thème clair par défaut */
    --color-bg: #F8F9FA;
    --color-bg-alt: #FFFFFF;
    --color-text: #212529;
    --color-text-muted: #6C757D;
    --color-border: #DEE2E6;
    --color-primary: #007BFF;
    --color-primary-light: #E6F2FF;
    --color-shadow: rgba(0, 0, 0, 0.1);
}

html[data-theme='dark'] {
    --color-bg: #121212;
    --color-bg-alt: #1E1E1E;
    --color-text: #E0E0E0;
    --color-text-muted: #9E9E9E;
    --color-border: #424242;
    --color-primary: #58A6FF;
    --color-primary-light: rgba(88, 166, 255, 0.1);
    --color-shadow: rgba(0, 0, 0, 0.4);
}

*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font-sans); color: var(--color-text); background-color: var(--color-bg);
    margin: 0; line-height: 1.6; font-size: 16px;
    transition: background-color var(--transition-std), color var(--transition-std);
}

/* === LAYOUT & STRUCTURE === */
.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-l); }
.site-header { padding: var(--space-l) 0; border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-xl); position: relative;}
.site-header h1 { font-family: var(--font-serif); font-size: var(--scale-5); margin: 0; }
.site-header p { font-size: var(--scale-2); color: var(--color-text-muted); margin: var(--space-s) 0 0; }
.site-footer { text-align: center; padding: var(--space-xl) 0; margin-top: var(--space-xxl); font-size: var(--scale-0); color: var(--color-text-muted); border-top: 1px solid var(--color-border); }

main.container { display: flex; flex-direction: column; gap: var(--space-xl); }

/* === NAVIGATION & VIEWS === */
.main-nav { display: flex; gap: var(--space-s); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-l); }
.nav-tab { padding: var(--space-s) var(--space-m); border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius-m) var(--radius-m) 0 0; cursor: pointer; text-decoration: none; color: var(--color-text-muted); transition: var(--transition-fast); }
.nav-tab:hover { background-color: var(--color-primary-light); color: var(--color-primary); }
.nav-tab.active { background-color: var(--color-bg-alt); border-color: var(--color-border); color: var(--color-text); font-weight: 600; }
.view.active { display: grid; } /* Utilisation de grid pour l'explorateur */

/* === EXPLORATEUR (FILTRES + GALLERIE) === */
#view-explorer { grid-template-columns: 280px 1fr; gap: var(--space-xl); }
.filters { background-color: var(--color-bg-alt); padding: var(--space-l); border-radius: var(--radius-l); border: 1px solid var(--color-border); box-shadow: var(--shadow-m); align-self: start; }
.filters h2 { margin-top: 0; }
.filter-group { margin-bottom: var(--space-l); }
.filter-group label { display: block; font-weight: 600; margin-bottom: var(--space-s); }
.search-wrapper { position: relative; }
.search-wrapper .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }
input[type="search"] { padding-left: 36px; }
input, select { width: 100%; padding: var(--space-s) var(--space-m); border: 1px solid var(--color-border); border-radius: var(--radius-m); background-color: var(--color-bg); color: var(--color-text); font-size: var(--scale-1); }
button, .chip-button { font-size: var(--scale-1); padding: var(--space-s) var(--space-m); border-radius: var(--radius-m); cursor: pointer; border: 1px solid var(--color-border); background-color: var(--color-bg-alt); color: var(--color-text); transition: var(--transition-fast); }
button:hover, .chip-button:hover { border-color: var(--color-primary); background-color: var(--color-primary-light); }
#reset-filters, #export-csv { width: 100%; margin-top: var(--space-s); }
.filter-actions { margin-top: var(--space-xl); display: flex; flex-direction: column; gap: var(--space-s); }

.chip-options { display: flex; flex-wrap: wrap; gap: var(--space-s); }
.chip-button { font-size: var(--scale-0); padding: var(--space-xs) var(--space-s); }
.chip-button.active { background-color: var(--color-primary); color: white; border-color: var(--color-primary); }

.active-filters-container { display: flex; flex-wrap: wrap; gap: var(--space-s); margin-bottom: var(--space-l); }
.active-filter-chip { display: inline-flex; align-items: center; background-color: var(--color-primary-light); color: var(--color-primary); padding: var(--space-xs) var(--space-s); border-radius: var(--radius-l); font-size: var(--scale-0); }
.active-filter-chip button { background: none; border: none; color: var(--color-primary); cursor: pointer; margin-left: var(--space-s); padding: 0; font-size: 1.2em; line-height: 1; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-l); }
.dino-card { background-color: var(--color-bg-alt); border-radius: var(--radius-l); border: 1px solid var(--color-border); overflow: hidden; box-shadow: var(--shadow-m); transition: transform var(--transition-fast), box-shadow var(--transition-fast); cursor: pointer; }
.dino-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-l); }
.dino-card-content { padding: var(--space-m); }
.dino-card h3 { margin: 0 0 var(--space-s) 0; font-size: var(--scale-2); }
.dino-card-meta { display: flex; flex-wrap: wrap; gap: var(--space-s); font-size: var(--scale-0); color: var(--color-text-muted); }
.dino-card-stats { margin-top: var(--space-m); padding-top: var(--space-m); border-top: 1px solid var(--color-border); display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-s); text-align: center; }
.dino-card-stats div > span:first-child { font-weight: 600; display: block; }

/* === DOCUMENTATION & TESTS VIEWS === */
.doc-content, .test-runner { background-color: var(--color-bg-alt); padding: var(--space-xl); border-radius: var(--radius-l); border: 1px solid var(--color-border); }
.doc-content h1, .doc-content h2 { font-family: var(--font-serif); border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-s); margin-top: var(--space-xl); }
.doc-content code { font-family: var(--font-mono); background-color: var(--color-primary-light); padding: 2px 4px; border-radius: var(--radius-s); font-size: 0.9em; }
.doc-content pre { background-color: var(--color-primary-light); padding: var(--space-m); border-radius: var(--radius-m); overflow-x: auto; }
.doc-content pre code { background: none; padding: 0; }
.doc-tabs { display: flex; gap: var(--space-s); margin-bottom: var(--space-l); }

#run-tests-btn { display: inline-block; width: auto; margin-bottom: var(--space-l); background-color: var(--color-primary); color: white; border: none; }
#run-tests-btn:hover { background-color: #0056b3; }
html[data-theme='dark'] #run-tests-btn:hover { background-color: #79b8ff; }

.test-results-container { margin-top: var(--space-l); font-family: var(--font-mono); font-size: var(--scale-0); }
.test-result { padding: var(--space-s); border-radius: var(--radius-m); margin-bottom: var(--space-s); border: 1px solid var(--color-border); }
.test-result.success { background-color: #d4edda; border-color: #c3e6cb; color: #155724; }
.test-result.failure { background-color: #f8d7da; border-color: #f5c6cb; color: #721c24; }
html[data-theme='dark'] .test-result.success { background-color: #1c3d2f; border-color: #2f6f4d; color: #a3e9a4; }
html[data-theme='dark'] .test-result.failure { background-color: #4d1b20; border-color: #8c2f39; color: #f5c6cb; }
.test-result summary { font-weight: bold; cursor: pointer; }
.test-result pre { white-space: pre-wrap; word-wrap: break-word; }

/* === MODAL === */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--color-bg); border-radius: var(--radius-l); box-shadow: var(--shadow-l); max-width: 800px; width: 90%; max-height: 90vh; overflow-y: auto; position: relative; padding: var(--space-xl); }
.modal-close { position: absolute; top: var(--space-m); right: var(--space-m); background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--color-text-muted); }
#modal-title { margin-top: 0; font-family: var(--font-serif); }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-l); margin-top: var(--space-l); }
.modal-grid h4 { margin-top: 0; margin-bottom: var(--space-s); border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-s); }
.calc-details { margin-top: var(--space-m); font-size: var(--scale-0); background: var(--color-primary-light); padding: var(--space-s); border-radius: var(--radius-m); }
.calc-details code { background: none; }

/* === THEME TOGGLE === */
#theme-toggle { position: absolute; top: var(--space-l); right: var(--space-l); background: none; border: 1px solid var(--color-border); border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#theme-toggle .icon { width: 24px; height: 24px; }
.icon-moon { display: none; }
html[data-theme='dark'] .icon-sun { display: none; }
html[data-theme='dark'] .icon-moon { display: block; }

/* === ACCESSIBILITY & RESPONSIVENESS === */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }

@media (max-width: 768px) {
    #view-explorer { grid-template-columns: 1fr; }
    .filters { margin-bottom: var(--space-l); }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
    .modal-grid { grid-template-columns: 1fr; }
}
