/* --- RESET & VARIABLES --- */
:root {
    --primary-color: #1a2332;   /* Bleu nuit / habit */
    --accent-color: #c5a059;    /* Or / Galon d'officier */
    --bg-light: #f5f2eb;        /* Papier chiffon / Parchemin clair */
    --card-bg: #ffffff;
    --text-color: #2c2a29;
    --text-muted: #666666;
    --border-color: #d8d3c5;

    /* Couleurs des Armées de 1815 */
    --color-france: #002366;     /* Bleu Impérial */
    --color-prusse: #1f2421;     /* Noir / Bleu très sombre prussien */
    --color-allies: #8b0000;     /* Rouge Cochenille (Redcoat) */

    --font-heading: 'Cinzel', 'Georgia', serif;
    --font-body: 'Lora', 'Times New Roman', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-light);
    color: var(--text-color);
    line-height: 1.6;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- HEADER & NAVIGATION --- */
.main-header {
    background-color: var(--primary-color);
    color: #fff;
    border-bottom: 3px solid var(--accent-color);
    padding: 1rem 0;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-area h1 {
    font-size: 1.75rem;
    color: var(--accent-color);
    letter-spacing: 1.5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.logo-area .subtitle {
    font-size: 1.5rem;
    color: #a0aab2;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.main-nav a {
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: background 0.3s;
}

.main-nav a:hover, .main-nav a.active {
    background-color: rgba(197, 160, 89, 0.2);
    color: var(--accent-color);
}

/* --- HERO --- */
.hero {
    background: linear-gradient(rgba(26, 35, 50, 0.85), rgba(26, 35, 50, 0.85)), url('img/hero-banner.jpg') center/cover;
    color: #fff;
    text-align: center;
    padding: 4rem 1.5rem;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.hero-buttons {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    transition: transform 0.2s, background 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #c5a059 0%, #a37f3a 100%);
    color: #111;
    border: 1px solid #7d5f23;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #d4af66 0%, #b38e47 100%);
}

.btn-secondary {
    display: inline-block;
    background-color: #6c757d;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease;
    border: 1px solid #5a6268;
}

.btn-secondary:hover {
    background-color: #5a6268;
    color: #ffffff;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
}

/* --- LAYOUT GENERAL --- */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* --- NATIONS GRID & CARDS --- */
.nations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.nation-card {
    border-radius: 8px;
    overflow: hidden;
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.nation-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.nation-card.france {
    border-top: 5px solid var(--color-france);
    background: linear-gradient(180deg, #0e1a2e 0%, var(--primary-color) 100%);
}

.nation-card.prusse {
    border-top: 5px solid #ffffff;
    background: linear-gradient(180deg, #181b19 0%, var(--primary-color) 100%);
}

.nation-card.anglo-allies {
    border-top: 5px solid var(--color-allies);
    background: linear-gradient(180deg, #2e1012 0%, var(--primary-color) 100%);
}

.nation-overlay {
    padding: 1.5rem;
    text-align: center;
}

.nation-overlay h3 {
    margin-bottom: 0.5rem;
}

.nation-overlay p {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 1rem;
}

.btn-card {
    display: inline-block;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Cocardes historiques CSS */
.cockade {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-bottom: 0.5rem;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.cockade-fr {
    background: radial-gradient(circle, #002366 30%, #ffffff 31%, #ffffff 60%, #ce1126 61%);
}

.cockade-pr {
    background: radial-gradient(circle, #ffffff 40%, #000000 41%);
}

.cockade-br {
    background: radial-gradient(circle, #000 0% 90%, #fff 90% 100%);
}

/* --- STRUCTURE 2 COLONNES --- */
.content-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 850px) {
    .content-layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    position: relative;
}

/* Filet de cadrage style gravure pour la colonne principale */
.main-column .card::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 1px solid rgba(197, 160, 89, 0.25);
    pointer-events: none;
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.status-box {
    margin-top: 1.5rem;
    background-color: var(--bg-light);
    padding: 1rem 1.2rem;
    border-left: 4px solid var(--accent-color);
    border-radius: 0 4px 4px 0;
}

.status-box h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.status-box ul {
    padding-left: 1.2rem;
    font-size: 0.95rem;
}

/* --- SIDEBAR & NOUVEAUTES --- */
.update-badge {
    background-color: var(--bg-light);
    padding: 0.5rem;
    text-align: center;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.news-list {
    list-style: none;
    margin-top: 1rem;
}

.news-list li {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
}

.news-date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.link-more {
    display: inline-block;
    margin-top: 0.5rem;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 0.85rem;
    text-decoration: none;
}

/* --- FOOTER --- */
.main-footer {
    background-color: var(--primary-color);
    color: #a0aab2;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
    font-size: 0.85rem;
    border-top: 3px solid var(--accent-color);
}

.footer-content strong {
    color: #fff;
}

/* --- VUE UNITE & SOUS-UNITE --- */
.planches-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    justify-content: center;
}

.planche-card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}

.planche-card img {
    max-width: 280px;
    height: auto;
    display: block;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}

.planche-card span {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: block;
}

.info-list p {
    margin-bottom: 0.8rem;
}

.subunits-list {
    list-style: square;
    padding-left: 1.5rem;
    margin-top: 1rem;
}

.subunits-list a {
    color: var(--primary-color);
    font-weight: bold;
    text-decoration: none;
}

.subunits-list a:hover {
    text-decoration: underline;
    color: var(--accent-color);
}

/* --- MOTEUR DE RECHERCHE (UNITES.PHP) --- */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.search-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.search-card.france { border-top: 5px solid var(--color-france); }
.search-card.prusse { border-top: 5px solid var(--color-prusse); }
.search-card.anglo-allies { border-top: 5px solid var(--color-allies); }

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background-color: var(--bg-light);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-search {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
}

.results-list {
    list-style: none;
    margin-top: 1rem;
    padding: 0;
}

.results-list li {
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.results-list li:last-child {
    border-bottom: none;
}

.results-list a {
    color: var(--primary-color);
    font-weight: bold;
    text-decoration: none;
}

.results-list a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.results-list .corps-tag {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: block;
}

/* --- UTILITAIRES & LAYOUT --- */
.mb-2 {
    margin-bottom: 2rem;
}

.mt-2 {
    margin-top: 2rem;
}

.mt-1 {
    margin-top: 1rem;
}

.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.text-muted-italic {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.8rem;
    font-style: italic;
}

.card-header-flex {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.search-form-stacked {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

/* --- ONGLET NATIONS --- */
.tabs-container {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab-button {
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--accent-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Disposition avec contenu additionnel à côté de la recherche */
.unites-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
}

@media (max-width: 850px) {
    .unites-layout {
        grid-template-columns: 1fr;
    }
}

/* --- BARRE DE SÉLECTION DES NATIONS EN HAUT --- */
.nations-top-bar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.nation-card-btn {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nation-card-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nation-card-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* --- GRILLE À 3 COLONNES --- */
.layout-3-cols {
    display: grid;
    grid-template-columns: 1fr 220px 220px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .layout-3-cols {
        grid-template-columns: 1fr;
    }
}

/* Encadrement et style des colonnes latérales de droite */
.type-column {
    background: #fdfbf7;
    border: 1px solid #dcd6cd;
    border-radius: 6px;
    padding: 1.25rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

/* Suppression des puces HTML et stylisation de la liste */
.type-column ul.types-menu {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.type-column ul.types-menu li {
    margin: 0;
    padding: 0;
}

/* Style des boutons cliquables */
.type-btn {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: #f4eee3;
    border: 1px solid #dcd6cd;
    border-radius: 4px;
    text-align: center;
    color: #2c2520 !important; /* Force la couleur du texte au lieu du bleu */
    text-decoration: none !important;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.type-btn:hover {
    background: #1f2937;
    color: #ffffff !important;
    border-color: #1f2937;
}

.type-btn.active {
    background: #1f2937;
    color: #ffffff !important;
    border-color: #1f2937;
}

.type-details-box {
    border-top: 1px solid #dcd6cd;
    padding-top: 1rem;
}

/* Animation de ciblage lors du retour sur la liste */
.subunits-list li:target,
.results-list li:target {
    background-color: #fef9c3;
    border-left: 4px solid var(--primary-color);
    padding-left: 0.5rem;
    transition: background-color 0.5s ease;
}

/* Alignement et dimensionnement des drapeau dans le menu des nations */
.nation-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.flag-icon {
    width: 20px;
    height: auto;
    vertical-align: middle;
}

/* ==========================================================================
   ORGANIGRAMMES MILITAIRES
   ========================================================================== */

.org-header-card {
    margin-bottom: 2rem;
    border-left: 5px solid #1e3a8a;
}

.org-tree-container {
    background: #ffffff;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.org-tree, 
.org-tree ul {
    list-style: none;
    padding-left: 24px;
    margin: 0;
    position: relative;
}

.org-tree ul {
    border-left: 2px dashed #cbd5e1;
    margin-left: 12px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.org-tree li {
    margin: 10px 0;
    position: relative;
}

/* Lignes horizontales reliant les nœuds */
.org-tree ul li::before {
    content: "";
    position: absolute;
    top: 18px;
    left: -24px;
    width: 20px;
    height: 2px;
    background-color: #cbd5e1;
}

.org-tree li.collapsed > ul {
    display: none;
}

/* Style des badges / cartes de nœuds */
.org-node {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 6px;
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    cursor: default; /* Flèche par défaut pour tout le nœud */
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.org-node:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

/* Niveaux d'organisation */
.node-corps {
    background: #1e3a8a;
    color: #ffffff;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.05rem;
    border: 1px solid #1d4ed8;
}

.node-division {
    background: #2563eb;
    color: #ffffff;
    font-weight: 600;
}

.node-brigade {
    background: #059669;
    color: #ffffff;
    font-weight: 600;
}

.node-regiment {
    background: #f8fafc;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.node-regiment.direct {
    background: #fffbebf8;
    border-color: #fde68a;
    color: #78350f;
}

/* Toggle de pliage / dépliage */
.toggle-icon {
    font-size: 0.75rem;
    margin-left: 6px;
    transition: transform 0.2s ease;
    cursor: pointer; /* Curseur main sur le triangle de dépliage */
}

.collapsed > ul {
    display: none !important;
}

.collapsed > .org-node .toggle-icon {
    transform: rotate(-90deg);
}

.badge-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 6px;
}

.alert-error {
    background-color: #fee2e2;
    border: 1px solid #f87171;
    color: #991b1b;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.compteur {
  font-size: 0.85rem;
  color: #a0aab2; /* Même nuance que sous-titre */
  margin-top: 5px;
}

.compteur strong {
  color: #d4a359; /* Teinte dorée rappelant le titre principal */
  font-weight: normal;
}

/* Container de la planche pour gérer le survol */
.planche-card {
  position: relative;
}

/* Modale cachée par défaut */
.image-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90vw;
  max-height: 90vh;
  z-index: 9999;
  background-color: rgba(0, 0, 0, 0.85);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none; /* Évite les conflits de survol */
}

.image-popup img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  display: block;
}

/* Affichage uniquement sur PC (souris/survol disponible) */
@media (hover: hover) and (pointer: fine) {
  .planche-card:hover .image-popup {
    display: block;
  }
}

.main-nav a.main-site-link {
    font-weight: bold;
    color: #d9534f; /* Remplacez par la couleur de votre choix */
    border-right: 1px solid #ccc; /* Ajoute un séparateur visuel si besoin */
    padding-right: 12px;
}

/* CSS pour la separation Depliage / Lien */
.node-toggle {
    cursor: default; /* Curseur flèche par défaut pour la zone symbole */
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.org-icon {
    cursor: default; /* L'icône est par défaut non cliquable (curseur flèche) */
}

.node-toggle a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer; /* Curseur main si enveloppée d'un lien d'officier */
}

.node-toggle a .org-icon {
    cursor: pointer; /* Curseur main sur l'image d'officier cliquable */
}

.node-toggle a:hover img {
    transform: scale(1.08);
    transition: transform 0.15s ease-in-out;
}

.node-label {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
    cursor: pointer; /* Curseur main uniquement sur les liens de nom d'unité */
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.node-label:hover {
    color: #0056b3;
    text-decoration: underline;
}

.node-title {
    cursor: default; /* Curseur flèche quand l'unité n'a pas de lien cliquable */
}