/* ============================================
   Tellme Admin Panel — Team Section Styles
   ============================================ */

/* --- Team Layout (3 columns) --- */

.team-layout {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  height: calc(100vh - 80px);
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

/* --- Presence Column (Left) --- */

.team-presence {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.team-presence-header {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.team-presence-count {
  font-size: 11px;
  opacity: 0.5;
  font-weight: 400;
}

.team-presence-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* --- User Card --- */

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}

.user-card:hover {
  background: var(--bg-hover);
}

.user-card.active {
  background: var(--bg-accent);
}

.user-card-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.user-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-card-avatar .status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--bg-sidebar);
}

.user-card-info {
  flex: 1;
  min-width: 0;
}

.user-card-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card-role {
  font-size: 11px;
  opacity: 0.4;
}

.user-card-badge {
  flex-shrink: 0;
}

.dnd-badge {
  background: rgba(231, 76, 60, 0.2);
  color: var(--color-danger);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Presence Section Groups --- */

.presence-group {
  margin-bottom: 8px;
}

.presence-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.4;
  padding: 8px 10px 4px;
}

/* --- Chat Column (Center) --- */

.team-chat {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

/* --- Group Chat Header --- */

.team-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background: var(--bg-card);
}

.team-chat-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.team-chat-participants {
  display: flex;
  align-items: center;
}

.participant-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-accent);
  border: 2px solid var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  margin-left: -8px;
  position: relative;
  overflow: hidden;
}

.participant-avatar:first-child {
  margin-left: 0;
}

.participant-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.participant-more {
  background: var(--bg-hover);
  color: var(--text-primary);
  opacity: 0.6;
  font-size: 9px;
}

/* --- Team Messages --- */

.team-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* --- Message Bubbles --- */

.team-msg {
  display: flex;
  gap: 10px;
  max-width: 75%;
  padding: 2px 0;
}

.team-msg.own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.team-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.team-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-msg-content {
  display: flex;
  flex-direction: column;
}

.team-msg-sender {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
  opacity: 0.7;
}

.team-msg.own .team-msg-sender {
  text-align: right;
}

.team-msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  position: relative;
  word-break: break-word;
}

.team-msg.own .team-msg-bubble {
  background: var(--bg-accent);
  border-color: transparent;
  border-bottom-right-radius: 4px;
}

.team-msg:not(.own) .team-msg-bubble {
  border-bottom-left-radius: 4px;
}

.team-msg-time {
  font-size: 10px;
  opacity: 0.35;
  margin-top: 2px;
  padding: 0 4px;
}

.team-msg.own .team-msg-time {
  text-align: right;
}

/* --- Reply Quote --- */

.team-msg-reply {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-left: 3px solid var(--highlight);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  opacity: 0.7;
  cursor: pointer;
}

.team-msg-reply:hover {
  opacity: 1;
}

.team-msg-reply-author {
  font-weight: 600;
  font-size: 11px;
  color: var(--highlight);
  margin-bottom: 2px;
}

/* --- Reactions --- */

.team-msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.reaction-badge:hover {
  border-color: var(--highlight);
}

.reaction-badge.reacted {
  background: rgba(233, 69, 96, 0.15);
  border-color: var(--highlight);
}

.reaction-badge .reaction-count {
  font-size: 10px;
  opacity: 0.6;
}

/* --- Typing Indicator --- */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  font-size: 12px;
  opacity: 0.5;
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--text-primary);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

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

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

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

/* --- File Attachment in DM --- */

.team-msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-top: 6px;
  cursor: pointer;
  transition: background var(--transition);
}

.team-msg-file:hover {
  background: var(--bg-hover);
}

.team-msg-file-icon {
  font-size: 20px;
  opacity: 0.5;
}

.team-msg-file-info {
  flex: 1;
  min-width: 0;
}

.team-msg-file-name {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-msg-file-size {
  font-size: 10px;
  opacity: 0.4;
}

/* --- Team Chat Input --- */

.team-chat-input {
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  flex-shrink: 0;
  background: var(--bg-card);
}

.team-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.team-chat-textarea {
  flex: 1;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-family);
  line-height: 1.5;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  outline: none;
  transition: border-color var(--transition);
}

.team-chat-textarea:focus {
  border-color: var(--highlight);
}

.team-chat-textarea::placeholder {
  color: var(--text-primary);
  opacity: 0.3;
}

/* --- Call Column (Right) --- */

.team-call {
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.team-call-header {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.team-call-status {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.5;
}

.team-call-status.active {
  color: var(--color-success);
  opacity: 1;
}

/* --- Video Grid --- */

.team-call-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
}

.team-call-grid.two-up {
  grid-template-columns: 1fr 1fr;
}

.team-call-grid.multi {
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
}

.video-tile {
  position: relative;
  background: var(--bg-primary);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile-name {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
}

.video-tile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

.video-tile-muted {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  opacity: 0.6;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- Call Controls --- */

.team-call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.call-control-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.call-control-btn:hover {
  background: var(--bg-accent);
}

.call-control-btn.active {
  background: var(--bg-accent);
  color: var(--color-success);
}

.call-control-btn.muted {
  background: rgba(231, 76, 60, 0.2);
  color: var(--color-danger);
}

.call-control-btn.hangup {
  background: var(--color-danger);
  color: #fff;
}

.call-control-btn.hangup:hover {
  background: #c0392b;
}

.call-join-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--color-success);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: var(--font-family);
}

.call-join-btn:hover {
  background: #27ae60;
}

/* --- Empty / Placeholder States --- */

.team-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  opacity: 0.3;
  font-size: 13px;
  gap: 8px;
}

.team-empty-icon {
  font-size: 32px;
}

/* --- Responsive --- */

@media (max-width: 1024px) {
  .team-layout {
    grid-template-columns: 200px 1fr;
  }

  .team-call {
    display: none;
  }

  .team-layout.call-active {
    grid-template-columns: 1fr;
  }

  .team-layout.call-active .team-presence,
  .team-layout.call-active .team-chat {
    display: none;
  }

  .team-layout.call-active .team-call {
    display: flex;
  }
}

@media (max-width: 768px) {
  .team-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .team-presence {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    max-height: 180px;
  }

  .team-presence-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
    padding: 8px;
  }

  .user-card {
    flex-shrink: 0;
    min-width: 120px;
  }

  .presence-group {
    display: flex;
    gap: 4px;
  }

  .presence-group-label {
    writing-mode: vertical-lr;
    padding: 4px 2px;
  }
}

@media (max-width: 480px) {
  .team-layout {
    height: calc(100vh - 120px);
  }

  .team-presence {
    max-height: 120px;
  }
}
