* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6fb;
  color: #061a44;
}
[hidden] {
  display: none !important;
}
.messages-page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.messages-page .dash-sidebar {
  min-height: 100vh;
}

.messages-main {
  min-width: 0;
  padding: 34px;
}

.messages-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.messages-page-header h1 {
  margin: 0;
  color: #061a44;
  font-size: 36px;
  letter-spacing: -0.04em;
}

.messages-page-header > div > p:not(.page-eyebrow) {
  margin: 8px 0 0;
  color: #637089;
  line-height: 1.5;
}

.page-eyebrow,
.section-label {
  margin: 0 0 7px;
  color: #16953c;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.connections-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid #dce3ef;
  border-radius: 10px;
  background: #ffffff;
  color: #061a44;
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}

.messages-sidebar-card {
  margin: auto 16px 20px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(
    135deg,
    #2449a8,
    #673dcc
  );
  color: #ffffff;
}

.messages-sidebar-card h4 {
  margin: 0 0 8px;
}

.messages-sidebar-card p {
  margin: 0 0 14px;
  font-size: 11px;
  line-height: 1.55;
}

.messages-sidebar-card a {
  display: block;
  padding-top: 12px;
  border-top: 4px solid #35c759;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.message-status {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid #cbdcfb;
  border-radius: 10px;
  background: #eef4ff;
  color: #174b9b;
  font-size: 13px;
  font-weight: 700;
}

.message-status.success {
  border-color: #bee7c9;
  background: #effbf2;
  color: #167a32;
}

.message-status.error {
  border-color: #efc4ca;
  background: #fff2f4;
  color: #b3263c;
}

.messaging-layout {
  min-height: 680px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #e0e6f0;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(6, 26, 68, 0.06);
}

.conversation-sidebar {
  min-width: 0;
  border-right: 1px solid #e4e9f2;
  background: #fbfcfe;
}

.conversation-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 24px 22px 16px;
}

.conversation-sidebar-header h2 {
  margin: 0;
  font-size: 22px;
}

.conversation-sidebar-header > span {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eaf8ed;
  color: #16843a;
  font-size: 12px;
  font-weight: 900;
}

.conversation-search {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 18px 18px;
  padding: 0 13px;
  border: 1px solid #dde4ef;
  border-radius: 11px;
  background: #ffffff;
}

.conversation-search input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #061a44;
  font-family: inherit;
}

.conversation-list {
  max-height: 570px;
  overflow-y: auto;
  padding: 0 12px 18px;
}

.conversation-loading,
.no-conversations {
  padding: 45px 20px;
  color: #7b879b;
  text-align: center;
  line-height: 1.6;
}

.no-conversations h3 {
  margin: 0 0 8px;
  color: #061a44;
}

.no-conversations p {
  margin: 0 0 18px;
  font-size: 12px;
}

.no-conversations a {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: 9px;
  background: #35c759;
  color: #061a44;
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
}

.conversation-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  text-align: left;
}

.conversation-item:hover {
  background: #f0f4fa;
}

.conversation-item.active {
  border-color: #bfe8ca;
  background: #eaf8ed;
}

.conversation-avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    #35c759,
    #2f73e8
  );
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

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

.conversation-info strong,
.conversation-info span {
  display: block;
}

.conversation-info strong {
  overflow: hidden;
  color: #061a44;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-info span {
  margin-top: 5px;
  overflow: hidden;
  color: #77839a;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  min-width: 0;
  min-height: 680px;
  background: #ffffff;
}

.empty-conversation {
  min-height: 680px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px;
  text-align: center;
}

.empty-conversation-icon {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 19px;
  border-radius: 50%;
  background: #eaf8ed;
  font-size: 30px;
}

.empty-conversation h2 {
  margin: 0;
  font-size: 26px;
}

.empty-conversation p {
  max-width: 470px;
  margin: 12px 0 22px;
  color: #66738a;
  line-height: 1.6;
}

.empty-conversation a {
  padding: 12px 17px;
  border-radius: 9px;
  background: #35c759;
  color: #061a44;
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
}

.active-conversation {
  min-height: 680px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  border-bottom: 1px solid #e4e9f2;
}

.chat-person {
  display: flex;
  align-items: center;
  gap: 13px;
}

.chat-avatar {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    #35c759,
    #2f73e8
  );
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
}

.chat-person h2 {
  margin: 0;
  font-size: 18px;
}

.chat-person p {
  margin: 5px 0 0;
  color: #78849a;
  font-size: 11px;
}

.refresh-messages-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #dce3ef;
  border-radius: 9px;
  background: #ffffff;
  cursor: pointer;
  color: #061a44;
  font-family: inherit;
  font-size: 10px;
  font-weight: 900;
}

.messages-container {
  height: 480px;
  overflow-y: auto;
  padding: 24px;
  background: #f7f9fc;
}

.messages-loading,
.no-messages {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7c8799;
  text-align: center;
}

.message-row {
  display: flex;
  margin-bottom: 12px;
}

.message-row.sent {
  justify-content: flex-end;
}

.message-row.received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: min(72%, 570px);
  padding: 12px 15px 9px;
  border-radius: 16px;
  line-height: 1.5;
}

.message-row.sent .message-bubble {
  border-bottom-right-radius: 5px;
  background: #35c759;
  color: #061a44;
}

.message-row.received .message-bubble {
  border: 1px solid #e0e6ef;
  border-bottom-left-radius: 5px;
  background: #ffffff;
  color: #061a44;
}

.message-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-time {
  display: block;
  margin-top: 6px;
  font-size: 9px;
  opacity: 0.66;
  text-align: right;
}

.message-form {
  padding: 17px 20px;
  border-top: 1px solid #e4e9f2;
  background: #ffffff;
}

.message-form textarea {
  width: 100%;
  min-height: 52px;
  max-height: 130px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #dce3ef;
  border-radius: 12px;
  outline: none;
  color: #061a44;
  font-family: inherit;
  line-height: 1.5;
}

.message-form textarea:focus {
  border-color: #35c759;
  box-shadow: 0 0 0 3px rgba(53, 199, 89, 0.12);
}

.message-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
}

.message-form-footer > span {
  color: #8a95a8;
  font-size: 10px;
}

.message-form button {
  min-height: 41px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  background: #35c759;
  cursor: pointer;
  color: #061a44;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
}

.message-form button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .messaging-layout {
    grid-template-columns: 270px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .messages-page {
    display: block;
  }

  .messages-main {
    padding: 24px 18px;
  }

  .messages-page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .messaging-layout {
    grid-template-columns: 1fr;
  }

  .conversation-sidebar {
    border-right: 0;
    border-bottom: 1px solid #e4e9f2;
  }

  .conversation-list {
    max-height: 270px;
  }
}

@media (max-width: 560px) {
  .messages-main {
    padding: 18px 10px;
  }

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

  .message-bubble {
    max-width: 88%;
  }
}