/* =========================
   PAGE: MESSAGES LAYOUT
========================= */

.app-layout {
  width: 100%;
  max-width: 1600px;

  margin: 0 auto;

  padding-top: 120px;
  padding-left: 40px;
  padding-right: 40px;

  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 30px;
}

.messages-main {
  min-height: calc(100vh - 120px);

  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* =========================
   HEADER
========================= */

.messages-header {
  padding: 28px;

  background: #ffffff;

  border: 1px solid #ececec;
  border-radius: 24px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  width: fit-content;

  margin-bottom: 16px;

  color: #676F54;

  font-weight: 600;
  text-decoration: none;

  transition: 0.3s ease;
}

.back-btn:hover {
  color: #79B4A9;
  transform: translateX(-3px);
}

.messages-header h1 {
  margin-bottom: 8px;

  color: #2b2b2b;

  font-family: "Belleza", sans-serif;
  font-size: 46px;
  font-weight: 400;
}

.messages-header p {
  color: #676F54;
  font-size: 16px;
}

/* =========================
   MESSAGES GRID
========================= */

.messages-layout {
  height: calc(100vh - 260px);
  min-height: 560px;

  display: grid;
  grid-template-columns: 320px 1fr;

  overflow: hidden;

  background: #ffffff;

  border: 1px solid #ececec;
  border-radius: 24px;
}

/* =========================
   CONVERSATIONS PANEL
========================= */

.conversations-panel {
  height: 100%;
  overflow: hidden;

  display: flex;
  flex-direction: column;

  background: #ffffff;

  border-right: 1px solid #ececec;
}

.panel-header {
  padding: 22px;

  border-bottom: 1px solid #ececec;
}

.panel-header h2 {
  color: #2b2b2b;
  font-size: 22px;
}

.conversation-search {
  padding: 16px;

  border-bottom: 1px solid #ececec;
}

.conversation-search input {
  width: 100%;
  height: 42px;

  padding: 0 16px;

  border: 1px solid #dedede;
  border-radius: 999px;

  font-family: "Inter", sans-serif;

  outline: none;
}

.conversation-search input:focus {
  border-color: #79B4A9;
  box-shadow: 0 0 0 4px rgba(121, 180, 169, 0.12);
}

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

.conversation-item {
  position: relative;

  display: flex;
  align-items: center;
  gap: 12px;

  padding: 16px;

  border-bottom: 1px solid #f0f0f0;

  cursor: pointer;
  transition: 0.2s ease;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef7eb;
}

.conversation-avatar {
  width: 46px;
  height: 46px;

  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  border: 2px solid #d4af37;

  background: #79B4A9;
  color: #ffffff;

  font-weight: 700;
}

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

.conversation-info strong {
  display: block;

  margin-bottom: 4px;

  color: #2b2b2b;

  font-size: 15px;
}

.conversation-info span {
  display: block;

  overflow: hidden;

  color: #777777;

  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.empty-conversations {
  padding: 24px;

  color: #777777;

  font-size: 14px;
}

.conversation-unread-badge {
  position: absolute;
  top: 18px;
  right: 18px;

  min-width: 22px;
  height: 22px;

  padding: 0 7px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;

  background: #c0392b;
  color: #ffffff;

  font-size: 12px;
  font-weight: 700;
}

/* =========================
   CHAT PANEL
========================= */

.chat-panel {
  height: 100%;
  min-width: 0;
  overflow: hidden;

  display: flex;
  flex-direction: column;

  background: #fdfdfb;
}

.chat-header {
  height: 78px;
  flex-shrink: 0;

  padding: 16px 22px;

  display: flex;
  align-items: center;
  gap: 12px;

  background: #ffffff;

  border-bottom: 1px solid #ececec;
}

.chat-user-avatar {
  width: 46px;
  height: 46px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  border: 2px solid #d4af37;

  background: #79B4A9;
  color: #ffffff;

  font-weight: 700;
}

.chat-header h2 {
  color: #2b2b2b;
  font-size: 18px;
}

.chat-header span {
  color: #777777;
  font-size: 13px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;

  padding: 24px;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-chat {
  max-width: 360px;

  margin: auto;

  color: #777777;

  text-align: center;
}

.empty-chat strong {
  display: block;

  margin-bottom: 8px;

  color: #2b2b2b;
}

/* =========================
   MESSAGE BUBBLES
========================= */

.message-bubble {
  max-width: 65%;

  padding: 12px 16px;

  border-radius: 18px;

  font-size: 15px;
  line-height: 1.5;

  word-wrap: break-word;
}

.message-bubble.sent {
  align-self: flex-end;

  background: #79B4A9;
  color: #ffffff;

  border-bottom-right-radius: 6px;
}

.message-bubble.received {
  align-self: flex-start;

  background: #ffffff;
  color: #2b2b2b;

  border: 1px solid #ececec;

  border-bottom-left-radius: 6px;
}

.message-time {
  display: block;

  margin-top: 6px;

  font-size: 11px;

  opacity: 0.7;
}

/* =========================
   INPUT AREA
========================= */

.chat-input-area {
  flex-shrink: 0;

  padding: 16px 24px;

  display: flex;
  align-items: center;
  gap: 12px;

  background: #ffffff;

  border-top: 1px solid #ececec;
}

.chat-input-area textarea {
  flex: 1;

  min-height: 48px;
  max-height: 120px;

  padding: 13px 16px;

  resize: none;

  border: 1px solid #dedede;
  border-radius: 18px;

  font-family: "Inter", sans-serif;
  font-size: 15px;

  outline: none;
}

.chat-input-area textarea:focus {
  border-color: #79B4A9;
  box-shadow: 0 0 0 4px rgba(121, 180, 169, 0.12);
}

.chat-input-area textarea:disabled {
  background: #f1f1f1;
  cursor: not-allowed;
}

.chat-input-area button {
  flex-shrink: 0;

  padding: 13px 24px;

  border: none;
  border-radius: 999px;

  background: #79B4A9;
  color: #ffffff;

  font-weight: 700;

  cursor: pointer;
  transition: 0.3s ease;
}

.chat-input-area button:hover:not(:disabled) {
  background: #676F54;
  transform: translateY(-2px);
}

.chat-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-left {
    display: none;
  }
}

@media (max-width: 800px) {
  .app-layout {
    padding-top: 150px;
    padding-left: 15px;
    padding-right: 15px;
  }

  .messages-layout {
    height: auto;
    min-height: 700px;

    grid-template-columns: 1fr;
  }

  .conversations-panel {
    height: 280px;

    border-right: none;
    border-bottom: 1px solid #ececec;
  }

  .chat-panel {
    min-height: 500px;
  }

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

@media (max-width: 480px) {
  .messages-header h1 {
    font-size: 36px;
  }

  .messages-header,
  .panel-header,
  .chat-messages {
    padding: 18px;
  }

  .chat-input-area {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-input-area button {
    width: 100%;
  }
}