/* =============================================
   ==          STYLES GÉNÉRAUX & THÈME         ==
   ============================================= */
body {
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  background: #0e1116;
  color: #e5ecff;
  margin: 0;
  min-height: 100vh;
  letter-spacing: 0.02em;
  line-height: 1.6;
  overflow-x: hidden;
}

.main-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem;
}

/* =============================================
   ==              BARRE DU HAUT               ==
   ============================================= */
header.topbar {
  padding: 1rem 2rem;
  background: rgba(21, 25, 34, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 2px 12px 0 #0004;
  border-bottom: 1px solid #232946;
  border-radius: 16px;
  position: sticky;
  top: 1rem;
  z-index: 100;
}

header.topbar h1 {
  font-size: 1.5rem;
  margin: 0;
  font-weight: 600;
  color: #5b8cff;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #1b2130;
  padding: 0.6rem 1rem;
  border-radius: 12px;
}

.controls label {
  color: #aab1d6;
  font-size: 0.9rem;
}

.controls select, .controls input[type="range"], .controls button {
  background: #232946;
  color: #e5ecff;
  border: 1px solid #333958;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.controls button:hover, .controls select:hover {
  background: #5b8cff;
  border-color: #5b8cff;
}

.controls button:active {
    transform: scale(0.95);
}

#speedVal {
  width: 2.5rem;
  text-align: right;
  color: #aab1d6;
  font-size: 0.9rem;
}

/* =============================================
   ==         VUE PRINCIPALE (LES PILES)       ==
   ============================================= */
main.layout {
  display: grid;
  grid-template-columns: 1fr 0.5fr 1fr;
  gap: 1rem;
  padding: 2rem 0;
  position: relative;
  min-height: 500px;
}

.column, .network {
  border: 1px solid #232946;
  border-radius: 16px;
  padding: 1rem;
}

.column h2, .network h2 {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
  color: #dfe7ff;
  text-align: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.layer {
  background: #232946;
  border-left: 8px solid var(--color, #5b8cff);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: #e5ecff;
  box-shadow: 0 2px 8px #0003;
  transition: all 0.25s;
  position: relative;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.layer:hover {
  background: #2d3a5a;
  box-shadow: 0 4px 16px #0004;
  transform: translateY(-2px) scale(1.02);
}

.layer.active {
  background: #5b8cff44;
  border-left-color: #5b8cff;
  box-shadow: 0 0 16px #5b8cff88;
  color: #fff;
}

.layer .tag {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.75rem;
  color: #aab1d6;
}

.layer .name {
  font-weight: 600;
}

.layer .pdu-name {
    font-size: 0.8rem;
    color: #aab1d6;
    font-style: italic;
}

/* =============================================
   ==              ÉLÉMENT PDU                 ==
   ============================================= */
.pdu {
  position: absolute;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #5dd3f3, #8df05b);
  color: #0a1126;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  box-shadow: 0 0 24px #8df05b88;
  border: 2px solid #fff6;
  transition: top 0.5s ease-in-out, left 0.5s ease-in-out, opacity 0.5s;
  pointer-events: none;
  min-width: 100px;
  text-align: center;
  font-size: 1rem;
  z-index: 10;
  opacity: 1;
}

/* =============================================
   ==           PANNEAUX DU BAS                ==
   ============================================= */
.bottom-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.details, .log-panel, .packet-view {
  padding: 1.5rem;
  background: #151922;
  border: 1px solid #232946;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
}

.details h3, .log-panel h3, .packet-view h3 {
    margin-top: 0;
    color: #aab1d6;
    font-size: 1.1rem;
    border-bottom: 1px solid #232946;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.step-desc { color: #aab1d6; margin-bottom: 1rem; font-size: 1rem; }

.headers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.header-card {
  background: #232946;
  border: 1px solid #333958;
  border-radius: 8px;
  padding: 0.7rem;
}

.header-card .h-title { font-weight: 600; margin-bottom: 0.3rem; color: #5b8cff; font-size: 0.9rem; }
.header-card .kv { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; color: #d8e3ff; }
.header-card .kv span { color: #aab1d6; }

#networkLog {
  background: #0e1116;
  border-radius: 6px;
  padding: 0.8rem;
  color: #b0eaff;
  font-size: 0.9rem;
  overflow-y: auto;
  font-family: 'Fira Mono', 'Consolas', monospace;
  flex-grow: 1;
}

#networkLog div {
    padding-bottom: 4px;
}

/* =============================================
   ==           VUE DU PAQUET                  ==
   ============================================= */
#packetViewContainer {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.5rem;
    background: #0e1116;
    border-radius: 6px;
}

.packet-layer {
    padding: 0.5rem;
    border: 2px solid;
    border-radius: 4px;
    margin: 2px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease-in-out;
}

.packet-layer-label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #fff;
    text-align: center;
}

.footer {
    text-align: center;
    color: #aab1d6;
    padding: 2rem;
    font-size: 0.9rem;
}

/* =============================================
   ==          INFOBULLE & ACCESSIBILITÉ       ==
   ============================================= */
.osi-tooltip {
  position: absolute;
  z-index: 1000;
  background: #232946;
  color: #e5ecff;
  border-radius: 8px;
  box-shadow: 0 4px 24px #0005;
  padding: 1rem;
  font-size: 0.9rem;
  max-width: 300px;
  pointer-events: none;
  border: 1px solid #5b8cff;
  opacity: 0.98;
  transition: opacity 0.2s;
}

.layer:focus {
  outline: 2px solid #5b8cff;
  outline-offset: 2px;
}

/* =============================================
   ==              RESPONSIVE                  ==
   ============================================= */
@media (max-width: 1200px) {
    main.layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 2rem;
    }
    .network {
        min-height: 100px;
    }
    .pdu {
        display: none; /* On cache le PDU en vue mobile pour simplifier */
    }
}

@media (max-width: 768px) {
    header.topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .controls {
        flex-wrap: wrap;
    }
    .bottom-panels {
        grid-template-columns: 1fr;
    }
}