:root {
  --bg: #0b141a;
  --sidebar: #111b21;
  --sidebar-2: #202c33;
  --panel: #111b21;
  --border: #2a3942;
  --text: #e9edef;
  --muted: #8696a0;
  --green: #00a884;
  --green-dark: #005c4b;
  --danger: #d9534f;
  --input: #2a3942;
  --message-other: #202c33;
  --message-mine: #005c4b;
  --modal-bg: rgba(11, 20, 26, 0.72);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

input {
  width: 100%;
  border: none;
  outline: none;
  background: var(--input);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
}

input::placeholder {
  color: #8696a0;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* LOGIN */

.app-shell {
  min-height: 100vh;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.brand {
  text-align: center;
  margin-bottom: 22px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--green);
  color: #06251f;
  display: grid;
  place-items: center;
  font-weight: bold;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
}

.auth-grid {
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.auth-card {
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  display: grid;
  gap: 15px;
}

.auth-card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.auth-card p {
  margin: 0;
  font-size: 14px;
}

/* BOTÕES */

.primary-button,
.secondary-button,
.sidebar-actions button,
.message-form button {
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: #06251f;
  padding: 12px 14px;
  font-weight: 600;
}

.secondary-button {
  background: #2a3942;
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.sidebar-actions button:hover,
.message-form button:hover {
  filter: brightness(1.08);
}

.ghost-button,
.icon-button {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
}

.ghost-button:hover,
.icon-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.danger {
  color: #ffb4b4;
}

/* LAYOUT DO CHAT */

.chat-page {
  height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr 300px;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  background: var(--sidebar-2);
  min-height: 64px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
}

.sidebar-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.chat-list {
  overflow-y: auto;
  min-height: 0;
}

.chat-item {
  width: 100%;
  min-height: 72px;
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(42, 57, 66, 0.65);
}

.chat-item:hover,
.chat-item.active {
  background: #202c33;
}

.chat-avatar,
.mini-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #6b7c85;
  color: #111b21;
  display: grid;
  place-items: center;
  font-weight: bold;
  flex: 0 0 auto;
}

.mini-avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.chat-item-content {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.chat-item-content strong {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-content span {
  color: var(--muted);
  font-size: 13px;
}

/* ÁREA PRINCIPAL */

.chat-main {
  background: #0b141a;
  display: grid;
  grid-template-rows: 64px 1fr auto auto;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  background: var(--sidebar-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.chat-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 20px 9%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: #0b141a;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 500;
}

.empty-state p {
  margin: 0;
}

.empty-chat,
.loading,
.empty-small {
  color: var(--muted);
  text-align: center;
  padding: 18px;
  font-size: 14px;
}

.message {
  display: flex;
  width: 100%;
}

.message.mine {
  justify-content: flex-end;
}

.bubble {
  max-width: min(70%, 680px);
  background: var(--message-other);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--text);
  position: relative;
}

.message.mine .bubble {
  background: var(--message-mine);
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.35;
}

.message-time {
  display: block;
  margin-top: 4px;
  color: rgba(233, 237, 239, 0.65);
  font-size: 11px;
  text-align: right;
}

.message.system {
  align-self: center;
  width: auto;
  max-width: 85%;
  background: #182229;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

.message.deleted .bubble {
  opacity: 0.7;
  font-style: italic;
}

.typing-text {
  min-height: 20px;
  padding: 0 9%;
  color: var(--muted);
  font-size: 13px;
}

.message-form {
  background: var(--sidebar-2);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.message-form input {
  border-radius: 8px;
  background: #2a3942;
}

.message-form button {
  padding-inline: 20px;
}

/* PAINEL DE INFO */

.info-panel {
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  min-height: 0;
  overflow-y: auto;
}

.panel-header {
  min-height: 64px;
  padding: 12px 14px;
  background: var(--sidebar-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}

.info-content {
  padding: 16px;
}

.info-content h4 {
  margin: 16px 0 8px;
  font-weight: 500;
}

.info-content p {
  font-size: 14px;
}

.member-list {
  display: grid;
}

.member-item,
.user-row {
  display: flex;
  align-items: center;
  gap: 11px;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 0;
  text-align: left;
  border-bottom: 1px solid rgba(42, 57, 66, 0.55);
}

.member-item strong,
.user-row strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
}

.member-item span,
.user-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* MODAL */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--modal-bg);
  padding: 16px;
}

.modal-content {
  width: min(460px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--sidebar);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.modal-content.large {
  width: min(620px, 100%);
}

.modal-content > label,
.modal-content > p,
.modal-content > input,
.modal-content > button,
.modal-content > .users-list {
  margin: 14px;
}

.users-list {
  display: grid;
  max-height: 370px;
  overflow-y: auto;
}

.user-row {
  width: 100%;
  cursor: pointer;
}

.user-row:hover {
  background: #202c33;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  padding: 10px 0;
  border-bottom: 1px solid rgba(42, 57, 66, 0.55);
}

.check-row input {
  width: auto;
}

.check-row span {
  font-size: 14px;
}

/* TOAST */

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100% - 36px));
}

.toast {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  color: white;
  background: #202c33;
  border-left: 4px solid var(--green);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
}

.toast.success {
  border-left-color: var(--green);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.hide {
  opacity: 0;
  transform: translateY(4px);
  transition: 0.2s;
}

/* CELULAR */

@media (max-width: 1100px) {
  .chat-page {
    grid-template-columns: 320px 1fr;
  }

  .info-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 90vw);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }

  .info-panel.open {
    transform: translateX(0);
  }
}

@media (max-width: 760px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .chat-page {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: 300px 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 300px;
  }

  .chat-main {
    min-height: calc(100vh - 300px);
  }

  .messages {
    padding: 14px;
  }

  .typing-text {
    padding: 0 14px;
  }

  .bubble {
    max-width: 86%;
  }

  .chat-header {
    align-items: flex-start;
  }

  .header-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .auth-page {
    padding: 16px;
  }

  .auth-card {
    padding: 18px;
  }

  .brand h1 {
    font-size: 28px;
  }

  .message-form {
    grid-template-columns: 1fr;
  }

  .message-form button {
    width: 100%;
  }
}
