/* Wabotia — panel. Mismo sistema que la web pública (wabotia.es):
   Open Runde, monocromo con acción negra en píldora, azul de marca para
   detalles y foco, superficies redondeadas con sombras casi invisibles. */

@font-face {
  font-family: "Open Runde";
  src: url("/fonts/OpenRunde-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Open Runde";
  src: url("/fonts/OpenRunde-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Open Runde";
  src: url("/fonts/OpenRunde-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #ffffff;
  --sidebar: #f4f5f7;
  --cloud: #f4f5f7;
  --ink: #0a0b10;
  --muted: #5e6070;
  --faint: #8b8c98;
  --line: #e6e7ec;
  --control: #d3d5dd;
  --action: #214cc4;
  --brand-tint: #e3eafb;
  --error: #b42334;
  --good: #1f7a45;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-button:
    0 1px 2px rgba(20, 22, 32, 0.12), 0 3px 3px rgba(20, 22, 32, 0.08);
  --shadow-float:
    0 1px 2px rgba(18, 52, 140, 0.06), 0 8px 24px rgba(18, 52, 140, 0.07);
  --sky: linear-gradient(
    180deg,
    #3a5fcc 0%,
    #5b7edb 40%,
    #93ade8 70%,
    #d6e1f7 100%
  );
  font:
    14px/1.5 "Open Runde",
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: inherit;
}
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button,
a {
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}
input,
textarea {
  caret-color: var(--action);
}
::selection {
  background: var(--brand-tint);
  color: #183f91;
}
:focus-visible {
  outline: 3px solid var(--action);
  outline-offset: 3px;
  border-radius: 8px;
}
a {
  color: var(--action);
  text-underline-offset: 3px;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.035em;
}
h2 {
  font-size: 17px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 30;
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
}
.skip:focus {
  top: 16px;
}

/* Marca: logotipo + nombre, sin cambiar el marcado */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.035em;
}
.brand::before {
  content: "";
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: url("/wabotia-mark.png") center / cover no-repeat;
  box-shadow: 0 2px 6px rgba(18, 52, 140, 0.18);
}

/* Estructura */
.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  padding: 22px 14px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar .brand {
  padding: 0 8px;
}
.sidebar select {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px rgba(18, 52, 140, 0.05);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  color: var(--muted);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav button:hover {
  background: #e9eaef;
  color: var(--ink);
}
.nav button[aria-current="page"] {
  color: var(--ink);
  background: white;
  font-weight: 600;
  box-shadow:
    0 0 0 1px var(--line),
    var(--shadow-float);
}
.nav button[aria-current="page"] svg {
  stroke: var(--action);
}
.nav svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.account {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  padding: 16px 12px 0;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  gap: 12px;
  overflow-wrap: anywhere;
}
.account span {
  color: var(--muted);
  font-weight: 400;
}
.account:hover span {
  color: var(--ink);
}
.content {
  padding: 32px 44px;
  min-width: 0;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
  min-height: 40px;
}

/* Pestañas en control segmentado, como en la web */
.tabs {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin-bottom: 36px;
  padding: 4px;
  border-radius: 999px;
  background: var(--cloud);
  overflow-x: auto;
}
.tabs button {
  background: none;
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.tabs button:hover {
  color: var(--ink);
}
.tabs button[aria-selected="true"] {
  color: var(--ink);
  background: white;
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(10, 11, 16, 0.08),
    0 4px 12px rgba(18, 52, 140, 0.06);
}

/* Ajustes y formularios */
.settings {
  max-width: 660px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--cloud);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--faint);
}
.status.good {
  color: var(--action);
  background: var(--brand-tint);
}
.status.good::before {
  background: var(--action);
}
.field {
  display: block;
  margin-bottom: 20px;
}
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}
.field input,
.field select,
.field textarea,
.composer > textarea {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  padding: 11px 13px;
  background: white;
  color: var(--ink);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.field input:hover,
.field select:hover,
.field textarea:hover,
.composer > textarea:hover {
  border-color: #b9bcc8;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.composer > textarea:focus {
  outline: none;
  border-color: var(--action);
  box-shadow: 0 0 0 4px rgba(33, 76, 196, 0.14);
}
.field textarea,
.composer > textarea {
  resize: vertical;
  line-height: 1.6;
}
.field input::placeholder,
textarea::placeholder {
  color: var(--faint);
  opacity: 1;
}
.field input[readonly] {
  background: var(--cloud);
  border-color: transparent;
  font-size: 12.5px;
  text-overflow: ellipsis;
}
.two-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Botones en píldora: acción negra, secundaria blanca */
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 0 18px;
  min-height: 40px;
  color: white;
  background: var(--ink);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-button);
}
.button:hover:not(:disabled) {
  background: #262833;
}
.button.secondary {
  background: white;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--control);
}
.button.secondary:hover:not(:disabled) {
  background: white;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.text-button {
  padding: 7px 0;
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--control);
  text-underline-offset: 4px;
  font-size: 13px;
}
.text-button:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}
.danger {
  color: var(--error);
}
.divided {
  margin-top: 32px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}
details {
  margin-bottom: 24px;
}
summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  list-style-position: inside;
}
summary::marker {
  color: var(--faint);
}
summary:hover {
  color: var(--ink);
}
details[open] > summary {
  margin-bottom: 22px;
  color: var(--ink);
}
.inline-error,
.blocking {
  color: var(--error);
  font-size: 13px;
  margin-top: 16px;
  overflow-wrap: anywhere;
}
.blocking {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fdf0f1;
}
.inline-error:empty {
  display: none;
}
.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  margin: 24px 0;
}
.check-field input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--action);
}
.usage {
  margin: 32px 0 0;
  padding: 8px 18px;
  border-radius: var(--radius-lg);
  background: var(--cloud);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.usage > div {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
}
.usage > div + div {
  border-top: 1px solid var(--line);
}
.usage dt {
  color: var(--muted);
}
.usage dd {
  margin: 0;
  font-weight: 500;
}

/* Acceso: el cielo de la web y una tarjeta blanca */
.auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--sky);
}
.auth-form {
  max-width: 400px;
  width: 100%;
  padding: 36px 32px 32px;
  border-radius: 28px;
  background: white;
  box-shadow:
    0 0 0 1px rgba(10, 11, 16, 0.04),
    0 30px 60px rgba(18, 40, 110, 0.22);
}
.auth-form .brand {
  margin-bottom: 34px;
}
.auth-form h1 {
  margin-bottom: 26px;
  font-size: 28px;
}
.auth-form .button {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
}

/* Vacíos y listas */
.empty {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  text-align: center;
}
.empty h2 {
  font-weight: 500;
  color: var(--muted);
}
.client-list {
  display: grid;
  gap: 8px;
}
.client-row {
  display: block;
  width: 100%;
  padding: 16px 18px;
  background: white;
  border: 0;
  border-radius: 16px;
  text-align: left;
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--line);
}
.client-row:hover {
  box-shadow:
    0 0 0 1px var(--control),
    var(--shadow-float);
}

/* Conocimiento */
.document-layout {
  max-width: 940px;
}
.document-editor {
  padding: 24px;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  background: var(--cloud);
}
.document-editor .field input,
.document-editor .field textarea {
  border-color: transparent;
  box-shadow: 0 0 0 1px var(--line);
}
.document-editor textarea {
  min-height: 300px;
}
.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
  margin-right: 12px;
  border-radius: 999px;
  background: white;
  box-shadow: inset 0 0 0 1px var(--control);
  font-size: 13.5px;
  font-weight: 500;
  vertical-align: middle;
}
.file-button:hover {
  box-shadow: inset 0 0 0 1px var(--ink);
}
.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.file-button:focus-within {
  outline: 3px solid var(--action);
  outline-offset: 3px;
}
.documents {
  display: grid;
  gap: 8px;
}
.document {
  padding: 16px 18px;
  margin: 0;
  border-radius: 16px;
  background: white;
  box-shadow: 0 0 0 1px var(--line);
}
.document[open] {
  box-shadow:
    0 0 0 1px var(--control),
    var(--shadow-float);
}
.document summary {
  color: var(--ink);
}
.document summary strong {
  font-weight: 600;
}
.document summary span {
  float: right;
  margin-left: 16px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--cloud);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.document pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow: auto;
  font: inherit;
  line-height: 1.7;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--cloud);
}

/* Bandeja */
.inbox-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  border-radius: 24px;
  background: var(--cloud);
  padding: 8px;
  gap: 8px;
}
.inbox-content {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}
.inbox-content > .page-header {
  flex: none;
}
.conversation-list {
  padding: 4px;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conversation-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: none;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
}
.conversation-item:hover {
  background: rgba(255, 255, 255, 0.7);
}
.conversation-item[aria-current="true"] {
  background: white;
  box-shadow: var(--shadow-float);
}
.conversation-item strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.conversation-item span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}
.thread {
  padding: 20px 24px 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 18px;
  background: white;
  box-shadow: 0 0 0 1px var(--line);
}
.inbox-layout > .empty {
  min-height: 0;
  border-radius: 18px;
  background: white;
  box-shadow: 0 0 0 1px var(--line);
}
.thread-back {
  display: none;
}
.thread .chat-log {
  height: auto;
  min-height: 0;
  flex: 1;
}
.thread > .thread-header,
.thread > .composer {
  flex: none;
}
.thread-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.chat-log {
  min-height: 280px;
  height: calc(100dvh - 390px);
  overflow: auto;
  padding: 24px 2px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-message {
  max-width: 78%;
  align-self: flex-start;
  font-size: 14px;
}
.chat-message.user {
  align-self: flex-end;
}
.chat-message > p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 11px 15px;
  background: var(--cloud);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  line-height: 1.45;
}
.chat-message.user > p {
  background: var(--brand-tint);
  border-radius: 18px;
  border-bottom-right-radius: 6px;
}
.chat-message small {
  display: block;
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 5px;
  padding: 0 4px;
}
.chat-message.user small {
  text-align: right;
}
.chat-message details {
  font-size: 12px;
  margin-top: 10px;
}
.composer {
  border-top: 1px solid var(--line);
  padding: 16px 0 20px;
}
.composer .field {
  margin-bottom: 10px;
}
.composer > textarea {
  border-radius: 16px;
}
.composer .button {
  margin-top: 10px;
}

/* Pruebas */
.playground {
  max-width: 900px;
}
.playground .chat-log {
  height: calc(100dvh - 340px);
  min-height: 320px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: white;
  box-shadow: 0 0 0 1px var(--line);
}
.playground .composer {
  border-top: 0;
}

/* Avisos */
.notice {
  position: fixed;
  bottom: 20px;
  right: 24px;
  z-index: 20;
  max-width: min(440px, calc(100vw - 40px));
  background: var(--ink);
  color: white;
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(10, 11, 16, 0.25);
}
.notice.error {
  background: var(--error);
}
.loading {
  padding: 40px;
  color: var(--muted);
}

@media (max-width: 1000px) {
  .content {
    padding: 28px 24px;
  }
  .inbox-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .thread-header {
    align-items: flex-start;
  }
}
@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    padding: 14px 16px;
    gap: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar > .brand {
    padding: 0;
  }
  .sidebar select {
    max-width: 320px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .nav button {
    padding: 7px 12px;
    gap: 6px;
  }
  .sidebar-bottom {
    margin-top: 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
  }
  .sidebar-bottom .nav button {
    font-size: 12.5px;
  }
  .sidebar-bottom .nav svg {
    display: none;
  }
  .account {
    border: 0;
    padding: 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    text-align: right;
  }
  .content {
    padding: 22px 16px;
  }
  .page-header {
    margin-bottom: 20px;
  }
  .tabs {
    margin-bottom: 26px;
  }
  .inbox-layout {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 6px;
  }
  .inbox-content {
    height: auto;
    display: block;
  }
  .shell.has-thread {
    height: var(--viewport-height, 100dvh);
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }
  .has-thread .sidebar,
  .has-thread .inbox-content > .page-header,
  .has-thread .conversation-list {
    display: none;
  }
  .has-thread .inbox-content {
    height: 100%;
    min-height: 0;
    padding: 0;
  }
  .has-thread .inbox-layout {
    height: 100%;
    grid-template-rows: minmax(0, 1fr);
    border-radius: 0;
    padding: 0;
    background: white;
  }
  .has-thread .thread {
    height: 100%;
    padding: 12px 16px 0;
    border-radius: 0;
    box-shadow: none;
  }
  .thread-back {
    display: block;
    flex-basis: 100%;
    text-align: left;
  }
  .thread-header {
    gap: 12px;
  }
  .thread-header .actions {
    gap: 8px;
  }
  .thread .composer {
    padding: 12px 0;
  }
  .thread .composer textarea {
    min-height: 64px;
    max-height: 25dvh;
    font-size: 16px;
  }
  .conversation-list {
    padding: 4px;
    max-height: 220px;
    overflow: auto;
  }
  .thread {
    padding: 18px 16px 0;
  }
  .chat-log {
    height: 340px;
    min-height: 0;
  }
  .chat-message {
    max-width: 88%;
  }
  .empty {
    min-height: 240px;
  }
  .two-fields {
    gap: 16px;
  }
  .document summary span {
    float: none;
    display: inline-block;
    margin: 8px 0 0;
  }
  .auth-form {
    padding: 28px 22px 24px;
  }
}
.consent {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  cursor: pointer;
}
.consent input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: 0 0 18px;
  margin: 0;
  accent-color: var(--action);
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
