/* LAN-Chat Web — port of the desktop design (see DESIGN.md / src/App.css).
   Light world: flat white over sunken gray, lavender incoming, cream outgoing,
   one black pill for the primary action. Fonts and icons are local. */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #17181a;
  --ink-2: #585c63;
  --ink-3: #666a71;
  --ground: #f7f7f8;
  --surface: #ffffff;
  --line: #ececee;
  --hover: #f1f1f3;
  --active: #e9e9ec;
  --lav: #efe9fb;
  --lav-ink: #241a3d;
  --cream: #fbf2d9;
  --cream-ink: #383013;
  --green: #2e7d46;
  --gray-dot: #a6aab1;
  --danger: #b3261e;
  --danger-soft: #fbeaea;
  --amber-ink: #8a5a00;
  --amber-bg: #fff3d6;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Inter Variable", -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font-family: inherit;
}

button {
  color: inherit;
}

::selection {
  background: #e2d7f8;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-thumb {
  background: #d8d9dc;
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #c4c5c9;
  border: 3px solid transparent;
  background-clip: content-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #d8d9dc transparent;
}

.hidden {
  display: none !important;
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}

.app-name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar-spacer {
  flex: 1;
}

.net-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  background: var(--ground);
  padding: 5px 11px;
  border-radius: 999px;
}

/* ── Gate (entrada) ─────────────────────────────────────── */
.gate {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.gate-inner {
  max-width: 46ch;
  text-align: center;
}

.gate-inner h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 10px;
}

.gate-inner > p {
  margin: 0 auto 26px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
}

.gate-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(300px, 100%);
  margin: 0 auto;
  padding: 20px;
  border-radius: 14px;
  background: var(--ground);
  border: 1px solid var(--line);
  text-align: left;
}

.gate-label {
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
}

.gate-card input {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.gate-card input:focus {
  border-color: #c6c7cc;
}

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 0;
  text-align: center;
}

/* ── Pills e icon buttons ───────────────────────────────── */
.pill {
  flex: none;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.pill:hover:enabled {
  background: #2e2f33;
}

.pill:active:enabled {
  transform: scale(0.98);
}

.pill:disabled {
  background: #e5e5e8;
  color: #9a9da3;
  cursor: default;
}

.pill-small {
  padding: 6px 14px;
  font-size: 13px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-btn:disabled:hover {
  background: transparent;
  color: var(--ink-2);
}

/* ── Shell ──────────────────────────────────────────────── */
.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.list-col {
  background: var(--ground);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.list-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 10px 10px 16px;
}

.list-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.list-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.list-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.device-row:hover {
  background: var(--hover);
}

.device-row.is-selected {
  background: var(--active);
}

.device-row.is-entering {
  animation: row-in 0.5s var(--ease) backwards;
}

.device-row.is-offline .device-name {
  color: var(--ink-2);
}

.avatar {
  position: relative;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  flex: none;
  user-select: none;
}

.avatar-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ground);
}

.conv-head .avatar-dot {
  border-color: var(--surface);
}

.avatar-dot.is-online {
  background: var(--green);
}

.avatar-dot.is-offline {
  background: var(--gray-dot);
}

.device-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.device-name {
  font-size: 14px;
  font-weight: 590;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-preview {
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-side {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-time {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.unread-badge {
  min-width: 19px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.list-empty {
  padding: 26px 14px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.55;
}

.list-empty p {
  margin: 14px 4px 0;
}

/* ── Conversación ───────────────────────────────────────── */
.conv-col {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.welcome {
  margin: auto;
  max-width: 44ch;
  text-align: center;
  padding: 32px;
}

.welcome h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 10px;
}

.welcome p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
}

.conv {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.conv-head {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.is-back {
  display: none;
  margin-left: -6px;
}

.conv-title {
  flex: 1;
  min-width: 0;
}

.conv-title h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
}

.conv-status.is-off {
  color: var(--ink-3);
}

.conv-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 12px;
  display: flex;
  flex-direction: column;
}

.conv-empty {
  margin: auto;
  text-align: center;
  max-width: 40ch;
  padding: 24px;
}

.conv-empty-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.conv-empty-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.5;
}

.conv-thread {
  width: 100%;
  margin-top: auto;
}

.thread-unit {
  display: flex;
  flex-direction: column;
}

.day-chip,
.system-row {
  align-self: center;
  width: fit-content;
  max-width: 90%;
  background: var(--hover);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 550;
  padding: 4px 12px;
  border-radius: 999px;
  margin: 6px auto 12px;
  text-align: center;
}

.bubble-row {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.bubble-row.is-grouped {
  margin-top: 3px;
}

.bubble-row.is-mine {
  align-items: flex-end;
}

.bubble-row.is-theirs {
  align-items: flex-start;
}

.bubble {
  max-width: min(560px, 78%);
  padding: 9px 12px 7px;
  border: none;
  border-radius: 18px;
  text-align: left;
  cursor: default;
  font-size: 14.5px;
  line-height: 1.42;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: rise 0.24s var(--ease) backwards;
}

.is-theirs .bubble {
  background: var(--lav);
  color: var(--lav-ink);
  border-bottom-left-radius: 6px;
}

.is-mine .bubble {
  background: var(--cream);
  color: var(--cream-ink);
  border-bottom-right-radius: 6px;
}

.bubble-row.is-grouped .bubble {
  border-bottom-left-radius: 18px;
}

.is-mine.bubble-row.is-grouped .bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}

.is-theirs.bubble-row.is-grouped .bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}

.bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.is-copyable {
  cursor: pointer;
}

.bubble.is-copyable:hover {
  filter: brightness(0.985);
}

.bubble-meta {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(23, 24, 26, 0.06);
  margin-bottom: 2px;
  text-decoration: none;
  color: inherit;
  font-size: 13.5px;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.file-card svg {
  flex: none;
}

.file-size {
  font-weight: 400;
  opacity: 0.75;
  white-space: nowrap;
}

.bubble-img {
  display: block;
  max-width: min(240px, 100%);
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 6px;
}

/* ── Composer ───────────────────────────────────────────── */
.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer-field {
  flex: 1;
  display: flex;
  align-items: flex-end;
  position: relative;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.composer-field:focus-within {
  border-color: #c6c7cc;
  background: var(--surface);
}

.composer-field textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--ink);
  caret-color: var(--ink);
  padding: 10px 12px;
  max-height: 120px;
}

.composer-field textarea::placeholder {
  color: var(--ink-3);
}

.composer-field textarea:disabled {
  color: var(--ink-3);
  cursor: default;
}

.composer-count {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ── Vinculación (pin-card de la desktop) ───────────────── */
.pin-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 26, 0.72);
  z-index: 60;
}

.pin-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 90%);
  padding: 20px;
  border-radius: 14px;
  background: #232630;
  color: #f2f3f5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.pin-card h3 {
  margin: 0;
  font-size: 15px;
  color: #f2f3f5;
}

.pin-card p {
  margin: 0;
  font-size: 12.5px;
  opacity: 0.78;
  color: #f2f3f5;
}

.pin-card input {
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #f2f3f5;
  font-size: 14px;
  letter-spacing: 2px;
}

.pin-error {
  color: #ff6b6b;
  font-size: 12.5px;
  min-height: 16px;
}

.pin-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pill-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #f2f3f5;
}

.pin-card .pill:hover:enabled {
  background: #2e2f33;
}

/* ── Conexión perdida ───────────────────────────────────── */
.offline-banner {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(23, 24, 26, 0.14), 0 2px 8px rgba(23, 24, 26, 0.08);
  font-size: 13.5px;
  color: var(--ink);
}

.offline-banner svg {
  flex: none;
  color: var(--ink-2);
}

/* ── Drag & drop ────────────────────────────────────────── */
.app.is-dragging::after {
  content: "Soltá para enviar al chat abierto";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 26, 0.72);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  z-index: 50;
  pointer-events: none;
}

/* ── Animaciones ────────────────────────────────────────── */
@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Layout angosto: una columna a la vez ───────────────── */
@media (max-width: 700px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .list-col,
  .conv-col {
    grid-area: 1 / 1;
  }

  .conv-col .welcome {
    display: none;
  }

  .conv-col {
    display: none;
  }

  .shell.show-conv .list-col {
    display: none;
  }

  .shell.show-conv .conv-col {
    display: flex;
  }

  .is-back {
    display: grid;
  }

  .conv-scroll {
    padding: 14px 14px 10px;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .bubble {
    max-width: 86%;
  }

  .offline-banner {
    top: 48px;
    font-size: 12.5px;
  }
}
