/* Terrario Chat — UI compartida (oficina + campo) */
:root {
  --tc-bg: #ebe4d8;
  --tc-paper: #fffcf8;
  --tc-ink: #10211c;
  --tc-muted: #5e7169;
  --tc-brand: #0c241f;
  --tc-brand-2: #16352d;
  --tc-accent: #c45c26;
  --tc-line: rgba(12, 36, 31, 0.1);
  --tc-soft: rgba(12, 36, 31, 0.05);
  --tc-shadow: 0 10px 28px rgba(12, 36, 31, 0.08);
  --tc-radius: 1.15rem;
}

.panel-chat {
  padding: 0 !important;
  height: calc(100dvh - 5.5rem);
  max-height: calc(100dvh - 5.5rem);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.content:has(#panel-chat:not([hidden])) {
  padding: 0 !important;
  overflow: hidden;
}

body:has(#panel-chat:not([hidden])),
body:has(.campo-main.is-chat),
body.tc-chat-open {
  overflow: hidden;
}

@media (max-width: 1023px) {
  .panel-chat {
    height: calc(100dvh - 4.75rem - env(safe-area-inset-top, 0px) - var(--nav-h, 0px));
    max-height: calc(100dvh - 4.75rem - env(safe-area-inset-top, 0px) - var(--nav-h, 0px));
  }

  .tc-shell,
  .tc-shell.is-open {
    max-width: none;
    margin: 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
  }
}

.tc-root {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tc-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1200px 420px at 10% -10%, rgba(196, 92, 38, 0.1), transparent 55%),
    radial-gradient(900px 380px at 100% 0%, rgba(12, 36, 31, 0.08), transparent 50%),
    linear-gradient(180deg, #f4eee4 0%, var(--tc-bg) 48%, #e6ddd0 100%);
  color: var(--tc-ink);
}

/* Campo: el chat llena el hueco entre app-bar y tabs, sin marcos */
#view-app:has(.campo-main.is-chat) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#view-app:has(.campo-main.is-chat) .app-bar {
  flex: 0 0 auto;
}

#view-app:has(.campo-main.is-chat) #live-notice {
  flex: 0 0 auto;
}

.campo-main.is-chat {
  padding: 0 !important;
  margin: 0 !important;
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  max-height: none !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* espacio solo para los tabs fijos de abajo */
  padding-bottom: calc(4.45rem + env(safe-area-inset-bottom, 0px)) !important;
  box-sizing: border-box;
}
.campo-main.is-chat .tc-root,
.campo-main.is-chat .tc-shell {
  height: 100%;
  min-height: 0;
  width: 100%;
  max-width: none;
}

.tc-shell.is-open {
  height: 100%;
  min-height: 0;
}

.tc-shell.is-open.is-keyboard {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 80;
  width: 100%;
  max-width: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  /* top/height los pone JS con visualViewport */
}

.tc-head {
  position: sticky;
  top: 0;
  flex: 0 0 auto;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 252, 248, 0.98);
  border-bottom: 1px solid var(--tc-line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tc-shell.is-keyboard .tc-head {
  padding-top: max(0.85rem, env(safe-area-inset-top, 0px));
}

.tc-head.is-list {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 1rem 1.05rem 0.9rem;
  background: transparent;
  border-bottom: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tc-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}

.tc-head.is-list .tc-head-copy h1 {
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.tc-head.is-list .tc-lead {
  margin-top: 0.15rem;
  font-size: 0.86rem;
  color: var(--tc-muted);
}

.tc-head-copy {
  min-width: 0;
}

.tc-eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tc-muted);
  font-weight: 700;
}

.tc-head h1 {
  margin: 0.12rem 0 0;
  font-family: var(--display, Fraunces, Georgia, serif);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tc-lead {
  margin: 0.2rem 0 0;
  color: var(--tc-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.tc-head-peer {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.tc-head-peer .tc-avatar {
  width: 2.55rem;
  height: 2.55rem;
  font-size: 0.95rem;
}

.tc-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.28rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: rgba(12, 36, 31, 0.07);
  color: var(--tc-brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tc-pill::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #1a6b48;
  box-shadow: 0 0 0 3px rgba(26, 107, 72, 0.15);
}

.tc-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tc-btn {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(160deg, var(--tc-brand-2), var(--tc-brand));
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  height: 2.4rem;
  padding: 0 1rem;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(12, 36, 31, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tc-btn svg {
  width: 1rem;
  height: 1rem;
}
.tc-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(12, 36, 31, 0.22);
}
.tc-btn:active {
  transform: translateY(0);
}

.tc-back,
.tc-icon-btn {
  width: 2.45rem;
  height: 2.45rem;
  border: 1px solid var(--tc-line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--tc-ink);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tc-back:hover,
.tc-icon-btn:hover {
  background: #fff;
  border-color: rgba(12, 36, 31, 0.18);
}
.tc-back svg,
.tc-icon-btn svg,
.tc-send svg {
  width: 1.1rem;
  height: 1.1rem;
}

.tc-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 0.5rem;
  align-content: start;
  padding: 0.85rem 0.9rem 1.4rem;
}

.campo-main.is-chat .tc-list {
  padding-bottom: 1.2rem;
}

.tc-group {
  display: grid;
  gap: 0.45rem;
}
.tc-group h2 {
  margin: 0.55rem 0.15rem 0.1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--tc-muted);
  font-weight: 700;
}

.tc-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--tc-radius);
  background: rgba(255, 252, 248, 0.9);
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--tc-shadow);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.tc-row:hover {
  transform: translateY(-1px);
  border-color: rgba(12, 36, 31, 0.14);
  box-shadow: 0 14px 30px rgba(12, 36, 31, 0.1);
}
.tc-row:active {
  transform: translateY(0);
}

.tc-avatar {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 0.95rem;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1a3b32, var(--tc-brand));
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.tc-avatar.is-admin {
  background: linear-gradient(145deg, #2a4a40, #0c241f);
}
.tc-avatar.is-lavanderia {
  background: linear-gradient(145deg, #3d6a8a, #1f4660);
}
.tc-avatar.is-aseo {
  background: linear-gradient(145deg, #d07a3d, #a84a1c);
}
.tc-avatar.is-operador {
  background: linear-gradient(145deg, #4a6b55, #244033);
}

.tc-row-body {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}
.tc-row-top {
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  align-items: baseline;
}
.tc-row-top strong {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tc-row-top time,
.tc-row-meta,
.tc-row-preview {
  color: var(--tc-muted);
  font-size: 0.78rem;
}
.tc-row-top time {
  flex: none;
  font-variant-numeric: tabular-nums;
}
.tc-row-preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-row.has-unread .tc-row-preview {
  color: var(--tc-ink);
  font-weight: 600;
}

.tc-badge {
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--tc-accent);
  color: #fff;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(196, 92, 38, 0.35);
}

.tc-empty {
  margin: 1.4rem 0.5rem;
  padding: 1.4rem 1.1rem;
  border-radius: 1.2rem;
  background: rgba(255, 252, 248, 0.72);
  border: 1px dashed rgba(12, 36, 31, 0.16);
  color: var(--tc-muted);
  line-height: 1.45;
  text-align: center;
}
.tc-empty strong {
  color: var(--tc-ink);
}
.tc-empty-ico {
  width: 2.8rem;
  height: 2.8rem;
  margin: 0 auto 0.7rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: var(--tc-soft);
  color: var(--tc-brand);
}
.tc-empty-ico svg {
  width: 1.35rem;
  height: 1.35rem;
}

.tc-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1rem 0.95rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background:
    linear-gradient(180deg, rgba(12, 36, 31, 0.02), transparent 40%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 11px,
      rgba(12, 36, 31, 0.015) 11px,
      rgba(12, 36, 31, 0.015) 12px
    );
}

.tc-bubble {
  max-width: min(82%, 28rem);
  align-self: flex-start;
  background: rgba(255, 252, 248, 0.96);
  border: 1px solid rgba(12, 36, 31, 0.08);
  border-radius: 1.15rem 1.15rem 1.15rem 0.35rem;
  padding: 0.72rem 0.9rem 0.45rem;
  box-shadow: 0 6px 16px rgba(12, 36, 31, 0.05);
  animation: tc-in 0.22s ease;
}
.tc-bubble.is-mine {
  align-self: flex-end;
  background: linear-gradient(165deg, #16352d, #0c241f);
  color: #fff;
  border-color: transparent;
  border-radius: 1.15rem 1.15rem 0.35rem 1.15rem;
  box-shadow: 0 10px 22px rgba(12, 36, 31, 0.2);
}
.tc-bubble p {
  margin: 0;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.94rem;
}
.tc-bubble time {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.66rem;
  opacity: 0.62;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@keyframes tc-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tc-dock {
  position: relative;
  flex: 0 0 auto;
  z-index: 4;
  background: rgba(255, 252, 248, 0.96);
  border-top: 1px solid var(--tc-line);
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
}

.tc-quick {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.55rem 0.9rem 0.15rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tc-quick::-webkit-scrollbar {
  display: none;
}

.tc-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(12, 36, 31, 0.12);
  background: #fff;
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  color: var(--tc-ink);
  box-shadow: 0 4px 12px rgba(12, 36, 31, 0.04);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.tc-chip:hover {
  border-color: rgba(196, 92, 38, 0.35);
  background: #fff8f2;
  transform: translateY(-1px);
}

.tc-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  padding: 0.55rem 0.9rem 0.75rem;
}
.campo-main.is-chat .tc-compose {
  padding-bottom: 0.75rem;
}

.tc-compose input {
  height: 2.85rem;
  border-radius: 1rem;
  border: 1px solid rgba(12, 36, 31, 0.12);
  padding: 0 1rem;
  font: inherit;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(12, 36, 31, 0.03);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tc-compose input:focus {
  border-color: rgba(12, 36, 31, 0.28);
  box-shadow: 0 0 0 3px rgba(12, 36, 31, 0.08);
}
.tc-compose input::placeholder {
  color: #8a9a93;
}

.tc-send {
  width: 2.85rem;
  height: 2.85rem;
  padding: 0;
  border: 0;
  border-radius: 1rem;
  background: linear-gradient(160deg, var(--tc-accent), #a8471a);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(196, 92, 38, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.tc-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(196, 92, 38, 0.34);
}
.tc-send:active {
  transform: translateY(0);
}

@media (min-width: 900px) {
  .panel-chat {
    height: calc(100dvh - 6.5rem);
    max-height: calc(100dvh - 6.5rem);
  }
  .tc-shell {
    max-width: 46rem;
    margin: 0 auto;
    width: 100%;
    border-left: 1px solid rgba(12, 36, 31, 0.06);
    border-right: 1px solid rgba(12, 36, 31, 0.06);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  }
  .tc-head h1 {
    font-size: 1.5rem;
  }
}
