/* ============================================================================
   Contigo Data Explorer — MS Teams Styles
   ============================================================================ */

/* --- Layout & Utilities --- */
.teams-view {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* --- Dashboard --- */
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.kpi-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.kpi-label {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Bar Chart */
.bar-chart-container {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 20px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  height: 200px;
  gap: 10px;
  margin-top: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}

.bar {
  flex: 1;
  background-color: var(--primary);
  border-radius: 4px 4px 0 0;
  min-width: 30px;
  position: relative;
  transition: opacity 0.2s;
  cursor: pointer;
}

.bar:hover {
  opacity: 0.8;
}

.bar-label {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%) rotate(-45deg);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.bar-tooltip {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tooltip);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.bar:hover .bar-tooltip {
  opacity: 1;
}

/* --- Team Cards --- */
.team-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.team-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.team-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.team-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

.team-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.team-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* --- Chat Layout (Teams Clone) --- */
.chat-layout {
  display: flex;
  height: calc(100vh - 100px); /* Adjust based on topbar height */
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-raised);
}

.chat-sidebar {
  width: 400px;
  min-width: 400px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
}

.chat-search-wrap {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.chat-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.chat-list-item:hover {
  background: var(--bg-hover);
}

.chat-list-item.active {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.chat-item-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}

.chat-item-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  background: var(--bg-raised);
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Message Bubbles --- */
.msg-group {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.msg-group.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.msg-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.msg-author {
  font-weight: 600;
  color: var(--text);
}

.msg-time {
  color: var(--text-muted);
}

.msg-bubble {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 0 8px 8px 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.msg-group.outgoing .msg-bubble {
  background: var(--primary-soft);
  border-radius: 8px 0 8px 8px;
  border-color: transparent;
}

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

.reaction-badge {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  max-width: 300px;
}

.attachment-icon {
  font-size: 20px;
}

.attachment-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.attachment-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--primary);
}

/* --- Team Detail View (Threaded) --- */
.team-channels {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.channel-tab {
  padding: 8px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.channel-tab:hover {
  background: var(--bg-hover);
}

.channel-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.thread-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.thread-root {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.thread-replies {
  margin-top: 16px;
  padding-left: 20px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Alert Summary Table --- */
.alert-summary-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.alert-summary-header {
  padding: 12px 16px;
  background: var(--bg-hover);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.alert-summary-date {
  font-weight: 600;
}

.alert-summary-count {
  background: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.alert-summary-samples {
  padding: 16px;
  display: none;
}

.alert-summary-item.open .alert-summary-samples {
  display: block;
}

.sample-msg {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.sample-msg:last-child {
  border-bottom: none;
}
