/* ─────────────────────────────────────────────────────────────
   network-page.css
   ───────────────────────────────────────────────────────────── */

.network-page {
  --bg: #020617;
  --bg-card: #0f172a;
  --bg-card-hover: #131c31;
  --bg-input: #020617;
  --bg-tab: #1e293b;
  --bg-tab-active: #0f172a;

  --border: #1e293b;
  --border-hover: #334155;
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;

  --color-blue: #3b82f6;
  --color-blue-hover: #2563eb;
  --color-emerald: #10b981;
  --color-indigo: #6366f1;
  --color-amber: #f59e0b;
  --color-rose: #f43f5e;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);

  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  background-color: var(--bg);
  min-height: 100vh;
  padding: 1.5rem;
  color: var(--text-primary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (min-width: 768px) {
  .network-page {
    padding: 2.5rem;
  }
}

/* ── Container ── */
.network-container {
  max-width: 64rem;
  margin: 0 auto;
}

/* ── Header ── */
.network-header {
  margin-bottom: 2rem;
}

.network-header h1 {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0;
}

.network-header p {
  margin-top: 0.375rem;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ── Loading ── */
.network-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 0.75rem;
}

.network-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--color-indigo);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.network-loading span {
  color: var(--text-secondary);
}

/* ── Alert ── */
.network-alert {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: rgba(251, 113, 133, 0.1);
  border: 1px solid rgba(251, 113, 133, 0.2);
}

.network-alert-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-rose);
  flex-shrink: 0;
}

.network-alert span {
  color: var(--color-rose);
  font-weight: 500;
  flex: 1;
}

.network-alert-retry {
  padding: 0.375rem 1rem;
  background: rgba(251, 113, 133, 0.15);
  border: 1px solid rgba(251, 113, 133, 0.3);
  color: var(--color-rose);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}

.network-alert-retry:hover {
  background: rgba(251, 113, 133, 0.25);
}

/* ── Router Info Bar ── */
.router-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.router-bar__item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.router-bar__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.router-bar__value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.router-bar__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-emerald);
  margin-left: auto;
}

.router-bar__dot {
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--color-emerald);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Tabs ── */
.network-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.375rem;
  background-color: var(--bg-tab);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.network-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
}

.network-tab:hover {
  color: var(--text-primary);
}

.network-tab--active {
  background-color: var(--bg-tab-active);
  color: var(--color-blue);
  box-shadow: var(--shadow-sm);
}

.network-tab__icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* ── Speed Panel ── */
.speed-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
}

.speed-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .speed-display {
    flex-direction: column;
    gap: 1.5rem;
  }
}

.speed-display__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.speed-display__gauge {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.speed-display__gauge--download {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.05) 100%);
  border: 2px solid rgba(59, 130, 246, 0.3);
}

.speed-display__gauge--upload {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.05) 100%);
  border: 2px solid rgba(16, 185, 129, 0.3);
}

.speed-display__icon {
  width: 2rem;
  height: 2rem;
  color: var(--text-secondary);
}

.speed-display__value {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -0.05em;
}

.speed-display__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.speed-display__time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.speed-display__divider {
  width: 1px;
  height: 8rem;
  background: linear-gradient(180deg, transparent, var(--border), transparent);
}

@media (max-width: 640px) {
  .speed-display__divider {
    width: 8rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
  }
}

.speed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  background-color: var(--color-blue);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.4);
}

.speed-btn:hover:not(:disabled) {
  background-color: var(--color-blue-hover);
  transform: translateY(-1px);
}

.speed-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.speed-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.speed-btn--testing {
  background-color: var(--text-disabled);
  box-shadow: none;
}

.speed-btn__spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.speed-btn__icon {
  width: 1.125rem;
  height: 1.125rem;
}

.speed-note {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Ping Panel ── */
.ping-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ping-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ping-panel__header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.ping-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--color-blue);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms ease;
}

.ping-btn:hover:not(:disabled) {
  background-color: var(--color-blue-hover);
}

.ping-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ping-btn__spinner {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.ping-btn__icon {
  width: 1rem;
  height: 1rem;
}

.ping-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .ping-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ping-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.ping-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.ping-card__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.ping-card__host {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
}

.ping-card__body {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ping-card__latency {
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1;
}

.ping-card__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
}

.ping-card__badge--excellent {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-emerald);
}

.ping-card__badge--poor {
  background-color: rgba(244, 63, 94, 0.15);
  color: var(--color-rose);
}

.ping-card__bar {
  height: 0.375rem;
  background-color: var(--bg-tab);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.ping-card__bar--pending {
  background: linear-gradient(90deg, var(--bg-tab) 25%, var(--border-hover) 50%, var(--bg-tab) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ping-card__bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 500ms ease;
}

/* ── Session Panel ── */
.session-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.session-panel__header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.session-panel__header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.session-panel__header p {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.session-table-wrapper {
  overflow-x: auto;
}

.session-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.session-table thead {
  background-color: rgba(30, 41, 59, 0.5);
}

.session-table th {
  padding: 0.875rem 1.5rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.session-table td {
  padding: 1rem 1.5rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.session-table tbody tr:hover {
  background-color: rgba(30, 41, 59, 0.3);
}

.session-table__ip {
  font-family: ui-monospace, monospace;
  color: var(--color-blue);
  font-weight: 500;
}

.session-table__mac {
  font-family: ui-monospace, monospace;
}

.session-table__active-text {
  color: var(--color-emerald);
  font-weight: 500;
}

.session-table__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.session-table__badge--active {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-emerald);
}

.session-table__badge--closed {
  background-color: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.session-table__pulse {
  width: 0.375rem;
  height: 0.375rem;
  background-color: var(--color-emerald);
  border-radius: 50%;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.session-table__empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.session-table__empty svg {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  color: var(--text-disabled);
}