@import url("./tokens.css");

.shell-main--chat {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.chat-app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0.75rem;
  flex: 1;
  min-height: calc(100vh - 7.5rem);
  max-height: calc(100vh - 7.5rem);
}

.chat-sidebar,
.chat-main {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-section {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.chat-sidebar-section:last-child {
  border-bottom: none;
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.chat-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.chat-sidebar-section h2 {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-sidebar-head h2 {
  margin-bottom: 0;
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-list-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.chat-list-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chat-list-item.is-active {
  background: var(--accent-muted);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--text);
}

.chat-list-item.is-general {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}

.chat-list-item.has-unread {
  color: var(--text);
  font-weight: 600;
}

.chat-list-item-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chat-list-item-main {
  flex: 1;
  min-width: 0;
}

.chat-list-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-item-preview {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-avatar {
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
}

.chat-unread-dot {
  flex: 0 0 auto;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.chat-main-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.chat-main-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.chat-main-meta {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-messages {
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
}

.chat-message {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
  max-width: 100%;
}

.chat-message.is-compact {
  margin-top: -0.15rem;
}

.chat-message.is-compact .chat-avatar,
.chat-message.is-compact .chat-message-head {
  visibility: hidden;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.chat-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}

.chat-message-content {
  min-width: 0;
}

.chat-message-head {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-bottom: 0.12rem;
  font-size: 0.72rem;
}

.chat-message-author {
  font-weight: 700;
  font-size: 0.8rem;
}

.chat-message-time {
  color: var(--muted);
  font-size: 0.68rem;
}

.chat-message-body {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 3px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.is-self .chat-message-body {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  align-items: end;
}

.chat-compose textarea {
  resize: vertical;
  min-height: 2.5rem;
  max-height: 8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-size: 0.88rem;
}

.chat-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.chat-group-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--text);
  padding: 0;
  max-width: 420px;
  width: calc(100vw - 2rem);
}

.chat-group-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.chat-group-dialog .dialog-form {
  padding: 1rem 1.1rem;
}

.chat-group-dialog h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.chat-group-dialog label,
.chat-group-members-label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chat-group-members-label {
  margin-top: 0.85rem;
}

.chat-group-dialog input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.chat-group-members {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.chat-group-member-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.chat-group-member-option input {
  accent-color: var(--accent);
}

@media (max-width: 768px) {
  .chat-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    max-height: none;
    min-height: calc(100vh - 8rem);
  }

  .chat-sidebar {
    max-height: 260px;
  }
}

/* --- Gruppen-Verwaltung --- */

.chat-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-header-action {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  line-height: 1;
}
.chat-header-action:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.chat-group-settings-members {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}
.chat-group-settings-members li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.chat-group-settings-members li:last-child {
  border-bottom: none;
}

.chat-kick-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.chat-kick-btn:hover {
  color: var(--err);
  background: rgba(239, 68, 68, 0.1);
}

.chat-group-invite-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

.chat-group-invite-select {
  flex: 1;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
}

/* --- Hand share chat card --- */

.chat-hand-share-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.75rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-width: 340px;
}

.chat-hand-share-label {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-hand-share-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.chat-hand-share-open {
  align-self: flex-start;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  text-decoration: none;
}
