:root {
  --bg-color: #d1d7db;
  --green: #00a884;
  --green-secondary: #d9fdd3;
  --light-grey: #e9edef;
  --primary: #f0f2f5;
  --bg-color-secondary: #ffffff;
  --text-primary: #3b4a54;
  --text-primary-strong: #111b21;
  --text-secondary: #667781;
  --search-input-background: #f0f2f5;
  --border-color: #e9edef;
  --compose-bg-color: #ffffff;
  --input-placeholder-color: #667781;
  --dropdown-color: #ffffff;
}

body {
  overflow: hidden;
  background: linear-gradient(180deg, #d7dbd6 0 126px, #efeae2 126px 100%);
}

#app-shell {
  height: 100vh;
  background-color: #ffffff;
}

.dashboard-avatar {
  background: linear-gradient(135deg, #dfe7ea, #cfd8dc);
  object-fit: cover;
}

.icon,
.pin {
  filter: invert(38%) sepia(10%) saturate(543%) hue-rotate(157deg)
    brightness(91%) contrast(87%);
}

#sidebar {
  flex: 0 0 420px;
  max-width: 420px;
  min-width: 320px;
  background-color: #ffffff;
}

#sidebar-contents {
  min-height: 0;
}

.kpi-strip {
  justify-content: space-between;
  gap: 10px;
}

.kpi-card {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #ffffff, #f7faf8);
  border: 1px solid #dfe5e7;
  box-shadow: 0 1px 2px rgba(17, 27, 33, 0.04);
}

.kpi-card span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.kpi-value {
  color: var(--text-primary-strong);
  font-size: 20px;
  font-weight: 700;
}

#chats-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-tile.active {
  background-color: #f0f2f5;
}

button.chat-tile {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  font: inherit;
}

button.chat-tile:focus-visible {
  outline: 2px solid #00a884;
  outline-offset: -2px;
}

.chat-tile-avatar {
  height: 49px;
  width: 49px;
  border-radius: 50%;
  margin: 0 5px 0 13px;
}

.chat-tile-title {
  display: flex;
  column-gap: 10px;
  min-width: 0;
}

.chat-tile-title > :first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-tile-title > :last-child {
  flex: 0 0 auto;
}

.chat-tile-subtitle > :first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-tile-subtitle {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.chat-tile-details {
  min-width: 0;
}

.chat-status-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--green);
  color: var(--text-primary-strong);
  font-size: 11px;
  font-weight: 700;
}

.chat-status-badge.pending {
  background: #f0b429;
  color: #111b21;
}

.chat-status-badge.confirmed {
  background: var(--green);
}

.chat-status-badge.declined {
  background: #f15c6d;
}

.mobile-back-button {
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-primary);
  border-radius: 999px;
  height: 32px;
  padding: 0 12px;
  cursor: pointer;
}

#chat-window {
  background-color: #efeae2;
}

#chat-window-header {
  color: var(--text-primary-strong);
  padding: 12px 18px;
}

.mobile-back-button {
  display: none;
}

#active-chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#active-chat-info:empty {
  display: none;
}

#chat-window-contents {
  background:
    linear-gradient(rgba(239, 234, 226, 0.92), rgba(239, 234, 226, 0.94)),
    url("../images/chat-bg.png");
  background-size: 380px;
  padding: 12px 16px 20px;
}

.thread-empty,
.empty-state {
  color: var(--text-secondary);
  padding: 22px 14px;
}

.thread-empty {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.thread-stack {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.chat-message-group {
  margin-bottom: 10px;
}

.chat-message-group.outgoing {
  flex-direction: row-reverse;
}

.chat-message-group.outgoing .chat-messages {
  align-items: flex-end;
}

.chat-message-group.outgoing .chat-message {
  background-color: #d9fdd3;
}

.chat-message-group.system {
  justify-content: center;
}

.chat-message-group.system .chat-message-avatar {
  display: none;
}

.chat-message-group.system .chat-messages {
  align-items: center;
}

.chat-message-group.system .chat-message {
  background-color: #fff3c4;
  color: #54656f;
}

.chat-messages {
  flex-grow: 0;
  max-width: min(46%, 430px);
}

.chat-message-container {
  flex-grow: 0;
  max-width: 100%;
  align-self: flex-start;
}

.chat-message {
  display: inline-block;
  max-width: 100%;
  background-color: #ffffff;
  color: #111b21;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-message a {
  color: inherit;
}

.chat-message-time {
  color: rgba(102, 119, 129, 0.9);
}

.chat-message.chat-message-first {
  border-top-left-radius: 2px;
}

.chat-message-group.outgoing .chat-message.chat-message-first {
  border-top-right-radius: 2px;
  border-top-left-radius: var(--border-radius);
}

.chat-message-group.outgoing .chat-message-container {
  align-self: flex-end;
}

.chat-message-sender {
  color: #128c7e;
}

.chat-message-group.outgoing .chat-message-sender {
  color: #0b6d61;
}

.chat-message.system-note .chat-message-sender {
  color: #b26a00;
}

.message-page-anchor {
  display: block;
  height: 1px;
}

.datestamp {
  color: #54656f;
  background-color: #fff3c4;
}

#chat-window-footer {
  gap: 10px;
}

#compose-chat-box[readonly] {
  cursor: default;
  background-color: #ffffff;
}

.hidden-file-input {
  display: none;
}

@media (max-width: 980px) {
  #app-shell {
    position: relative;
  }

  #sidebar,
  #chat-window {
    max-width: none;
    width: 100%;
  }

  body.mobile-thread-open #sidebar {
    display: none;
  }

  body:not(.mobile-thread-open) #chat-window {
    display: none;
  }

  .mobile-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .chat-messages {
    max-width: 76%;
  }
}

@media (max-width: 640px) {
  #sidebar {
    min-width: 0;
  }

  #sidebar-header,
  #chat-window-header {
    padding: 10px 12px;
  }

  #chat-window-contents {
    padding: 10px 10px 18px;
  }

  .chat-messages {
    max-width: 86%;
  }
}
