/* Hydrosphere Mobile — alineado a gui/theme.py DARK */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg-main: #0d0f12;
  --bg-panel: #111419;
  --bg-surface: #0a0c0f;
  --border: #1e2530;
  --accent: #007bff;
  --accent-hover: #1689ff;
  --accent-dim: rgba(0, 123, 255, 0.12);
  --accent2: #34a853;
  --text: #c8d0dc;
  --text-dim: #556070;
  --text-muted: #8ea0b5;
  --text-strong: #ffffff;
  --warning: #ffaa00;
  --danger: #ff4455;
  --ok: #7ddea0;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
  max-width: 100vw;
}

body {
  height: 100%;
  background: var(--bg-main);
}

img.icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  filter: brightness(0) invert(0.85);
}

img.icon.accent {
  filter: invert(42%) sepia(98%) saturate(1800%) hue-rotate(192deg) brightness(101%) contrast(101%);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--accent-hover);
}

.app-shell {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  max-height: 100dvh;
  position: relative;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  background: var(--bg-main);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.view {
  display: none;
  padding: 12px 16px 8px;
  animation: rise 0.35s var(--ease) both;
}

.view.active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 44px;
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 18px;
  height: 18px;
  display: block;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.status-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-chip.online .dot {
  background: var(--accent2);
}
.status-chip.online {
  color: var(--ok);
  border-color: rgba(52, 168, 83, 0.35);
}

.status-chip.demo .dot {
  background: var(--warning);
}
.status-chip.offline .dot {
  background: var(--danger);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-strong);
}

.panel.warn-panel {
  border-color: rgba(255, 170, 0, 0.45);
  background: #1a1710;
}

a.btn {
  text-decoration: none;
}

.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 12px;
}

.ssid-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.steps {
  margin: 0 0 14px;
  padding-left: 1.2rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.steps code {
  color: var(--text-strong);
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1 1 auto;
  transition: background 0.15s var(--ease), border-color 0.15s;
}

.btn .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary .icon {
  filter: brightness(0) invert(1);
}

/* Loader de botón (stud.io / MemoriaLiteral) */
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--busy:disabled {
  opacity: 1;
  cursor: wait;
}

.btn-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  height: 1em;
}

.btn-dots span {
  display: block;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: currentColor;
  animation: btn-dot-wave 0.9s ease-in-out infinite;
}

.btn-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.btn-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes btn-dot-wave {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-0.35em);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent-hover);
  background: var(--accent-dim);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 68, 85, 0.45);
}

.btn-sm {
  min-height: 36px;
  font-size: 0.85rem;
  padding: 6px 12px;
  flex: 0 0 auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input,
.search-bar input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-strong);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.search-bar input {
  border: 0;
  background: transparent;
  min-height: 42px;
  padding-left: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.metric .label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric .value {
  font-size: 0.95rem;
  color: var(--text-strong);
  word-break: break-all;
}

.metric.ok .value {
  color: var(--ok);
}
.metric.warn .value {
  color: var(--warning);
}
.metric.err .value {
  color: var(--danger);
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-btn {
  text-align: left;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 88px;
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn.hot {
  border-color: rgba(0, 123, 255, 0.55);
  background: var(--accent-dim);
}

.action-btn strong {
  color: var(--text-strong);
  font-size: 0.9rem;
}

.action-btn .hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.3;
}

.log-box {
  max-height: 160px;
  overflow: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--border);
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row .meta {
  flex: 1;
  min-width: 0;
}

.file-row .name {
  color: var(--text-strong);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  gap: 4px;
  background: linear-gradient(
    to top,
    var(--bg-main) 0%,
    var(--bg-main) 35%,
    rgba(13, 15, 18, 0) 100%
  );
  border-top: none;
  z-index: 20;
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--text-dim);
  border-radius: 10px;
  padding: 6px 4px;
  min-height: 48px;
  align-self: center;
}

.bottom-nav button.active {
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.bottom-nav button.active .icon {
  filter: invert(42%) sepia(98%) saturate(1800%) hue-rotate(192deg) brightness(101%) contrast(101%);
}

.fab-install {
  position: fixed;
  right: max(16px, calc(50% - 240px + 16px));
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 123, 255, 0.35);
  display: grid;
  place-items: center;
  z-index: 25;
}

.fab-install .icon {
  filter: brightness(0) invert(1);
  width: 1.4rem;
  height: 1.4rem;
}

.fab-install.hidden,
.hidden {
  display: none !important;
}

.update-banner {
  display: none;
  margin: 12px 16px 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(0, 123, 255, 0.45);
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
}

.update-banner.show {
  display: flex;
}

.update-banner p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-strong);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.update-banner .btn {
  width: 100%;
  flex: 0 0 auto;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 20px);
  max-width: 448px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: #1a2030;
  border: 1px solid var(--border);
  color: var(--text-strong);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s var(--ease);
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.err {
  border-color: rgba(255, 68, 85, 0.55);
}
