/* worlo-tines.css starts every non-landing fx-tines body at opacity:0 and waits
   for a .ready class to fade it in. The standalone Teams pages don't run that
   bootstrap script, so without this override they render permanently blank. */
body.fx-tines.teams-app {
  opacity: 1 !important;
}

.teams-app {
  min-height: 100vh;
  background: transparent;
}

:root {
  --teams-ink: #12121a;
  --teams-line: rgba(15, 35, 65, 0.1);
  --teams-line-strong: rgba(15, 35, 65, 0.16);
  --teams-surface: rgba(255, 255, 255, 0.96);
  --teams-radius: 16px;
}

/* ----------------------------------------------------------------- auth view */

.teams-view {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.teams-view.hidden {
  display: none;
}

.teams-auth-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--fx-radius-xl, 20px);
  box-shadow: 0 18px 60px rgba(45, 90, 135, 0.16);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.teams-app .btn-primary {
  background: var(--teams-ink) !important;
  color: #fff !important;
}

.teams-logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fx-text);
  text-decoration: none;
  display: block;
  margin-bottom: 12px;
}

.teams-auth-lead {
  font-size: 14px;
  color: var(--fx-text-secondary);
  line-height: 1.55;
  margin-bottom: 28px;
}

.teams-auth-lead a {
  color: var(--fx-sky, #2d5a87);
  font-weight: 600;
  text-decoration: none;
}

.teams-auth-lead a:hover {
  text-decoration: underline;
}

.teams-auth-foot {
  margin-top: 20px;
  font-size: 13px;
  color: var(--fx-text-tertiary);
  text-align: center;
}

.teams-auth-foot a {
  color: var(--fx-sky, #3b6fd9);
  font-weight: 600;
}

.form-optional {
  font-weight: 400;
  color: var(--fx-text-tertiary);
  font-size: 12px;
}

#btn-join:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ chat app */

#view-chat {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  height: 100vh;
  min-height: 100vh;
}

.teams-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
  padding: 0 20px;
  background: var(--teams-surface);
  border-bottom: 1px solid var(--teams-line);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.teams-header-left {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.teams-logo-sm {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--teams-ink);
  white-space: nowrap;
}

.teams-user-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--fx-text-secondary);
  background: rgba(15, 35, 65, 0.05);
  border: 1px solid var(--teams-line);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.teams-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  background: #eef1f5;
  padding: 4px;
  border-radius: 999px;
}

.teams-tab {
  border: none;
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fx-text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.teams-tab:hover {
  color: var(--teams-ink);
}

.teams-tab.active {
  background: #fff;
  color: var(--teams-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-signout {
  flex: 0 0 auto;
  border: 1px solid var(--teams-line-strong);
  background: #fff;
  color: var(--fx-text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-signout:hover {
  background: #f6f7f9;
  color: var(--teams-ink);
}

/* Chat app fills the window edge-to-edge so everything sits flush to the
   borders. Message bubbles are capped separately for readability. */
.teams-main {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.55);
}

.teams-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--teams-line);
  background: rgba(255, 255, 255, 0.45);
  padding: 18px 14px;
  overflow-y: auto;
}

.teams-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fx-text-tertiary);
  margin: 0 0 10px;
  padding: 0 8px;
}

.teams-member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.teams-member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--fx-text);
}

.teams-member:hover {
  background: rgba(15, 35, 65, 0.04);
}

.member-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7ccd4;
  flex-shrink: 0;
}

.teams-member.online .member-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.member-name {
  flex: 1;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}

.teams-panels {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.teams-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.teams-panel.active {
  display: flex;
}

.teams-ai-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fx-text-secondary);
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid var(--teams-line);
}

.teams-ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6366f1;
}

.teams-ai-private {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fx-text-tertiary);
  background: rgba(15, 35, 65, 0.05);
  padding: 2px 8px;
  border-radius: 999px;
}

.teams-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------- message bubbles */

.msg {
  max-width: min(86%, 760px);
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg.user {
  align-self: flex-end;
  margin-left: auto;
  background: var(--teams-ink);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.bot,
.msg.peer {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--teams-line);
  color: var(--fx-text);
  border-bottom-left-radius: 5px;
}

.msg.err {
  align-self: flex-start;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.msg.team-msg {
  max-width: 78%;
}

/* AI replies inside the group chat */
.msg.ai-msg {
  align-self: flex-start;
  background: #f4f4ff;
  border: 1px solid #dcdcfb;
  color: #1e1b4b;
  border-bottom-left-radius: 5px;
}

.msg-sender {
  font-size: 11px;
  font-weight: 700;
  color: var(--fx-text-secondary);
  margin-bottom: 3px;
}

.msg.ai-msg .msg-sender {
  color: #4f46e5;
  display: flex;
  align-items: center;
  gap: 5px;
}

.msg.ai-msg .msg-sender::before {
  content: "✦";
  font-size: 12px;
}

.msg-body {
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* typing / thinking indicator */
.msg-typing {
  min-width: 56px;
  padding: 14px 18px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 10px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: teams-typing-bounce 1.2s ease-in-out infinite;
}

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

@keyframes teams-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.msg-revealing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #6b7280;
  animation: teams-cursor-blink 0.8s step-end infinite;
}

@keyframes teams-cursor-blink {
  50% { opacity: 0; }
}

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

.teams-compose {
  flex: 0 0 auto;
  padding: 14px 24px 18px;
  background: var(--teams-surface);
  border-top: 1px solid var(--teams-line);
}

.teams-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--teams-line-strong);
  border-radius: 14px;
  padding: 6px 6px 6px 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.teams-compose-row:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.teams-compose textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  max-height: 140px;
  color: var(--fx-text);
}

.teams-send-btn {
  flex: 0 0 auto;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.teams-ai-btn {
  flex: 0 0 auto;
  border: none;
  background: var(--teams-ink);
  color: #fff;
  border-radius: 6px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.teams-ai-btn:hover {
  background: #2a2a35;
}

.btn-send--working {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
}

.send-spinner {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
}

.send-spinner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: teams-send-spin 0.7s linear infinite;
}

.send-spinner::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 2px;
}

@keyframes teams-send-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .teams-main {
    max-width: 100%;
    border-left: none;
    border-right: none;
  }
  .teams-sidebar { display: none; }
  .teams-header { padding: 0 14px; gap: 10px; }
  .teams-user-chip { display: none; }
  .msg { max-width: 88%; }
}

/* worlo-tines.css styles bare <header> and <main> elements as a fixed site nav
   with offset content (body.fx-tines header / main). Those element selectors
   outrank our .teams-* classes and were pinning the header on top of the chat
   (hiding the first member + title) and shrinking the message area. Re-assert
   the Teams chrome here with higher specificity so the layout stays correct. */
body.teams-app header.teams-header {
  position: sticky;
  top: 0;
  left: auto;
  right: auto;
  box-sizing: border-box;
  width: auto;
  height: 60px;
  margin: 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--teams-surface);
  border-bottom: 1px solid var(--teams-line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10;
}

body.teams-app main.teams-chat {
  margin: 0;
  max-width: none;
  padding: 20px 24px;
}
