/* ============================================================
   team-chat.css — Communication → Team

   Layout is taken from the supplied mockup (list / thread / composer,
   mobile list-to-thread switch). Colours come from the app's own tokens
   so it reads correctly in both light and dark themes instead of
   hardcoding the mockup's obsidian palette.
   ============================================================ */

.tc-app {
  display: flex;
  height: calc(100vh - 190px);
  min-height: 460px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
  position: relative;
}

/* ---------------- conversation list ---------------- */

.tc-list {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--elev);
}

.tc-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 10px;
}

.tc-list-title b {
  display: block;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.3px;
  color: var(--text);
}

.tc-list-sub {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.tc-icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.tc-icon-btn:hover { background: var(--primary-soft); color: var(--primary-dark); }
.tc-icon-btn svg { width: 18px; height: 18px; }

.tc-search-wrap { position: relative; padding: 0 14px 10px; }

.tc-search-ic {
  position: absolute;
  left: 26px;
  top: 11px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.tc-search {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  padding: 0 12px 0 36px;
  font-size: 12px;
  outline: none;
}

.tc-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tc-search::placeholder { color: var(--muted); }

.tc-filters { display: flex; gap: 6px; padding: 0 14px 10px; }

.tc-filter {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}

.tc-filter:hover { border-color: var(--primary); color: var(--primary); }
.tc-filter.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

.tc-rows { flex: 1; overflow-y: auto; min-height: 0; padding: 2px 8px 10px; }

.tc-rows-empty,
.tc-contact-empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.tc-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background .15s ease;
}

.tc-row:hover { background: var(--card); }
.tc-row.is-active { background: var(--card); box-shadow: inset 2px 0 var(--primary); }

.tc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  color: #f7edda;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
  border: 1px solid rgba(255,255,255,.08);
}

.tc-row-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.tc-row-line,
.tc-row-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.tc-row-line b {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tc-row-time { font-size: 9.5px; color: var(--muted); white-space: nowrap; flex: none; }

.tc-row-preview > span:first-child {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tc-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  flex: none;
}

/* ---------------- thread ---------------- */

.tc-thread {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--card);
}

.tc-head {
  height: 62px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  z-index: 2;
}

.tc-head-avatar { width: 37px; height: 37px; font-size: 11px; }
.tc-peer { flex: 1; min-width: 0; }
.tc-peer-name {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-peer-status {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-sound.is-off { color: var(--danger); }
.tc-back { display: none; }

.tc-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px clamp(14px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(ellipse at 12% 0%, var(--primary-soft), transparent 42%),
    var(--card);
  scroll-behavior: smooth;
}

.tc-day { align-self: center; margin: 4px 0 6px; }
.tc-day span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
}

.tc-msg {
  max-width: min(76%, 560px);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tc-msg.is-in { align-self: flex-start; }
.tc-msg.is-out { align-self: flex-end; align-items: flex-end; }

.tc-sender {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--primary);
  padding: 0 4px;
}

.tc-bubble {
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  background: var(--elev);
  color: var(--text);
}

.tc-msg.is-in .tc-bubble { border-top-left-radius: 3px; }
.tc-msg.is-out .tc-bubble {
  border-top-right-radius: 3px;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tc-msg.is-pending .tc-bubble { opacity: .72; }
.tc-msg.is-failed .tc-bubble { border-color: var(--danger); }

.tc-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--muted);
  padding: 0 3px;
}
.tc-ticks { color: var(--primary); letter-spacing: -2px; }
.tc-msg.is-out .tc-ticks { color: var(--primary); }
.tc-failed { color: var(--danger); font-weight: 700; }

.tc-media-pending { color: inherit; opacity: .8; font-style: italic; }

.tc-thread-loading,
.tc-thread-empty,
.tc-fatal {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 30px;
}

.tc-thread-empty b { display: block; color: var(--text); font-size: 13.5px; margin: 10px 0 4px; }
.tc-thread-empty-ic {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.tc-thread-empty-ic svg { width: 24px; height: 24px; }

/* ---------------- composer ---------------- */

.tc-composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.tc-input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--elev);
  color: var(--text);
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.4;
  outline: none;
  font-family: inherit;
}
.tc-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tc-input::placeholder { color: var(--muted); }

.tc-send {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: transform .12s ease, filter .15s ease;
}
.tc-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.tc-send:disabled { opacity: .5; cursor: default; transform: none; }
.tc-send svg { width: 18px; height: 18px; }

/* ---------------- new chat modal ---------------- */

.tc-modal {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 12, 16, .55);
  backdrop-filter: blur(2px);
}
.tc-modal[hidden] { display: none; }

.tc-modal-card {
  width: min(380px, 100%);
  max-height: 70%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.tc-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.tc-contact-list { overflow-y: auto; padding: 8px; }

.tc-contact {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.tc-contact:hover { background: var(--elev); }

.tc-contact-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tc-contact-meta b { font-size: 12px; color: var(--text); font-weight: 600; }
.tc-contact-meta span { font-size: 10.5px; color: var(--muted); }

/* ---------------- mobile ---------------- */

@media (max-width: 900px) {
  .tc-app { height: calc(100vh - 160px); }
  .tc-list { width: 280px; }
}

@media (max-width: 720px) {
  .tc-app { height: calc(100vh - 150px); border-radius: 12px; }
  .tc-list { width: 100%; border-right: 0; }
  .tc-thread {
    position: absolute;
    inset: 0;
    display: none;
    z-index: 5;
    border-radius: 12px;
  }
  .tc-app.open-thread .tc-list { visibility: hidden; }
  .tc-app.open-thread .tc-thread { display: flex; }
  .tc-back { display: grid; }
  .tc-msg { max-width: 86%; }
}

/* ---------------- attachments, voice, recording ---------------- */

.tc-composer.is-recording .tc-input { opacity: .4; pointer-events: none; }

.tc-rec {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--danger-soft);
  font-size: 12px;
}
.tc-rec[hidden] { display: none; }
.tc-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  animation: tc-pulse 1.1s ease-in-out infinite;
  flex: none;
}
@keyframes tc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
.tc-rec-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--danger); }
.tc-rec-label { flex: 1; color: var(--muted); }
.tc-rec-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.tc-rec-btn.is-primary { background: var(--danger); border-color: var(--danger); color: #fff; }

.tc-bubble.is-media { padding: 6px; }
.tc-msg.is-out .tc-bubble.is-media { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }
.tc-msg.is-in .tc-bubble.is-media { background: var(--elev); color: var(--text); }

.tc-media {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  max-width: 260px;
  background: transparent;
  color: inherit;
  font: inherit;
}
.tc-media img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
}
.tc-media video {
  display: block;
  max-width: 280px;
  max-height: 320px;
  border-radius: 8px;
}
.tc-media-ph {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 92px;
  padding: 14px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 11px;
  color: var(--muted);
}
.tc-media-video {
  width: 100%;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}
.tc-media-play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  flex: none;
}
.tc-media-play svg { width: 16px; height: 16px; }
.tc-media.is-loading { opacity: .6; }
.tc-media.is-waiting .tc-media-ph { font-style: italic; }

.tc-voice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 2px;
  min-width: 160px;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.tc-voice-play {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--primary);
  flex: none;
}
.tc-voice.is-playing .tc-voice-play { background: var(--primary); border-color: var(--primary); color: #fff; }
.tc-voice-play svg { width: 13px; height: 13px; }
.tc-voice-wave {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: .3;
}
.tc-voice-time { font-size: 10px; opacity: .85; font-variant-numeric: tabular-nums; }
