:root {
  /* Developer / GitHub / Modrinth structural tokens */
  --bg-page: #f6f8fa; /* GitHub Light bg */
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;

  /* Borders & Shadows (Strictly non-AI, very tight) */
  --border-color: #d0d7de; /* GitHub border */
  --border-light: #e5e7eb;
  --shadow-card: 0 1px 3px rgba(27, 31, 36, 0.04);
  --shadow-btn: 0 1px 0 rgba(27, 31, 36, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  
  /* Corner radius (Small and professional) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* The User's Light Blue Brand */
  --primary: #4da3ff;
  --primary-hover: #3a96fa;
  --primary-active: #2b84e8;
  --primary-subtle: rgba(77, 163, 255, 0.1);

  /* Typography */
  --text-main: #24292f;
  --text-muted: #57606a;
  
  /* Statuses */
  --success: #1a7f37;
  --success-bg: #dafbe1;
  --danger: #cf222e;
  --danger-bg: #ffebe9;
  
  /* Mobile UI */
  --header-height: 60px;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* ──────────────────────────────────────────────
   LAYOUT DESKTOP
────────────────────────────────────────────── */
#network-container {
    flex-grow: 1;
    height: 100%;
    width: 100%;
    background-color: var(--bg-page);
    position: relative;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

header#main-header {
    position: absolute;
    left: 16px;
    top: 16px;
    width: 296px;
    height: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.hamburger-btn {
    display: none; /* Masqué sur desktop */
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-main);
    cursor: pointer;
}

#header-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 16px;
}

h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

h1 span {
    color: var(--primary);
}

p.subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
}

.search-input {
  width: 100%;
  padding: 5px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-main);
  box-shadow: inset 0 1px 0 rgba(208, 215, 222, 0.2);
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

/* Nav Links */
.nav-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: var(--radius-md);
    transition: background-color 0.2s;
}

.nav-links a:hover {
    background-color: var(--bg-hover);
}

.nav-links i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
}

.header-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Boutons */
.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border: 1px solid rgba(27, 31, 36, 0.15);
  border-radius: var(--radius-md);
  padding: 5px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: 0.2s background-color;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-outline {
  background-color: var(--bg-page);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 5px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: 0.2s background-color;
}

.btn-outline:hover {
  background-color: var(--bg-hover);
}

/* ──────────────────────────────────────────────
   REACT FLOW CUSTOM NODE PREMIUM
────────────────────────────────────────────── */
.pro-card-node {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left-width: 4px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    width: 220px;
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 12px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pro-card-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.pro-card-node.selected {
    box-shadow: 0 0 0 2px var(--primary), 0 6px 16px rgba(0,0,0,0.08);
}

.pro-card-node.dead {
    opacity: 0.6;
    border-style: dashed;
    border-left-style: solid; /* On garde la couleur de la barre de gauche */
}

.pro-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.node-logo {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.pro-card-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.pro-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pro-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pro-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.pro-tag.category {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.pro-tag.status.active {
    background: var(--success-bg);
    color: var(--success);
}

.pro-tag.status.dead {
    background: var(--danger-bg);
    color: var(--danger);
}

/* React flow overrides */
.custom-handle {
    width: 10px;
    height: 10px;
    background-color: #8c959f;
    border: 2px solid var(--bg-card);
}

.custom-controls {
    bottom: 30px !important; /* Espacement pour mobile */
}

/* ──────────────────────────────────────────────
   PANNEAU DE DÉTAILS
────────────────────────────────────────────── */
#details-panel.card {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 320px;
    height: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
    overflow-y: auto;
    transition: transform 0.2s ease-out;
}

#details-panel.hidden {
    transform: translateX(120%);
}

.status-badge {
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 2em;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(27, 31, 36, 0.15);
    background-color: var(--success-bg);
    color: var(--success);
}

.status-badge.dead {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.category-tag {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    display: inline-block;
    width: fit-content;
}

.relations-group {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 8px;
}

.relations-group h3 {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 0 8px 0;
}

.relations-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.relation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    margin: 0 -8px;
    border-radius: var(--radius-md);
    transition: background-color 0.2s;
}

.relation-item:hover {
    background-color: var(--primary-subtle);
    text-decoration: underline;
}

.relation-tag {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 6px;
    border-radius: 2em;
    border: 1px solid var(--border-color);
    background-color: var(--bg-page);
    text-decoration: none !important;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.close-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.details-drag-handle {
    display: none;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s;
}

/* ──────────────────────────────────────────────
   RESPONSIVE MOBILE (La fameuse refonte)
────────────────────────────────────────────── */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    /* Le header devient une Navbar Sticky en haut */
    header#main-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        z-index: 20;
        padding: 0; /* padding géré à l'intérieur */
    }

    .header-top {
        padding: 12px 16px;
        margin: 0;
        background: var(--bg-card);
    }

    .hamburger-btn {
        display: block; /* Visible sur mobile */
    }

    /* Le contenu du menu (masqué par défaut, s'affiche en overlay) */
    #header-content {
        position: fixed;
        top: 60px; /* En dessous du header-top */
        left: 0;
        width: 100%;
        background: var(--bg-card);
        padding: 16px;
        box-sizing: border-box;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        transform: translateY(-150%);
        transition: transform 0.3s ease-in-out;
        z-index: 19;
    }

    #header-content.open {
        transform: translateY(0);
    }

    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    /* L'arbre prend la place sous la navbar */
    #network-container {
        margin-top: 60px; 
        height: calc(100vh - 60px);
    }

    /* Remonter les contrôles React Flow */
    .custom-controls {
        bottom: 80px !important;
    }

    /* Panneau de détails en modale Bottom Sheet */
    #details-panel.card {
        position: fixed;
        bottom: 0;
        top: auto;
        right: 0;
        left: 0;
        width: 100%;
        height: 70vh; /* 70% de l'écran */
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
        z-index: 30;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
    }

    #details-panel.card:not(.hidden) {
        transform: translateY(0);
    }

    .details-drag-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
        margin: 0 auto 12px auto;
    }
}
