/* --- VARIABLES ET RESET --- */
:root {
    --bg-color: #f3f4f6;
    --paper-white: #ffffff;
    --army-blue: #19223d;
    --text-dark: #1f2937;
    --accent-blue: #3b82f6;
    --dotted-color: #d1d5db;
    --gold: #e7e134;
}

/* * {
    box-sizing: border-box;
} */
body {
    margin: 0;
    padding: 0;
    background-color: var(--army-blue);
    font-family: 'JetBrains Mono', 'Courier New', Courier, monospace;
    color: var(--text-dark);
}

.lazyload {
    filter: blur(5px);
}

.print-container {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    border-collapse: collapse;
}

.header-space {
    height: 20px;
}

.fiche-container {
    background-color: var(--paper-white);
    padding: 40px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 100vh;
    max-width: calc(100% - 80px);
}

.main-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
}

.photo-frame {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--gold);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chasseur-name {
    font-size: 2.2rem;
}

.incorp-date {
    font-size: 1rem;
    color: #4b5563;
    margin: 0;
}

.notion-id {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 5px;
}

/* --- GRILLES D'INFORMATIONS --- */
.info-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

h2 {
    margin: 0;
}

.data-block {
    margin-bottom: 60px;
}

.block-title {
    background: var(--army-blue);
    color: white;
    padding: 6px 15px;
    font-size: 1.1rem;
    letter-spacing: 3px;
    margin-bottom: 20px;
}

.data-row {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.data-row span {
    color: #6b7280;
}

/* --- SIGNALEMENT --- */
.signalement-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 40px;
}

.sig-item {
    border-bottom: 1px dotted var(--dotted-color);
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
}

.sig-item .label {
    color: #1f2937;
}

.sig-item .value {
    color: var(--accent-blue);
    font-weight: bold;
}

/* --- TIMELINE --- */
.timeline {
    margin-left: 20px;
    border-left: 2px dashed var(--army-blue);
    padding-left: 30px;
}

.timeline-item {
    position: relative;
    margin-bottom: 25px;
}

.timeline-marker {
    position: absolute;
    left: -36px;
    top: 5px;
    width: 10px;
    height: 10px;
    background: var(--army-blue);
    border-radius: 50%;
}

.timeline-content .grade {
    display: block;
    font-weight: bold;
    font-size: 1.1rem;
}

.timeline-content .date {
    color: #6b7280;
    font-size: 0.9rem;
}

/* --- CITATIONS --- */
.citations-section {
    text-align: center;
    margin-top: 40px;
}

.citation-card {
    margin-bottom: 30px;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.cit-header {
    font-weight: bold;
    margin-bottom: 5px;
}

.cit-body {
    font-style: italic;
    color: #4b5563;
    line-height: 1.6;
}

/* --- FOOTER --- */
.fiche-footer {
    padding: 20px 40px;
    background: var(--paper-white);
}

.footer-line {
    border-top: 1px solid var(--army-blue);
    margin-bottom: 15px;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.footer-logo img {
    height: 50px;
    filter: grayscale(1);
    opacity: 0.8;
}

.footer-info {
    text-align: left;
}

.brand-name {
    font-weight: bold;
    font-size: 0.8rem;
    line-height: 1.2;
    margin: 0 0 5px 0;
    text-transform: uppercase;
}

.social-links {
    display: flex;
    gap: 15px;
    font-size: 0.75rem;
    color: #4b5563;
    align-items: baseline;
    justify-content: space-between;
}

.social-links a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.social-links a:hover {
    color: var(--accent-blue);
}

/* --- BOUTON ACTIONS --- */
.print-actions {
    display: flex;
    justify-content: center;
    padding: 30px 0;
}

.download-btn {
    background-color: var(--army-blue);
    color: white;
    padding: 14px 18px;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.grade-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.grade-icon {
    width: 24px;
    height: auto;
    object-fit: contain;
}

/* --- TABLE DES DÉCORATIONS --- */
.decorations-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.85rem;
    table-layout: fixed;
}

.decorations-table th {
    border-bottom: 2px solid var(--army-blue);
    padding: 12px 10px;
    text-align: left;
    color: var(--army-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.decorations-table td {
    padding: 12px 10px;
    border-bottom: 1px dotted var(--dotted-color);
    vertical-align: top;
    line-height: 1.4;
}

.col-nom {
    width: 30%;
}

.col-date {
    width: 20%;
}

.col-detail {
    width: 50%;
    font-style: italic;
    color: #4b5563;
}

/* ============================================================
   SECTION DOCUMENTS & ARCHIVES
   ============================================================ */
/* Conteneur global des sections documents */
.documents-section,
.pdf-section {
    width: 100%;
    margin-top: 40px;
}

/* --- GRILLE DES PHOTOS --- */
.photo-card {
    background: #ffffff;
    border: 1px solid var(--dotted-color);
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.photo-card:hover {
    transform: scale(1.02);
    background: var(--bg-color);
}

.photo-caption {
    display: block;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-dark);
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-break: break-all;
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    width: 100%;
}

.img-wrapper {
    width: 100%;
    height: 150px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #eee;
}

.img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: auto;
}

.pdf-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.pdf-row {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 5px solid var(--army-blue);
    /* Rappel de la couleur militaire */
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.pdf-row:hover {
    background: #f1f5f9;
    border-color: var(--accent-blue);
}

.pdf-icon {
    font-size: 1.8rem;
    margin-right: 20px;
}

.pdf-details {
    display: flex;
    flex-direction: column;
}

.pdf-name {
    font-weight: bold;
    font-size: 0.95rem;
    color: var(--army-blue);
    margin-bottom: 3px;
}

.pdf-action {
    font-size: 0.8rem;
    color: var(--accent-blue);
    font-style: italic;
}

/* --- SECTION BLESSURES --- */
.blessures-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.blessure-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 12px 15px;
    background: rgba(220, 38, 38, 0.03);
    /* Un fond rouge très très léger */
    border-left: 3px solid #dc2626;
    /* Un liseré rouge médical */
    border-bottom: 1px dashed var(--dotted-color);
}

.blessure-icon {
    color: #dc2626;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1;
}

.blessure-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-dark);
}

.name-container {
    display: flex;
    align-items: center;
    justify-content: center;
    /* À adapter si ton titre n'est pas centré */
    gap: 15px;
}

.chasseur-name-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.cocarde {
    width: 28px;
    height: 28px;
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.1));
    flex-shrink: 0;
}

.cocarde .rouge {
    background-color: #ce1126;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cocarde .blanc {
    background-color: #ffffff;
    width: 66%;
    height: 66%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cocarde .bleu {
    background-color: #002395;
    width: 50%;
    height: 50%;
    border-radius: 50%;
}

/* --- RÈGLES D'IMPRESSION (PDF) --- */
@media print {
    @page {
        margin: 0.5cm;
    }

    body {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        display: block;
    }

    .pdf-new-page {
        page-break-before: always !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        min-height: 90vh !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100%;
    }

    /* On s'assure que les titres de blocs restent bien en haut de leur contenu centré */
    .pdf-new-page .block-title {
        align-self: flex-start;
        width: 100%;
        margin-bottom: 30px;
    }

    .photo-card {
        break-inside: avoid;
        /* Évite de couper une photo entre deux pages */
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .pdf-section {
        display: none !important;
    }

    .pdf-row {
        background: white !important;
        border: 1px solid #eee !important;
        border-left: 5px solid #19223d !important;
    }

    .documents-section {
        page-break-before: always;
        min-height: 90vh;
        /* Centré verticalement comme les autres */
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .blessure-item {
        background: white !important;
        /* Pas de fond de couleur à l'impression */
        border-left: 3px solid #000 !important;
        /* Liseré noir pour plus de sobriété sur papier */
    }

    /* On cache les liens ou on les rend sobres à l'impression */
    .pdf-action {
        display: none;
    }

    .doc-card {
        break-inside: avoid;
        border: 1px solid #eee;
    }

    .print-actions {
        display: none !important;
    }

    .fiche-container {
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        padding: 20px 40px !important;
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .main-header,
    .info-grid,
    .signalement-section,
    .fiche-footer {
        width: 100% !important;
    }

    .print-container {
        width: 100% !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    tfoot {
        display: table-footer-group;
    }

    .data-block,
    .citation-card,
    .timeline-item,
    .sig-item,
    .main-header {
        page-break-inside: avoid;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .footer-space {
        height: 40px;
    }

    .fiche-footer {
        width: 100% !important;
        padding: 10px 0 !important;
        margin: 0 !important;
    }

    .signalement-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px 50px !important;
    }

    .social-links a {
        border: none;
        text-decoration: none;
    }

    .grade-icon {
        width: 20px;
        -webkit-print-color-adjust: exact !important;
    }

    .decorations-table {
        page-break-inside: avoid;
    }

    .decorations-table th {
        background-color: rgba(30, 41, 59, 0.05) !important;
        -webkit-print-color-adjust: exact !important;
    }

    .decorations-table td {
        border-bottom: 1px solid #eee !important;
    }
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    .chasseur-name {
        font-size: 1.5rem !important;
    }

    .main-header {
        flex-direction: column;
        text-align: center;
    }

    .info-grid,
    .signalement-grid {
        grid-template-columns: 1fr;
    }

    .photos-grid {
        grid-template-columns: 1fr;
        /* Une seule photo par ligne sur mobile */
    }

    .pdf-row {
        padding: 10px;
    }

    /* On cache l'en-tête du tableau qui ne sert plus à rien en mode vertical */
    .decorations-table thead {
        display: none;
    }

    .decorations-table,
    .decorations-table tbody,
    .decorations-table tr,
    .decorations-table td {
        display: block;
        width: 100% !important;
    }

    .decorations-table tr {
        margin-bottom: 20px;
        border: 1px solid var(--dotted-color);
        padding: 10px;
        background: rgba(255, 255, 255, 0.5);
    }

    .decorations-table td {
        border: none;
        padding: 5px 0;
        text-align: left;
        margin-bottom: 20px;
    }

    /* Ajout de labels automatiques pour savoir ce qu'on lit */
    .decorations-table td::before {
        content: attr(data-label);
        /* Utilise l'attribut HTML data-label */
        display: block;
        font-size: 0.7rem;
        text-transform: uppercase;
        color: var(--army-blue);
        font-weight: bold;
        margin-bottom: 2px;
    }

    /* Ajustement des largeurs spécifiques */
    .col-nom,
    .col-date,
    .col-detail {
        width: 100% !important;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-info {
        text-align: center;
    }

    .social-links {
        justify-content: center;
        flex-wrap: wrap;
    }
}