@import url("./portal-header-auth.css");

:root {
  --messages-page-max: 1580px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(118, 176, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #eff4fd 0%, #f7faff 100%);
  color: #1f2f4a;
}

.messages-main .container,
.portal-header .container {
  max-width: var(--messages-page-max);
}

.messages-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  padding: 18px 0 22px;
}

.messages-main .container {
  width: 100%;
  height: auto;
  min-height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.messages-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  width: min(100%, 1460px);
  height: calc(100vh - 116px);
  min-height: 860px;
  max-height: 940px;
  margin-inline: auto;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(48, 78, 120, 0.1);
  box-shadow: 0 20px 48px rgba(31, 54, 90, 0.14);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.messages-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(34, 40, 53, 0.96)),
    linear-gradient(180deg, #151b25, #2b313d);
  color: #f7fbff;
}

.messages-sidebar-top {
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.messages-self-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.messages-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #eef4ff, #d6e2fb);
  color: #36527c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  border: 3px solid rgba(255, 255, 255, 0.18);
}

.messages-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.messages-avatar.is-large {
  width: 62px;
  height: 62px;
  font-size: 24px;
}

.messages-self-copy,
.messages-panel-user-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.messages-self-name,
.messages-panel-user-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
}

.messages-self-email,
.messages-panel-user-email {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.74);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-panel-user-email {
  color: #7890b5;
}

.messages-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 0 12px;
  min-height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.messages-search-icon {
  color: rgba(255, 255, 255, 0.58);
  font-size: 18px;
}

.messages-search input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
}

.messages-search input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.messages-conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 0;
}

.messages-conversation-item {
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.messages-conversation-item:hover,
.messages-conversation-item.is-active {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: #ffb347;
}

.messages-conversation-copy {
  min-width: 0;
}

.messages-conversation-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.messages-conversation-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-conversation-time {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.46);
  flex: 0 0 auto;
}

.messages-conversation-preview {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.62);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.messages-conversation-empty {
  padding: 28px 20px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 14px;
  line-height: 1.6;
}

.messages-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
}

.messages-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(43, 68, 110, 0.08);
}

.messages-panel-user {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.messages-panel-sub {
  margin-top: 4px;
  font-size: 13px;
  color: #8ea3c2;
}

.messages-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 28px 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(247, 250, 255, 0.94));
}

.messages-thread-notice {
  max-width: 620px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 12px;
  text-align: center;
  font-size: 13px;
  color: #7689a9;
  background: #eef3fb;
}

.messages-thread-empty {
  max-width: 560px;
  margin: 80px auto 0;
  text-align: center;
  color: #6e83a5;
}

.messages-thread-empty h2 {
  margin: 0 0 10px;
  font-size: 24px;
  color: #263a59;
}

.messages-thread-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.messages-row {
  display: flex;
}

.messages-row.outgoing {
  justify-content: flex-end;
}

.messages-bubble {
  max-width: min(78%, 640px);
  padding: 13px 15px 12px;
  border-radius: 18px;
  box-shadow: 0 10px 20px rgba(31, 51, 89, 0.08);
}

.messages-row.incoming .messages-bubble {
  background: #fff;
  border-top-left-radius: 8px;
  color: #213551;
}

.messages-row.outgoing .messages-bubble {
  background: linear-gradient(135deg, #3f7ef7, #2b66d6);
  border-top-right-radius: 8px;
  color: #fff;
}

.messages-bubble-author {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.76;
  margin-bottom: 6px;
}

.messages-bubble-text {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.messages-bubble-attachments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.messages-bubble-attachment {
  display: block;
  width: min(100%, 420px);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  background: rgba(239, 244, 253, 0.96);
  border: 1px solid rgba(86, 121, 177, 0.12);
}

.messages-row.outgoing .messages-bubble-attachment {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.messages-bubble-attachment.messages-bubble-video-trigger {
  position: relative;
  padding: 0;
  cursor: pointer;
}

.messages-bubble-attachment img,
.messages-bubble-attachment video {
  width: 100%;
  display: block;
  max-height: 240px;
  object-fit: cover;
  background: rgba(15, 23, 42, 0.18);
}

.messages-bubble-attachment video {
  object-fit: contain;
  background: rgba(15, 23, 42, 0.9);
}

.messages-bubble-video-preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1.55 / 1;
  min-height: 186px;
  background:
    radial-gradient(circle at top left, rgba(103, 145, 224, 0.28), transparent 38%),
    linear-gradient(135deg, #0f172a, #1e293b 60%, #1f467d);
}

.messages-row.outgoing .messages-bubble-video-preview {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 38%),
    linear-gradient(135deg, rgba(18, 34, 64, 0.94), rgba(31, 70, 125, 0.98));
}

.messages-bubble-video-play {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.22);
  position: relative;
}

.messages-bubble-video-play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-38%, -50%);
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: 22px solid #2b66d6;
}

.messages-bubble-video-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.86);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-bubble-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  color: inherit;
}

.messages-bubble-link-label {
  font-size: 14px;
  font-weight: 700;
}

.messages-bubble-link-url {
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.76;
  word-break: break-all;
}

.messages-bubble-time {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.66;
  text-align: right;
}

.messages-compose {
  padding: 16px 22px 18px;
  border-top: 1px solid rgba(43, 68, 110, 0.08);
  background: #fff;
}

.messages-compose-toolbar {
  position: relative;
  margin-bottom: 10px;
}

.messages-compose-tools {
  display: flex;
  gap: 18px;
  align-items: center;
}

.messages-tool-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: #5b6270;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.messages-tool-btn:hover {
  transform: translateY(-1px);
  background: rgba(235, 241, 251, 0.9);
  color: #314767;
}

.messages-tool-btn.is-open {
  background: rgba(223, 233, 250, 0.96);
  color: #2f4f83;
  box-shadow: inset 0 0 0 1px rgba(129, 156, 202, 0.24);
}

.messages-tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.messages-tool-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages-emoji-picker {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  display: block;
  width: min(100vw - 64px, 360px);
  padding: 0;
  margin-bottom: 0;
  border-radius: 18px;
  border: 1px solid rgba(198, 212, 236, 0.9);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 36px rgba(31, 51, 89, 0.16);
  overflow: visible;
  z-index: 20;
}

.messages-emoji-picker::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.98);
  border-right: 1px solid rgba(198, 212, 236, 0.9);
  border-bottom: 1px solid rgba(198, 212, 236, 0.9);
  transform: rotate(45deg);
}

.messages-emoji-picker[hidden] {
  display: none;
}

.messages-emoji-panel {
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.98);
}

.messages-emoji-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(208, 220, 240, 0.8);
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.96), rgba(255, 255, 255, 0.96));
}

.messages-emoji-title {
  font-size: 13px;
  font-weight: 800;
  color: #324766;
}

.messages-emoji-body {
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px 10px;
  background: #fff;
}

.messages-emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
}

.messages-emoji-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: none;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.messages-emoji-btn:hover {
  background: #f3f7ff;
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(74, 110, 171, 0.12);
}

.messages-emoji-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  padding: 8px 8px 8px;
  border-top: 1px solid rgba(208, 220, 240, 0.85);
  background: linear-gradient(180deg, rgba(251, 252, 255, 0.98), rgba(245, 249, 255, 0.98));
}

.messages-emoji-tab {
  min-height: 36px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #687d9e;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.messages-emoji-tab:hover {
  background: rgba(231, 239, 252, 0.88);
  transform: translateY(-1px);
}

.messages-emoji-tab.is-active {
  background: rgba(220, 232, 252, 0.98);
  color: #2a4f8f;
}

.messages-emoji-tab-icon {
  font-size: 18px;
  line-height: 1;
}

.messages-compose-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.messages-compose-attachment {
  position: relative;
  width: 118px;
  border-radius: 16px;
  overflow: hidden;
  background: #f7faff;
  border: 1px solid #dbe4f3;
  box-shadow: 0 10px 24px rgba(31, 51, 89, 0.08);
}

.messages-compose-attachment.is-link {
  width: min(100%, 260px);
  padding: 12px 14px 14px;
}

.messages-compose-attachment img,
.messages-compose-attachment video {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
  background: rgba(15, 23, 42, 0.84);
}

.messages-compose-attachment video {
  object-fit: contain;
}

.messages-compose-attachment-copy {
  padding: 10px 12px 12px;
}

.messages-compose-attachment-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: #28405f;
  word-break: break-word;
}

.messages-compose-attachment-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #7488a8;
  word-break: break-all;
}

.messages-compose-attachment-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.messages-compose-box {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.messages-compose textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 52px;
  max-height: 180px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #dbe4f3;
  background: #f7faff;
  font: inherit;
  color: #223654;
  outline: none;
}

.messages-compose textarea:focus {
  border-color: #6ea5ff;
  box-shadow: 0 0 0 4px rgba(88, 142, 255, 0.12);
}

#messagesSendBtn {
  flex: 0 0 auto;
  min-width: 120px;
  min-height: 52px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #1f467d, #3768a6);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(31, 70, 125, 0.18);
}

#messagesSendBtn:hover {
  transform: translateY(-1px);
}

#messagesSendBtn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

.messages-compose-status {
  min-height: 20px;
  margin-top: 10px;
  font-size: 13px;
  color: #6f83a5;
}

.messages-compose-status.is-error {
  color: #d14343;
}

.messages-compose-status.is-success {
  color: #2f8b57;
}

.messages-video-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
}

.messages-video-modal[hidden] {
  display: none;
}

.messages-video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 23, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.messages-video-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(92vw, 1080px);
  max-height: 88vh;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(8, 13, 23, 0.96);
  box-shadow: 0 28px 54px rgba(5, 10, 20, 0.34);
}

.messages-video-modal-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(78vh, 720px);
  padding: 36px 28px 28px;
  background: #050913;
}

.messages-video-modal-stage video {
  width: 100%;
  max-height: calc(88vh - 64px);
  border-radius: 18px;
  background: #000;
}

.messages-video-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.messages-video-modal-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

@media (max-width: 1100px) {
  .messages-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .messages-main {
    flex: 0 0 auto;
    display: block;
    min-height: auto;
    padding: 16px 0 24px;
  }

  .messages-main .container {
    width: auto;
    height: auto;
    padding: 0 16px;
    display: block;
  }

  .messages-shell {
    grid-template-columns: 1fr;
    width: 100%;
    height: auto;
    min-height: auto;
  }

  .messages-sidebar {
    min-height: 280px;
    overflow: hidden;
  }

  .messages-panel {
    min-height: 280px;
    overflow: hidden;
  }

  .messages-thread {
    min-height: 320px;
  }

  .messages-emoji-picker {
    width: min(100%, 420px);
  }

  .messages-emoji-body {
    max-height: 220px;
    padding: 12px;
  }

  .messages-emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
  }

  .messages-emoji-btn {
    font-size: 22px;
  }

  .messages-emoji-tabs {
    padding: 8px 8px 10px;
  }

  .messages-compose-tools {
    gap: 12px;
  }
}
