html {
  scroll-behavior: smooth;
}

:root {
  --sidebar-w: 371px;
  /* breedte van je linker sidebar */
  --sidebar-gap: 17px;
  /* ruimte tussen sidebar en content */
  --sidebar-pad: 71px;
  /* extra binnenruimte links in de sidebar */
  --sidebar-safe: 24px;

  /* Modern color palette */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --accent-primary: #007bff;
  --accent-primary-dark: #0056b3;
  --accent-secondary: #0f766e;
  --accent-tertiary: #1d4ed8;
  --border-color: #e0e0e0;
  --focus-glow: rgba(0, 123, 255, 0.25);
}

/* body blijft je content centreren, maar krijgt links ruimte voor de sidebar */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.6;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-items: left;
  justify-content: flex-start;
  padding: 2em 2em;
  padding-left: calc(
    var(--sidebar-w) + var(--sidebar-gap) + var(--sidebar-pad) +
      var(--sidebar-safe)
  );
  margin-bottom: 500px;
  transition: background-color 0.3s ease;
  overflow-x: hidden;
}

main {
  flex: 1;
  /* duwt de footer naar beneden */
  max-width: 800px;
  margin: 0 auto;
}

/* vaste linker sidebar */
.sidenav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 1000;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: 24px 16px;
  padding-left: var(--sidebar-pad);
  /* extra binnenruimte links */
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
}

.sidenav h2 {
  color: var(--text-primary);
}

.sidenav p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.sidenav a {
  display: block;
  /* links altijd onder elkaar */
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--accent-primary);
  padding: 10px 12px;
  border-radius: 6px;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.sidenav a:hover {
  background: rgba(0, 123, 255, 0.08);
  color: var(--accent-primary-dark);
  border-left-color: var(--accent-primary);
  padding-left: 16px;
}

/* Anker scroll offset */
[id] {
  scroll-margin-top: 71px;
}

h1 {
  font-family: "georgiapro", sans-serif !important;
  font-weight: 700;
  font-style: normal;
  font-size: 2em;
}

h2 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  font-style: normal;
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.title-small {
  display: block;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.title-large {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.25rem;
}

.introduction {
  background: none;
  padding: 2rem;
  border-radius: 10px;
  width: 100%;
  margin-bottom: 71px;
}

.container {
  background: var(--bg-secondary);
  padding: 2.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin: 0 auto 3rem auto;
  transition: all 0.3s ease;
}

.container:hover {
  border-color: rgba(0, 123, 255, 0.3);
}

.uitleg {
  font-size: 1rem;
  margin-bottom: 1.75rem;
  color: var(--text-secondary);
  max-width: 600px;
  line-height: 1.6;
}

.why {
  margin-top: 2rem;
  font-size: 0.95rem;
  color: #444;
  line-height: 1.5;
  background-color: #f7f7f7;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.05);
}

.why h4 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.toelichting {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: #444;
  line-height: 1.5;
}

.toelichting summary {
  cursor: pointer;
  font-weight: bold;
}

ul.list {
  list-style-type: square;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  color: #444;
  max-width: 600px;
  line-height: 1.4;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.875rem;
  margin-top: 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-sizing: border-box;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--focus-glow);
  background: var(--bg-secondary);
}

.form-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: nowrap;
}

.form-buttons button {
  width: auto;
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.form-buttons button[type="submit"] {
  flex: 1 1 180px;
  min-width: 180px;
}

.form-buttons button[type="reset"] {
  width: 100px;
  background-color: #ddd;
  color: #333;
}

.form-buttons button[type="reset"]:hover {
  background-color: #ccc;
}

button {
  background: linear-gradient(135deg, var(--accent-primary), #0056b3);
  color: white;
  cursor: pointer !important;
  transition: all 0.3s ease;
  font-weight: 500;
  border: none;
  position: relative;
  overflow: hidden;
  padding: 0.875rem 1.5rem;
}

button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition:
    width 0.6s,
    height 0.6s;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 123, 255, 0.3);
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button[type="reset"] {
  background: linear-gradient(135deg, #e0e0e0, #d0d0d0);
  color: var(--text-primary);
  margin-left: 0.5rem;
}

button[type="reset"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.sample-button {
  background: linear-gradient(135deg, var(--accent-secondary), #0b5f59);
}

.sample-button:hover {
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.3);
}

.copy-result {
  width: auto;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--accent-tertiary), #1e40af);
  font-size: 1.2rem;
  line-height: 1;
  height: 44px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: none;
}

.result.visible + .copy-result {
  display: flex !important;
}

.copy-result:hover {
  box-shadow: 0 8px 16px rgba(29, 78, 216, 0.3);
}

.copy-result:disabled {
  background: linear-gradient(135deg, #9aa3af, #8a9aaf);
  cursor: not-allowed !important;
  opacity: 0.6;
}

.help-text {
  margin: 0.5rem 0 0.5rem 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

.is-invalid {
  border-color: #dc2626 !important;
  background-color: #fef2f2;
}

/* Result output wrapper with button */
.result {
  margin-top: 2rem;
  padding: 1.75rem;
  border-radius: 12px;
  display: none;
  border: 1px solid var(--border-color);
  background: linear-gradient(135deg, #f0f9ff 0%, #f5f3ff 100%);
  animation: slideIn 0.3s ease-out;
  overflow-x: auto;
  position: relative;
  padding-top: 3rem;
}

.result.visible {
  display: block;
}

.result + .copy-result {
  position: relative;
  margin-top: -43px;
  margin-right: -1.75rem;
  margin-bottom: 1rem;
  float: right;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result.visible {
  display: block;
}

.result p {
  margin: 0.75rem 0;
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.6;
}

label {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.explanation h2 {
  margin-bottom: 1rem;
  font-size: 1.3rem;
  color: var(--text-primary);
}

.explanation p {
  margin-bottom: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.subnet-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.subnet-row label {
  width: 220px;
}

.subnet-row input {
  flex: 1;
  padding: 0.3rem;
}

.add-subnet {
  font-size: 1.25rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  margin-left: 0.5rem;
  color: white;
  cursor: pointer !important;
  user-select: none;
  background: linear-gradient(135deg, var(--accent-secondary), #0b5f59);
  border: none;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.add-subnet:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}

.block-bar {
  display: flex;
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  height: 50px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.subnet-block {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: linear-gradient(135deg, var(--accent-secondary), #0b5f59);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
  font-weight: 500;
  transition: all 0.3s ease;
}

.cidr-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  border-radius: 8px;
  overflow: hidden;
}

.cidr-table th,
.cidr-table td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
  font-family: "Monaco", "Menlo", "Consolas", monospace;
}

.cidr-table th {
  background: linear-gradient(135deg, #f8f9fa, #f0f4f8);
  font-weight: 600;
  color: var(--text-primary);
}

select {
  width: 100%;
  padding: 0.875rem;
  margin-top: 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-sizing: border-box;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25em 1.25em;
  padding-right: 2.5rem;
}

select:hover,
select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.binair-box {
  margin-top: 1.5rem;
}

.poortentabel {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  border-radius: 8px;
  overflow: hidden;
}

.poortentabel th,
.poortentabel td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.poortentabel th {
  background: linear-gradient(135deg, #f8f9fa, #f0f4f8);
  font-weight: 600;
  color: var(--text-primary);
}

.poortentabel td.tcp {
  background-color: #d0ebff;
  font-weight: 500;
  color: var(--text-primary);
}

.poortentabel td.udp {
  background-color: #ffe8cc;
  font-weight: 500;
  color: var(--text-primary);
}

.poortentabel td.tcpudp {
  background-color: #e0e0ff;
  font-weight: 500;
  color: var(--text-primary);
}

.result table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
  border-radius: 8px;
  overflow: hidden;
}

.result th,
.result td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
  font-family: "Monaco", "Menlo", "Consolas", monospace;
  font-size: 0.8rem;
  white-space: nowrap;
}

.result th {
  background: linear-gradient(135deg, #f8f9fa, #f0f4f8);
  font-weight: 600;
  color: var(--text-primary);
}

.result td {
  color: var(--text-primary);
}

@media (max-width: 600px) {
  .result table {
    font-size: 0.7rem;
  }
}

textarea {
  width: 100%;
  padding: 0.875rem;
  font-family: "Monaco", "Menlo", "Consolas", monospace;
  font-size: 0.9rem;
  box-sizing: border-box;
  margin-top: 0.75rem;
  resize: vertical;
  min-height: 120px;
}

/* =========================
   RESPONSIVE FIXES
   ========================= */

/* 1) Schakel eerder over naar nav-boven/content-onder om overlap te voorkomen */
@media (max-width: 1100px) {
  body {
    padding-left: 1.7em;
    /* geen ruimte meer reserveren voor fixed sidebar */
  }

  .sidenav {
    position: static;
    /* niet meer fixed */
    width: 100%;
    /* volle breedte */
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
    padding: 1.5rem 1rem;
    padding-left: 1rem;
    /* reset extra linkermarge */
    z-index: auto;
    display: block;
    /* kinderen stapelen */
  }

  .sidenav a {
    display: block;
    /* ALTÍJD onder elkaar */
    white-space: normal;
    /* tekst kan afbreken */
    padding: 8px 6px;
    font-size: 1rem;
    margin: 0;
  }
}

/* 2) Op heel smalle schermen nog iets compacter */
@media (max-width: 600px) {
  body {
    padding: 0;
  }

  .sidenav {
    padding: 1.5rem 1rem;
    margin: 0 0 1rem 0;
    border: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-radius: 0;
  }

  .sidenav a {
    padding: 8px 4px;
    font-size: 0.95rem;
  }

  .container {
    padding: 1.5rem 1rem;
    margin: 0 0 1rem 0;
    border-radius: 0;
  }

  .form-buttons {
    display: flex;
    gap: 0.75rem;
  }

  .form-buttons button {
    flex: 1 1 0;
    min-width: 0;
    width: auto !important;
  }

  .subnet-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .subnet-row label {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .subnet-row input {
    width: 100%;
  }

  .add-subnet {
    margin-left: 0;
    margin-top: 0.5rem;
    width: 100%;
  }

  h2 {
    font-size: 1.25rem;
  }

  .uitleg {
    font-size: 0.95rem;
  }

  input[type="text"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px;
  }

  .result {
    padding: 1rem;
    padding-top: 2rem;
  }

  .copy-result {
    top: 0.5rem;
    right: 0.5rem;
  }
}

/* ========================================
   VISUALIZATIONS: BITGRID, BLOCKSTRIP, VIZ-BAR
   ======================================== */

/* 1. BIT VISUALIZATION (32-bit grid) */
.bitviz {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f4f8, #f8f9fa);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.bitviz-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.bitviz-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: white;
  font-weight: 500;
}

.bitviz-pill::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.bitviz-pill.net::before {
  background: #007bff;
}

.bitviz-pill.host::before {
  background: #28a745;
}

.bitviz-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.bitgrid {
  display: inline-grid;
  grid-template-columns: repeat(auto-fit, minmax(24px, 1fr));
  gap: 4px;
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
}

.bit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #ddd;
  color: #333;
  user-select: none;
}

.bit.net {
  background: #e7f2ff;
  border-color: #007bff;
  color: #0056b3;
}

.bit.host {
  background: #e8f5e9;
  border-color: #28a745;
  color: #1e7e34;
}

.bit-sep {
  width: 100%;
  height: 2px;
  background: #ccc;
  margin: 4px 0;
  grid-column: 1 / -1;
}

/* 2. BLOCKSTRIP (horizontal scrolling blocks) */
.blockstrip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 1rem 0;
  scroll-behavior: smooth;
}

.blockstrip::-webkit-scrollbar {
  height: 8px;
}

.blockstrip::-webkit-scrollbar-track {
  background: transparent;
}

.blockstrip::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}

.block {
  flex: 0 0 auto;
  min-width: 140px;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.block:hover {
  border-color: #007bff;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.block[aria-current="true"] {
  border-color: #007bff;
  background: #e7f2ff;
  box-shadow: 0 4px 16px rgba(0, 123, 255, 0.25);
}

.block-label {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.block-range {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: monospace;
  line-height: 1.4;
}

.block-ellipsis {
  flex: 0 0 auto;
  min-width: 60px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  background: transparent;
  cursor: default;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #999;
  padding: 1rem;
  user-select: none;
}

/* 3. VLSM/SUPERNETTING VIZ-BAR */
.viz-bar {
  display: flex;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-top: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.viz-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.viz-segment:last-child {
  border-right: none;
}

.viz-segment:hover {
  opacity: 0.85;
  filter: brightness(1.1);
}

/* 4. ANDVIZ (bitwise AND visualization) */
.andviz {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f0f4f8, #f8f9fa);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.andviz-pre {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre;
}

.andviz-pre > span.and-arrow {
  color: #007bff;
  font-weight: bold;
}

.andviz-pre > span.and-label {
  display: inline-block;
  width: 120px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 0.5rem;
}

/* 5. BADGES (protocol, DNS record type) */
.proto-badge,
.dns-badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5rem;
  vertical-align: middle;
  border: 1px solid transparent;
}

.proto-badge.tcp {
  background: #e7f2ff;
  color: #0056b3;
  border-color: #007bff;
}

.proto-badge.udp {
  background: #fff3e0;
  color: #e65100;
  border-color: #ff9800;
}

.proto-badge.both {
  background: #f3e5f5;
  color: #6a1b9a;
  border-color: #9c27b0;
}

.dns-badge.a {
  background: #e7f2ff;
  color: #0056b3;
  border-color: #007bff;
}

.dns-badge.aaaa {
  background: #f3e5f5;
  color: #6a1b9a;
  border-color: #9c27b0;
}

.dns-badge.ptr {
  background: #e8f5e9;
  color: #1e7e34;
  border-color: #28a745;
}

.dns-badge.cname {
  background: #fff3e0;
  color: #e65100;
  border-color: #ff9800;
}

.dns-badge.mx {
  background: #ffe0e0;
  color: #c41c3b;
  border-color: #dc3545;
}

/* 6. BIT WEIGHTS (decimal/binary converter) */
.bit-weights {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: monospace;
}

.bit-weight {
  width: 32px;
  text-align: center;
}
