/* Customer service and after-sales share the same conversation workspace. */
#actionDialog.service-chat-dialog {
  width: min(1100px, calc(100vw - 32px)) !important;
  height: min(760px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid #e3e9f1;
  border-radius: 12px;
  background: #fff;
  color: #344054;
  box-shadow: 0 24px 90px #1e36552e;
  overflow: hidden;
  color-scheme: light;
}

#actionDialog.service-chat-dialog::backdrop {
  background: #18263d66;
  backdrop-filter: blur(3px);
}

.service-chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.service-chat-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 15px 24px;
  border-bottom: 1px solid #e9edf3;
  background: #fff;
}

.service-chat-heading,
.service-chat-header-actions,
.chat-profile-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.service-chat-heading > div,
.chat-profile-identity > div {
  min-width: 0;
}

.service-chat-avatar,
.service-chat-dialog .message-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #eaf4ff;
  color: #3588de;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.service-chat-heading h2 {
  margin: 0;
  overflow: hidden;
  color: #263447;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-chat-heading p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0 0;
  color: #8491a2;
  font-size: 11px;
  line-height: 1.3;
}

.service-chat-dialog .channel-tag {
  padding: 3px 7px;
  border-radius: 4px;
  background: #eef6ff;
  color: #3c91e7;
  font-size: 10px;
}

.service-chat-header-actions {
  flex-shrink: 0;
  gap: 10px;
}

.service-chat-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8895a6;
  cursor: pointer;
}

.service-chat-close:hover {
  background: #f1f5f9;
  color: #334155;
}

.service-chat-close svg {
  width: 20px;
  height: 20px;
}

.chat-details-toggle {
  display: none;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #dbe8f5;
  border-radius: 6px;
  background: #f5faff;
  color: #3285d8;
  font-size: 11px;
  cursor: pointer;
}

.service-chat-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  min-height: 0;
  overflow: hidden;
}

.service-chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f5f7fa;
}

.service-chat-dialog .service-messages {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 24px;
  height: auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 28px 24px;
  border: 0;
  border-radius: 0;
  background: #f5f7fa;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.service-chat-dialog .service-message {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  align-self: flex-start;
  gap: 10px;
  max-width: 88%;
  min-width: 0;
}

.service-chat-dialog .message-avatar {
  width: 34px;
  height: 34px;
  margin-top: 22px;
  border-radius: 10px;
  background: #e7edf6;
  color: #6b809f;
  font-size: 14px;
}

.service-chat-dialog .message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.service-chat-dialog .service-message small {
  display: block;
  margin: 0 0 7px;
  color: #8d99aa;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.service-chat-dialog .service-message p {
  margin: 0;
  padding: 12px 15px;
  border: 1px solid #edf0f4;
  border-radius: 2px 12px 12px;
  background: #fff;
  color: #39485d;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.service-chat-dialog .service-message.is-mine {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.service-chat-dialog .service-message.is-mine .message-content {
  align-items: flex-end;
}

.service-chat-dialog .service-message.is-mine .message-avatar {
  background: #409eff;
  color: #fff;
}

.service-chat-dialog .service-message.is-mine small {
  text-align: right;
}

.service-chat-dialog .service-message.is-mine p {
  border-color: #d8eaff;
  border-radius: 12px 2px 12px 12px;
  background: #e7f2ff;
  color: #264e7e;
}

.service-chat-dialog .service-messages > .empty-state {
  flex: 1;
  min-height: 120px;
}

.service-chat-dialog .message-compose {
  flex: 0 0 auto;
  margin: 0;
  padding: 16px 24px 17px;
  border-top: 1px solid #e6ebf2;
  background: #fff;
}

.service-chat-dialog .message-compose textarea {
  display: block;
  width: 100%;
  height: 84px;
  min-width: 0;
  min-height: 64px;
  max-height: 130px;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: #344054;
  font: inherit;
  font-size: 13px;
  line-height: 1.8;
  resize: none;
}

.service-chat-dialog .message-compose textarea::placeholder {
  color: #a6afbd;
}

.service-chat-dialog .message-compose:focus-within {
  border-top-color: #a9d2fc;
}

.service-chat-dialog .message-compose-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

.service-chat-dialog .message-hint {
  color: #98a3b3;
  font-size: 11px;
  line-height: 1.5;
}

.service-chat-dialog .primary-action {
  justify-content: center;
  min-width: 86px;
  min-height: 35px;
  padding: 0 16px;
  border-radius: 6px;
  background: #409eff;
  font-size: 12px;
  font-weight: 500;
}

.service-chat-dialog .primary-action:hover:not(:disabled) {
  background: #268bef;
}

.service-chat-dialog .primary-action svg {
  width: 15px;
  height: 15px;
}

.service-chat-dialog :is(button, summary):focus-visible {
  outline: 3px solid #a7d3ff;
  outline-offset: 3px;
}

.service-chat-dialog .message-error,
.service-chat-dialog .message-sync,
.service-chat-dialog .followup-feedback {
  min-height: 0;
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.service-chat-dialog .message-error {
  color: #c1544c;
}

.service-chat-dialog .message-sync {
  color: #8b99ab;
}

.service-chat-dialog .followup-feedback {
  color: #63866f;
}

.service-chat-dialog :is(.message-error, .message-sync, .followup-feedback):empty {
  display: none;
}

.service-chat-sidebar {
  min-width: 0;
  min-height: 0;
  padding: 0 22px 22px;
  border-left: 1px solid #e6ebf2;
  background: #fff;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.service-chat-dialog :is(.service-messages, .service-chat-sidebar) {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.chat-profile-card {
  padding: 24px 0 22px;
}

.service-chat-sidebar h3 {
  margin: 0;
  color: #35445a;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.chat-profile-identity {
  margin: 20px 0 18px;
}

.chat-profile-identity .service-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 21px;
}

.chat-profile-identity strong,
.chat-profile-identity > div > span {
  display: block;
  overflow-wrap: anywhere;
}

.chat-profile-identity strong {
  color: #344054;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.chat-profile-identity > div > span {
  margin-top: 5px;
  color: #99a2b0;
  font-size: 11px;
}

.chat-info-list {
  display: grid;
  gap: 12px;
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
}

.chat-info-list > div {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 12px;
}

.chat-info-list dt {
  color: #99a3b2;
}

.chat-info-list dd {
  min-width: 0;
  margin: 0;
  color: #55657b;
  text-align: right;
  overflow-wrap: anywhere;
}

.chat-order-card {
  padding: 22px 0;
  border-top: 1px solid #edf0f5;
}

.chat-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 19px;
}

.chat-order-status {
  padding: 4px 8px;
  border-radius: 5px;
  background: #eff6ff;
  color: #4092e7;
  font-size: 10px;
  line-height: 1.4;
}

.chat-order-game {
  display: block;
  color: #3b4d65;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.chat-order-id {
  display: block;
  margin: 5px 0 19px;
  color: #a0aab8;
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.chat-order-requirement {
  margin: 17px 0 0;
  padding: 11px 12px;
  border-radius: 6px;
  background: #f7f9fc;
  color: #7d8ba0;
  font-size: 11px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-order-history {
  margin-top: 16px;
}

.service-chat-dialog :is(.chat-order-history, .internal-followup) > summary {
  color: #7b8da4;
  font-size: 12px;
  line-height: 1.7;
  cursor: pointer;
}

.service-chat-dialog :is(.chat-order-history, .internal-followup) > summary::marker {
  color: #a2b2c5;
  font-size: 10px;
}

.service-chat-dialog .internal-followup {
  margin: 0;
  padding: 20px 0 0;
  border-top: 1px solid #edf0f5;
}

.service-chat-dialog .internal-followup > summary {
  color: #536880;
}

.service-chat-dialog .chat-note {
  padding: 11px 12px;
  margin-top: 12px;
  border-radius: 6px;
  background: #f7f9fc;
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.service-chat-dialog .chat-note p {
  margin: 0 0 5px;
  color: #69798e;
  white-space: pre-wrap;
}

.service-chat-dialog .chat-note small {
  display: block;
  color: #a3adbb;
  font-size: 10px;
}

.service-chat-dialog #internalNotes > .empty-state {
  padding: 18px 0 3px;
  font-size: 11px;
}

.service-chat-dialog .chat-followup-form {
  margin-top: 15px;
}

.service-chat-dialog .chat-followup-form .form-field {
  gap: 7px;
  margin: 13px 0;
  color: #8a98aa;
  font-size: 11px;
}

.service-chat-dialog .chat-followup-form :is(textarea, select) {
  width: 100%;
  padding: 9px 10px;
  border-color: #dfe7f0;
  background: #fff;
  color: #55657b;
  font-size: 12px;
  line-height: 1.6;
}

.service-chat-dialog .chat-followup-form textarea {
  min-height: 88px;
}

.service-chat-dialog .chat-followup-form :is(textarea, select):focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 3px #edf6ff;
}

.service-chat-dialog .chat-followup-form .primary-action {
  width: 100%;
  margin-top: 17px;
}

.service-chat-dialog .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .service-chat-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .service-chat-sidebar {
    padding-right: 18px;
    padding-left: 18px;
  }

  .service-chat-dialog .service-messages {
    padding: 22px 18px;
  }

  .service-chat-dialog .service-message {
    max-width: 94%;
  }
}

@media (max-width: 720px) {
  #actionDialog.service-chat-dialog {
    width: calc(100vw - 16px) !important;
    height: calc(100dvh - 24px);
    border-radius: 9px;
  }

  .service-chat-header {
    min-height: 72px;
    gap: 10px;
    padding: 12px 14px;
  }

  .service-chat-heading {
    gap: 9px;
  }

  .service-chat-heading h2 {
    font-size: 14px;
  }

  .service-chat-heading > .service-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 16px;
  }

  .service-chat-header-actions {
    gap: 4px;
  }

  .chat-details-toggle {
    display: inline-flex;
    align-items: center;
  }

  .chat-details-toggle[aria-expanded="true"] {
    border-color: #9dcbf7;
    background: #e8f3ff;
  }

  .service-chat-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .service-chat-sidebar {
    position: absolute;
    z-index: 1;
    inset: 0 0 0 auto;
    display: none;
    width: min(320px, 100%);
    padding-right: 20px;
    padding-left: 20px;
    box-shadow: -16px 0 40px #2d466b20;
  }

  .service-chat-shell.is-details-open .service-chat-sidebar {
    display: block;
  }

  .service-chat-dialog .service-messages {
    gap: 22px;
    padding: 20px 14px;
  }

  .service-chat-dialog .service-message {
    gap: 8px;
    max-width: 95%;
  }

  .service-chat-dialog .message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 13px;
  }

  .service-chat-dialog .service-message p {
    padding: 10px 12px;
    font-size: 12px;
  }

  .service-chat-dialog .service-message small {
    font-size: 10px;
  }

  .service-chat-dialog .message-compose {
    padding: 13px 14px;
  }

  .service-chat-dialog .message-compose textarea {
    height: 76px;
  }

  .service-chat-dialog .message-hint {
    font-size: 10px;
  }
}

@media (max-height: 500px) {
  .service-chat-header {
    min-height: 60px;
    padding-top: 9px;
    padding-bottom: 9px;
  }

  .service-chat-dialog .message-compose {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .service-chat-dialog .message-compose textarea {
    height: 48px;
    min-height: 48px;
  }
}
