/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow: hidden;
}

/* Header */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    position: relative;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
}

.logo i {
    margin-right: 10px;
    font-size: 24px;
    color: #3498db;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    font-size: 14px;
}

.nav-item:hover {
    background-color: #34495e;
    color: white;
}

.nav-item.active {
    background-color: #34495e;
    color: white;
    border-bottom-color: #3498db;
}

.nav-item i {
    margin-right: 8px;
    font-size: 16px;
}

/* Container principal */
.main-container {
    display: flex;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: #2c3e50;
    color: white;
    overflow-y: auto;
    border-right: 1px solid #34495e;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
}

.sidebar-header h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #ecf0f1;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #34495e;
    border-radius: 5px;
    background-color: #34495e;
    color: white;
    font-size: 14px;
}

.search-box input::placeholder {
    color: #95a5a6;
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
}

/* Contenu de la sidebar */
.sidebar-content {
    padding: 0;
}

.object-category {
    border-bottom: 1px solid #34495e;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background-color: #2c3e50;
    transition: background-color 0.3s ease;
    font-weight: 500;
}

.category-header:hover {
    background-color: #34495e;
}

.category-header i {
    margin-right: 10px;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.category-header.collapsed i {
    transform: rotate(-90deg);
}

.category-items {
    background-color: #34495e;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.category-items.collapsed {
    max-height: 0;
}

.object-item {
    display: flex;
    align-items: center;
    padding: 12px 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.object-item:hover {
    background-color: #3498db;
    border-left-color: #2980b9;
}

.object-item.active {
    background-color: #3498db;
    border-left-color: #2980b9;
}

.object-item i {
    margin-right: 12px;
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.object-item span {
    font-size: 14px;
}

/* Zone de diagramme */
.diagram-container {
    flex: 1;
    position: relative;
    background-color: #ecf0f1;
}

#network-diagram {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    border: 1px solid #ddd;
}

/* Contrôles du diagramme */
.diagram-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.control-btn {
    width: 40px;
    height: 40px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.control-btn:hover {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.control-btn i {
    font-size: 16px;
}

.info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background-color: #3498db;
    color: white;
    border-radius: 8px 8px 0 0;
}

.info-header h4 {
    margin: 0;
    font-size: 16px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

.info-content {
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
}


/* Styles pour les éléments du diagramme */
.vis-network {
    outline: none;
}

/* Scrollbar personnalisée */
.sidebar::-webkit-scrollbar,
.info-content::-webkit-scrollbar,
.legend-content::-webkit-scrollbar,
.stats-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.info-content::-webkit-scrollbar-track,
.legend-content::-webkit-scrollbar-track,
.stats-content::-webkit-scrollbar-track {
    background: #34495e;
}

.sidebar::-webkit-scrollbar-thumb,
.info-content::-webkit-scrollbar-thumb,
.legend-content::-webkit-scrollbar-thumb,
.stats-content::-webkit-scrollbar-thumb {
    background: #95a5a6;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.info-content::-webkit-scrollbar-thumb:hover,
.legend-content::-webkit-scrollbar-thumb:hover,
.stats-content::-webkit-scrollbar-thumb:hover {
    background: #7f8c8d;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
    }
    
    .nav-item {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .info-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
    }
    
    .legend-panel {
        position: relative;
        top: 0;
        left: 0;
        margin: 20px;
        width: calc(100% - 40px);
    }
    
    .stats-panel {
        position: relative;
        bottom: 0;
        right: 0;
        margin: 20px;
        width: calc(100% - 40px);
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 200px;
    }
    
    .header-content {
        flex-direction: column;
        height: auto;
        padding: 10px;
    }
    
    .main-container {
        height: calc(100vh - 80px);
    }
}

/* Animation pour les éléments du diagramme */
.vis-network canvas {
    transition: all 0.3s ease;
}

/* États de chargement */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Styles pour les tooltips */
.vis-tooltip {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    max-width: 200px;
    word-wrap: break-word;
}



/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-badge.active {
    background-color: #d5f4e6;
    color: #27ae60;
}

.status-badge.inactive {
    background-color: #ffeaa7;
    color: #f39c12;
}

.status-badge.off {
    background-color: #fab1a0;
    color: #e74c3c;
}

/* Styles pour le tableau des applications */
.table-container {
    padding: 20px;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.btn-back-network {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-wrapper {
    flex: 1;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.applications-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.applications-table th {
    background-color: #34495e;
    color: black;
    padding: 12px 8px;
    text-align: left;
    position: sticky;
    top: 0;
}

.applications-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 13px;
}

.app-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.app-row:hover {
    background-color: #f8f9fa;
}

.quality-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    background-color: #3498db;
}

.table-controls { 
    display: flex; 
    gap: 10px; 
    align-items: center; 
}

.btn-toggle-panel { 
    background: #2c3e50; 
    color: white; 
    border: none; 
    padding: 8px 15px; 
    border-radius: 5px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.btn-toggle-panel:hover { 
    background: #34495e; 
}

.table-stats-panel, .table-legend-panel { 
    background: #f8f9fa; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    margin-bottom: 20px; 
    overflow: hidden; 
    transition: all 0.3s ease; 
}

.table-stats-panel.collapsed, .table-legend-panel.collapsed { 
    max-height: 0; 
    margin-bottom: 0; 
    border: none; 
}

.table-stats-panel .stats-content { 
    display: flex; 
    justify-content: space-around; 
    padding: 20px; 
    gap: 20px; 
}

.table-stats-panel .stat-item { 
    text-align: center; 
    flex: 1; 
}

.table-stats-panel .stat-number { 
    display: block; 
    font-size: 2em; 
    font-weight: bold; 
    color: #3498db; 
    margin-bottom: 5px; 
}

.table-stats-panel .stat-label { 
    color: #7f8c8d; 
    font-size: 0.9em; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

.table-legend-panel .legend-content { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 15px; 
    padding: 20px; 
    justify-content: center; 
}

/* Cartographie */
.cartography-view {
    padding: 2rem 0;
}

.cartography-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.view-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.view-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.view-section h3 {
    color: #2d3748;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    text-align: center;
    border-bottom: 2px solid rgba(52, 73, 94, 0.2);
    padding-bottom: 0.5rem;
}

.blocks-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.carto-block {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.9rem;
}

.carto-block:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.sites-section .carto-block {
    background: linear-gradient(135deg, #4a5568, #2d3748);
    color: white;
}

.applicative-section .carto-block {
    background: linear-gradient(135deg, #3182ce, #2c5282);
    color: white;
}

.technique-section .carto-block {
    background: linear-gradient(135deg, #4a5568, #2d3748);
    color: white;
}

.frequency-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.frequency-demande { background-color: #e3f2fd; color: #1976d2; }
.frequency-mensuel { background-color: #f3e5f5; color: #7b1fa2; }
.frequency-quotidien { background-color: #e8f5e8; color: #388e3c; }

.tech-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.tech-api { background-color: #fff3e0; color: #f57c00; }
.tech-fichier-plat { background-color: #fce4ec; color: #c2185b; }

/* Éditeur d'application */
.app-editor {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    height: 100vh;
    background: #2d2d2d;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    color: #e0e0e0;
}

.app-editor.active {
    right: 0;
}

.editor-header {
    padding: 15px 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
}

.close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

.close-btn:hover {
    color: #fff;
}

.editor-tabs {
    display: flex;
    border-bottom: 1px solid #444;
    padding: 0 20px;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-btn.active {
    color: #4a90e2;
    border-bottom-color: #4a90e2;
    font-weight: 500;
}

.editor-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.form-section {
    max-width: 100%;
}

/* Le conteneur du tableau doit prendre la hauteur et scroller */
.table-container {
    /* ajuste si besoin en fonction de la hauteur du header */
    height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
  }
  
  .table-wrapper {
    flex: 1 1 auto;
    overflow: auto;          /* ← permet de scroller */
    -webkit-overflow-scrolling: touch; /* fluide sur mobile */
  }
  
  /* Optionnel : fixe l'en-tête */
  .applications-table thead th {
    position: sticky;
    top: 0;
    background: #f7f9fc;
    z-index: 1;
  }
  
  /* La zone principale doit prendre toute la hauteur dispo */
.diagram-container { 
  height: calc(100vh - 64px); /* ajuste 64px si ton header est plus grand/petit */
  display: flex;
  flex-direction: column;
}

/* Le container du tableau prend toute la place */
.table-container { 
  height: 100%;
  display: flex; 
  flex-direction: column; 
  padding: 12px;
}

/* La zone scrollable */
.table-wrapper { 
  flex: 1 1 auto; 
  overflow: auto; 
  -webkit-overflow-scrolling: touch; 
}

/* Entête collante */
.applications-table thead th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  z-index: 1;
}

/* --- Scroll fiable de la vue Applications --- */
.diagram-container {
  height: calc(100vh - 60px); /* ajuste si ton header ≠ 60px */
  display: flex;
  flex-direction: column;
  min-height: 0; /* indispensable pour que les enfants puissent rétrécir */
}

#apps-view {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

#apps-view .table-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0; /* pour que table-wrapper puisse scroller */
}

#apps-view .table-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;                 /* ← c’est ici que ça scrolle */
  -webkit-overflow-scrolling: touch;
}

/* Entête collante + couleur */
#apps-view .applications-table thead th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  color: #2c3e50; /* texte foncé */
  z-index: 1;
}

/* s'assurer que la sidebar capte bien les clics */
.sidebar{ position:relative; z-index:1000; }
.diagram-container{ position:relative; z-index:1; }

/* si on met la classe .blocking sur le diagramme, il ne capte plus les clics */
#network-diagram.blocking { pointer-events:none; }

/* Force le masquage des vues */
.diagram-container > .hidden { display: none !important; }

/* ==== Scroll fiable pour TOUTES les vues tableau (écrase les règles génériques) ==== */
.diagram-container {
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  min-height: 0; /* indispensable */
}

/* Toutes les vues "…-view" sont des flex containers qui peuvent rétrécir */
.diagram-container > [id$='-view'] {
  flex: 1 1 auto;
  min-height: 0;
  display: none;
}

/* Quand la vue n'a pas .hidden, on l'affiche en flex */
.diagram-container > [id$='-view']:not(.hidden) {
  display: flex;
}

/* Conteneur du tableau : doit pouvoir rétrécir -> supprime la hauteur fixe définie ailleurs */
.diagram-container > [id$='-view'] .table-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;      /* <-- écrase height: calc(100vh - 160px) */
  overflow: visible !important; /* <-- évite le overflow:hidden hérité */
  padding: 12px;
}

/* Zone scrollable */
.diagram-container > [id$='-view'] .table-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* En-têtes collants */
.diagram-container > [id$='-view'] .applications-table thead th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  z-index: 1;
}

/* même effet gris que les autres boutons */
.btn-primary:hover {
  background: #34495e;
}

/* Hover gris léger sur toutes les lignes des tableaux */
.applications-table tbody tr > td { 
  transition: background-color .12s ease;
}

.applications-table tbody tr:hover > td {
  background-color: #f6f7fb;   /* gris très léger */
}

/* Style du bouton "Retour" dans les pages d'édition = même que .btn-primary */
.edit-head .btn-secondary {
  background: #3498db;
  color: #fff;
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease;
}

.edit-head .btn-secondary:hover {
  background: #2c80b8;
}

/* Zone de contenu + header plus larges */
.header-content,
.container{
  max-width: 1480px !important;   /* était 1200px */
}

/* Et on ouvre encore un peu sur très grands écrans */
@media (min-width: 1600px){
  .header-content,
  .container{ max-width: 1600px !important; }
}
@media (min-width: 1900px){
  .header-content,
  .container{ max-width: 1760px !important; }
}

/* Lettres (A-Z) */
.letters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}
.letters button{
  border:1px solid #cbd5e1;background:#fff;color:#0f172a;
  padding:6px 10px;border-radius:9999px;cursor:pointer
}
.letters button:hover{background:#eef2ff}
.letters button.active{background:#2563eb;border-color:#2563eb;color:#fff}

/* Grille de tuiles */
.apps-grid{
  display:grid;gap:10px;
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
}

/* Tuile appli (bleu comme ton UI) */
.app-card{
  display:flex;align-items:center;gap:10px;
  padding:12px;border-radius:12px;background:#0b4a7a;color:#fff;
  text-decoration:none
}
.app-card:hover{filter:brightness(1.03)}

/* Badge lettre */
.app-card .badge{
  background:#e2e8f0;color:#0f172a;
  width:36px;height:36px;border-radius:9999px;
  display:flex;align-items:center;justify-content:center;font-weight:700
}

/* Libellé */
.app-card .label{font-weight:600;line-height:1.2}

/* Panneau lettres */
.letter-board{
  display:grid; gap:14px;
  grid-template-columns:repeat(auto-fill, minmax(90px, 1fr));
  margin-bottom:8px;
}
.letter{
  position:relative;
  width:90px; height:90px;
  border:3px solid #085b7d; color:#085b7d; background:#fff;
  border-radius:9999px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:26px;
  box-shadow:0 0 0 3px rgba(8,91,125,.1) inset;
}
.letter .count{
  position:absolute; bottom:8px; left:0; right:0;
  text-align:center; font-size:14px; font-weight:700; color:#0873a3;
}
.letter.disabled{ opacity:.35; cursor:not-allowed; }
.letter.active{ background:#e6f0fa; }

/* Grille applis (utilisée par la vue Navigation) */
.apps-grid{
  display:grid; gap:10px;
  grid-template-columns:repeat(auto-fill, minmax(260px,1fr));
}
.app-card{
  display:flex; align-items:center; gap:10px;
  padding:12px; border-radius:12px; background:#0b4a7a; color:#fff; text-decoration:none;
}
.app-card:hover{ filter:brightness(1.04); }
.app-card .badge{
  background:#e2e8f0; color:#0f172a; width:36px; height:36px; border-radius:9999px;
  display:flex; align-items:center; justify-content:center; font-weight:700;
}
.app-card .label{ font-weight:600; line-height:1.2; }

/* Bouton retour */
.btn{ padding:8px 12px; border:1px solid #cbd5e1; border-radius:8px; background:#fff; cursor:pointer; }
