/* ============================================================
   network.css — Estils del temari i contingut de xarxes
   ============================================================ */

/* ---------- Acordió de temes ---------- */
.topic-accordion {
  margin-bottom: 0.5rem;
}

.topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.topic-header:hover {
  background: rgba(26, 115, 232, 0.08);
  border-color: var(--color-primary);
}

.topic-header.open {
  background: rgba(26, 115, 232, 0.12);
  border-color: var(--color-primary);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.topic-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topic-icon {
  font-size: 1.3rem;
}

.topic-title-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}

.topic-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

.topic-arrow {
  color: var(--color-text-muted);
  transition: transform var(--transition);
  font-size: 0.8rem;
}

.topic-header.open .topic-arrow {
  transform: rotate(180deg);
}

.topic-body {
  background: rgba(30, 39, 54, 0.7);
  border: 1px solid var(--color-primary);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.4s ease, padding 0.2s ease;
  padding: 0 1.25rem;
}

.topic-body.open {
  max-height: 2000px;
  padding: 1.25rem;
}

/* Text del contingut del tema */
.topic-content-text {
  color: var(--color-text);
  line-height: 1.75;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

/* Subtemes dins de l'acordió */
.subtopic {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.subtopic h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.subtopic p {
  font-size: 0.87rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  white-space: pre-line;
}

.subtopic p strong {
  color: var(--color-text);
}

/* Exemples de comandes */
.examples-section {
  margin-top: 1rem;
}

.examples-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-accent);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.command-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.command-chip {
  background: var(--color-terminal);
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--color-green);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.command-chip:hover {
  border-color: var(--color-accent);
  background: rgba(0, 188, 212, 0.08);
  transform: translateY(-1px);
}

/* Marca si un tema s'ha llegit */
.topic-completed-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--color-success);
  background: rgba(67, 160, 71, 0.15);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
}

/* ---------- Model OSI visual ---------- */
.osi-model {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 1rem 0;
}

.osi-layer {
  display: grid;
  grid-template-columns: 80px 140px 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  transition: transform var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.osi-layer:hover {
  transform: translateX(6px);
  border-color: currentColor;
}

.osi-layer-num {
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  opacity: 0.7;
}

.osi-layer-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.osi-layer-protocols {
  font-size: 0.8rem;
  opacity: 0.8;
  font-family: var(--font-mono);
}

/* Colors per capa OSI */
.osi-l7 { background: rgba(26,115,232,0.15); color: #60a5fa; }
.osi-l6 { background: rgba(34,197,94,0.12);  color: #4ade80; }
.osi-l5 { background: rgba(168,85,247,0.12); color: #c084fc; }
.osi-l4 { background: rgba(251,140,0,0.12);  color: #fbbf24; }
.osi-l3 { background: rgba(239,68,68,0.12);  color: #f87171; }
.osi-l2 { background: rgba(20,184,166,0.12); color: #2dd4bf; }
.osi-l1 { background: rgba(100,116,139,0.15);color: #94a3b8; }

/* ---------- Taula de protocols ---------- */
.protocols-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.protocols-table th {
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
}

.protocols-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.protocols-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

.port-number {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-accent);
}

.protocol-name-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.protocol-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.protocol-type-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Cerca de resultats ---------- */
.search-results-container {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 2000;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}

.search-result-item:hover {
  background: rgba(26, 115, 232, 0.1);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.search-result-excerpt {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-highlight {
  background: rgba(251, 140, 0, 0.3);
  color: var(--color-warning);
  border-radius: 2px;
  padding: 0 2px;
}
