/* ---------------------------------------------------------------------
   soporte.tuinternet.pe — consola de enlaces remotos

   Dirección: consola técnica de operaciones (NOC), no landing comercial.
   Paleta pensada en "señal que llega desde una antena rural": fondo
   grafito-azulado, un cian de "enlace vivo" como único acento cálido de
   estado, ámbar para tránsito/advertencia, rojo apagado para caído.
   Monoespaciada para todo dato técnico (IP, SSID, gateway, id de
   dispositivo) — la fuente de datos crudos no debería lucir "de marketing".
--------------------------------------------------------------------- */

:root {
  --bg: #0d1117;
  --surface: #141b24;
  --surface-2: #1b2430;
  --border: #263041;
  --border-soft: #1d2733;

  --text: #e7ecf2;
  --text-muted: #8b96a5;
  --text-faint: #5c6675;

  --accent-live: #45d6c6;   /* enlace activo / online */
  --accent-live-dim: #1f4b47;
  --accent-warn: #f2a93b;   /* conectando / advertencia */
  --accent-warn-dim: #4a3a1a;
  --accent-down: #e5555f;   /* sin señal / error */
  --accent-down-dim: #4a2226;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  height: 100%;
}

body {
  background-image:
    radial-gradient(circle at 15% -10%, rgba(69, 214, 198, 0.07), transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(69, 214, 198, 0.04), transparent 40%);
  background-attachment: fixed;
}

button { font-family: inherit; }
input { font-family: inherit; color: inherit; }

/* ---------------------------- topbar ---------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(20, 27, 36, 0.6);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 10px;
  height: 22px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-live), transparent);
  box-shadow: 0 0 12px rgba(69, 214, 198, 0.5);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.brand-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-dim { color: var(--text-muted); font-weight: 500; }

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.counts { display: flex; gap: 10px; }

.count-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}
.count-pill span[data-count] { color: var(--text); font-weight: 600; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------------------------- estado (dot) ---------------------------- */

.dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-flex;
  flex: none;
  background: var(--text-faint);
}
.dot-online, .dot[data-state="online"] { background: var(--accent-live); }
.dot-offline, .dot[data-state="offline"] { background: var(--accent-down); }
.dot[data-state="connecting"] { background: var(--accent-warn); }

.dot-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0;
}
.dot-online .dot-ring,
.dot[data-state="online"] .dot-ring {
  color: var(--accent-live);
  animation: pulse-ring 2.2s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { opacity: 0.55; transform: scale(0.6); }
  70%  { opacity: 0; transform: scale(1.6); }
  100% { opacity: 0; transform: scale(1.6); }
}

@media (prefers-reduced-motion: reduce) {
  .dot-ring { animation: none !important; }
}

/* ---------------------------- main / toolbar ---------------------------- */

.main { padding: 24px 28px 60px; max-width: 1180px; margin: 0 auto; }

.toolbar { margin-bottom: 16px; }

.search {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search::placeholder { color: var(--text-faint); }
.search:focus { border-color: var(--accent-live); }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
}
.empty-title { font-weight: 600; margin: 0 0 6px; }
.empty-body { color: var(--text-muted); margin: 0; font-size: 13px; }

/* ---------------------------- tabla de conexiones ---------------------------- */

.connection-list {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.row {
  display: grid;
  grid-template-columns: 28px 1.4fr 1.8fr 1fr 0.7fr 0.9fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.row:last-child { border-bottom: none; }

.row-head {
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
}

.row:not(.row-head):hover { background: rgba(255, 255, 255, 0.015); }

.cell-alias { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alias-text {
  font-weight: 600;
  cursor: text;
  border-bottom: 1px dashed transparent;
}
.alias-text:hover, .alias-text:focus { border-bottom-color: var(--text-faint); outline: none; }
.alias-input {
  background: var(--surface-2);
  border: 1px solid var(--accent-live);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 13px;
  color: var(--text);
}
.device-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.cell-network { display: flex; flex-direction: column; gap: 3px; }
.net-line { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; }
.net-label {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 26px;
  flex: none;
}
.net-value { color: var(--text-muted); }
.net-mono { font-family: var(--font-mono); color: var(--text); }
.net-arrow { color: var(--text-faint); }

.cell-signal { display: flex; align-items: center; gap: 8px; }
.signal-bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.signal-bars .bar {
  width: 3px;
  border-radius: 1px;
  background: var(--border);
}
.signal-bars .bar[data-bar="1"] { height: 4px; }
.signal-bars .bar[data-bar="2"] { height: 7px; }
.signal-bars .bar[data-bar="3"] { height: 10px; }
.signal-bars .bar[data-bar="4"] { height: 14px; }
.signal-bars.level-1 .bar[data-bar="1"] { background: var(--accent-down); }
.signal-bars.level-2 .bar[data-bar="1"],
.signal-bars.level-2 .bar[data-bar="2"] { background: var(--accent-warn); }
.signal-bars.level-3 .bar[data-bar="1"],
.signal-bars.level-3 .bar[data-bar="2"],
.signal-bars.level-3 .bar[data-bar="3"] { background: var(--accent-live); }
.signal-bars.level-4 .bar { background: var(--accent-live); }
.signal-value { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

.battery-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.cell-lastseen { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }

.cell-actions { display: flex; gap: 8px; }

/* ---------------------------- botones ---------------------------- */

.btn {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.btn:hover { border-color: var(--accent-live); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-outline { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-primary {
  background: var(--accent-live);
  border-color: var(--accent-live);
  color: #08201c;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------------------------- modales ---------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 960px;
  height: 80vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.modal-browse { max-width: 1280px; }

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
  flex: none;
}

.modal-title-group { display: flex; flex-direction: column; line-height: 1.2; min-width: 140px; }
.modal-title { font-weight: 700; font-size: 13.5px; }
.modal-subtitle { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }

.modal-address {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.modal-address-prefix { color: var(--text-faint); }
.modal-address-scheme {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12.5px;
  cursor: pointer;
}
.modal-address-scheme option { background: var(--surface); color: var(--text); }
.modal-address-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  min-width: 0;
}
.modal-address-input:first-of-type { flex: 1; }
.modal-address-port { width: 46px; }
.modal-address-colon { color: var(--text-faint); }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
}
.modal-close:hover { color: var(--text); }

.modal-body { flex: 1; min-height: 0; }
.modal-body-browse { display: flex; }

.browse-frame-wrap { flex: 1; position: relative; display: flex; min-width: 0; }
.browse-frame { flex: 1; border: none; background: #fff; }

.browse-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  z-index: 2;
  transition: opacity 150ms ease;
}
.browse-loading[hidden] { display: none; }
.browse-loading.is-error { color: var(--accent-down); }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent-live);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--border); }
}

/* ---------------------------- inspector de red (estilo DevTools) ---------------------------- */

.network-panel {
  width: 340px;
  flex: none;
  border-left: 1px solid var(--border-soft);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.network-panel[hidden] { display: none; }

.network-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  flex: none;
}

.network-panel-cols {
  display: grid;
  grid-template-columns: 42px 1fr 40px 48px 48px;
  gap: 6px;
  padding: 6px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.network-panel-list { flex: 1; overflow-y: auto; }

.network-row {
  display: grid;
  grid-template-columns: 42px 1fr 40px 48px 48px;
  gap: 6px;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border-bottom: 1px solid var(--border-soft);
  align-items: center;
}
.network-row:hover { background: rgba(255, 255, 255, 0.02); }

.net-row-method { color: var(--text-faint); font-weight: 600; }
.net-row-path {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.net-row-status { font-weight: 600; }
.net-row-status[data-level="ok"] { color: var(--accent-live); }
.net-row-status[data-level="redirect"] { color: var(--accent-warn); }
.net-row-status[data-level="error"] { color: var(--accent-down); }
.net-row-time, .net-row-size { color: var(--text-faint); }

/* ---------------------------- historial de soporte ---------------------------- */

.modal-history { max-width: 900px; }
.modal-body-history { overflow-y: auto; padding: 8px 0; }

.history-list { display: flex; flex-direction: column; }

.history-row {
  display: grid;
  grid-template-columns: 70px 1.2fr 1fr 1.4fr 1fr 70px;
  gap: 12px;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.history-row:first-child { border-top: 1px solid var(--border-soft); }

.history-action {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}
.history-action[data-action-type="browse"] { color: var(--accent-live); background: var(--accent-live-dim); }
.history-action[data-action-type="ssh"] { color: var(--accent-warn); background: var(--accent-warn-dim); }

.history-alias { font-weight: 600; }
.history-technician { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }
.history-target { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }
.history-when { color: var(--text-faint); font-size: 11.5px; }
.history-duration { color: var(--text-faint); font-family: var(--font-mono); font-size: 11px; text-align: right; }

.ssh-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-warn);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ssh-auth {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 16px;
  flex-wrap: wrap;
}
.ssh-auth label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ssh-auth input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  min-width: 120px;
}
.ssh-auth input:focus { outline: none; border-color: var(--accent-live); }

.modal-body-ssh { padding: 8px; background: #0a0e13; }
.ssh-terminal { width: 100%; height: 100%; }

/* scrollbar discreto */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

/* responsive básico */
@media (max-width: 860px) {
  .row { grid-template-columns: 20px 1fr; grid-auto-rows: auto; row-gap: 4px; }
  .row-head { display: none; }
  .cell-network, .cell-signal, .cell-battery, .cell-lastseen, .cell-actions { grid-column: 2; }
}

/* ---------------------------- login ---------------------------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 32px 28px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
}

.brand-centered { justify-content: center; margin-bottom: 28px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.login-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 14px;
  color: var(--text);
}
.login-form input:focus { outline: none; border-color: var(--accent-live); }
.login-form .btn { margin-top: 6px; }

.login-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--accent-down);
  text-align: center;
}
