/* ============================================
   Formation Hygiène & Salubrité — Common CSS
   Variables, Reset, Typo, Grille, Composants
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@600;700&display=swap');

:root {
    /* Couleurs principales */
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3d5c;
    --primary-bg: #eaf2f8;
    --accent: #27ae60;
    --accent-light: #2ecc71;
    --accent-dark: #1e8449;
    --warning: #f39c12;
    --warning-light: #fdebd0;
    --danger: #e74c3c;
    --danger-light: #fadbd8;
    --info: #3498db;
    --info-light: #d6eaf8;

    /* Texte */
    --text: #1a202c;
    --text-light: #4a5568;
    --text-muted: #718096;
    --text-inverse: #ffffff;

    /* Fonds */
    --bg: #ffffff;
    --bg-alt: #f7fafc;
    --bg-warm: #fafafa;
    --bg-dark: #1a202c;

    /* Bordures */
    --border: #e2e8f0;
    --border-light: #edf2f7;

    /* Ombres */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.15);

    /* Rayons */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Transitions */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;

    /* Typo */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;

    /* Largeurs */
    --max-width: 1200px;
    --content-width: 800px;
    --sidebar-width: 280px;
}

/* ============================================
   Reset
============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg-alt);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary-light); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: var(--primary); }
ul, ol { padding-left: 1.5em; }
table { border-collapse: collapse; width: 100%; }

/* ============================================
   Typographie
============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    color: var(--primary);
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1 { font-size: 2.2rem; font-weight: 700; }
h2 { font-size: 1.7rem; font-weight: 700; }
h3 { font-size: 1.3rem; font-weight: 600; font-family: var(--font-sans); }
h4 { font-size: 1.1rem; font-weight: 600; font-family: var(--font-sans); }

p { margin-bottom: 1em; }
strong { font-weight: 600; }

/* ============================================
   Composants de base
============================================ */

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(26,82,118,0.3);
}

.btn-primary:hover {
    background: var(--primary-light);
    color: var(--text-inverse);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26,82,118,0.4);
}

.btn-accent {
    background: var(--accent);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(39,174,96,0.3);
}

.btn-accent:hover {
    background: var(--accent-light);
    color: var(--text-inverse);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--text-inverse);
    transform: translateY(-2px);
}

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; }

/* Cartes */
.card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

.card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* Tags / Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-accent { background: #e8f8f0; color: var(--accent-dark); }
.badge-warning { background: var(--warning-light); color: #b7791f; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: #2471a3; }

/* Alertes */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.9rem;
}

.alert-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }

.alert-info { background: var(--info-light); border-left: 4px solid var(--info); }
.alert-warning { background: var(--warning-light); border-left: 4px solid var(--warning); }
.alert-danger { background: var(--danger-light); border-left: 4px solid var(--danger); }
.alert-success { background: #e8f8f0; border-left: 4px solid var(--accent); }

/* Grille */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Barre de progression */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 50px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 50px;
    transition: width 0.5s ease;
}

/* Listes stylées */
.list-check {
    list-style: none;
    padding: 0;
}

.list-check li {
    position: relative;
    padding-left: 1.8em;
    margin-bottom: 0.5em;
}

.list-check li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}

/* Tableaux */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.table-styled {
    width: 100%;
    border-collapse: collapse;
}

.table-styled th {
    background: var(--primary);
    color: var(--text-inverse);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-styled td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.table-styled tr:nth-child(even) td { background: var(--bg-alt); }
.table-styled tr:hover td { background: var(--primary-bg); }

/* Sections */
.section {
    padding: 3rem 0;
}

.section-title {
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-title h2 { margin-bottom: 0.5rem; }

.section-title p {
    color: var(--text-light);
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   Navigation header
============================================ */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.site-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: var(--text-inverse);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
    padding: 0;
}

.nav-links a {
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text);
}

.nav-toggle svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   Footer
============================================ */
.site-footer {
    background: var(--bg-dark);
    color: var(--text-inverse);
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
    font-size: 0.85rem;
}

.site-footer a {
    color: var(--accent-light);
}

/* ============================================
   Utilitaires
============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ============================================
   Responsive
============================================ */
@media (max-width: 968px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    .nav-links { display: none; }
    .nav-links.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg);
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
    .nav-toggle { display: block; }

    h1 { font-size: 1.6rem; }
    .container { padding: 0 1rem; }
}

@media (max-width: 480px) {
    html { font-size: 15px; }
    h1 { font-size: 1.4rem; }
    .btn { padding: 10px 20px; font-size: 0.9rem; }
    .card { padding: 1.25rem; }
}

/* ============================================
   Animations
============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-in {
    animation: fadeInUp 0.6s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* PWA Install / Update banner */
.pwa-install-banner {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    color: var(--text-inverse);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    box-shadow: var(--shadow-xl);
    z-index: 9999;
    transition: bottom 0.4s ease;
    max-width: 90vw;
}
.pwa-install-banner.visible { bottom: 20px; }
.pwa-install-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
.pwa-dismiss-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

/* Standalone (installed PWA) tweaks */
@media (display-mode: standalone) {
    .site-header { padding-top: env(safe-area-inset-top, 0); }
    body { padding-bottom: env(safe-area-inset-bottom, 0); }
}
