:root {
  color-scheme: light;
  --bg: #eeeae4;
  --surface: #f8f6f2;
  --surface-2: #ffffff;
  --text: #15171b;
  --muted: #6d7688;
  --line: rgba(21, 23, 27, .09);
  --indigo: #454f78;
  --indigo-soft: rgba(69, 79, 120, .10);
  --clay: #9b5e50;
  --green: #3d8b64;
  --shadow: 0 18px 50px rgba(21, 23, 27, .08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #171a20;
  --surface-2: #1d2027;
  --text: #f2eee8;
  --muted: #969eae;
  --line: rgba(255, 255, 255, .08);
  --indigo: #8995c3;
  --indigo-soft: rgba(137, 149, 195, .12);
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    "IBM Plex Sans Arabic",
    "Segoe UI",
    Arial,
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at 20% 20%,
      rgba(69,79,120,.14),
      transparent 32%
    ),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--text);
  color: var(--surface-2);
  font-weight: 800;
  font-size: 23px;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 18px;
}

.login-copy {
  margin: 28px 0;
}

.login-copy span {
  color: var(--indigo);
  font-size: 13px;
  font-weight: 700;
}

.login-copy h1 {
  margin: 8px 0;
  font-size: 34px;
  letter-spacing: -1px;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: .2s ease;
}

input {
  height: 49px;
  padding: 0 15px;
  border-radius: 13px;
}

textarea {
  min-height: 48px;
  max-height: 150px;
  resize: none;
  padding: 13px 15px;
  border-radius: 15px;
}

input:focus,
textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

.primary-btn,
.send-btn {
  border: 0;
  background: var(--indigo);
  color: white;
  font-weight: 700;
}

.primary-btn {
  width: 100%;
  height: 50px;
  margin-top: 22px;
  border-radius: 14px;
}

.form-error {
  min-height: 18px;
  color: #c24f4f;
  font-size: 13px;
}

.app {
  height: 100vh;
  overflow: hidden;
  background: var(--surface);
}

.topbar {
  height: 68px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand > div:last-child {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  color: var(--muted);
  font-size: 11px;
}

.connected {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(61, 139, 100, .10);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.connected i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.icon-btn,
.text-btn,
.mobile-back {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}

.icon-btn:hover {
  background: var(--indigo-soft);
  color: var(--indigo);
}

.text-btn {
  font-size: 12px;
}

.workspace {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 270px;
}

.conversation-panel,
.details-panel {
  background: var(--surface-2);
  overflow: hidden;
}

.conversation-panel {
  border-left: 1px solid var(--line);
}

.details-panel {
  border-right: 1px solid var(--line);
  padding: 26px 22px;
}

.panel-heading {
  height: 75px;
  padding: 18px 20px 10px;
  display: flex;
  align-items: center;
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.search-box {
  margin: 0 15px 14px;
  height: 43px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.search-box span {
  color: var(--muted);
}

.search-box input {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.conversation-list {
  height: calc(100% - 132px);
  overflow-y: auto;
  padding: 0 8px 16px;
}

.conversation {
  width: 100%;
  padding: 14px 12px;
  display: grid;
  grid-template-columns: 43px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--text);
  text-align: right;
}

.conversation:hover {
  background: var(--surface);
}

.conversation.active {
  background: var(--indigo-soft);
}

.avatar,
.details-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-weight: 800;
}

.avatar {
  width: 43px;
  height: 43px;
  font-size: 11px;
}

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

.conversation-main strong,
.conversation-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-main strong {
  font-size: 13px;
}

.conversation-main span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.conversation-meta {
  align-self: start;
  text-align: left;
}

.conversation-time {
  color: var(--muted);
  font-size: 10px;
}

.unread {
  min-width: 20px;
  height: 20px;
  margin-top: 7px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--indigo);
  color: white;
  font-size: 10px;
}

.chat-panel {
  min-width: 0;
  background: var(--surface);
}

.empty-chat {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.empty-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 25px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-size: 34px;
}

.empty-chat h2 {
  margin: 20px 0 6px;
  font-size: 19px;
}

.empty-chat p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.active-chat {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.chat-header {
  min-height: 72px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.mobile-back {
  display: none;
  font-size: 27px;
}

.chat-person {
  display: grid;
  gap: 3px;
}

.chat-person strong {
  font-size: 14px;
  direction: ltr;
}

.chat-person span {
  color: var(--muted);
  font-size: 11px;
}

.window-badge {
  margin-right: auto;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.window-badge.open {
  background: rgba(61, 139, 100, .1);
  color: var(--green);
}

.window-badge.closed {
  background: rgba(155, 94, 80, .12);
  color: var(--clay);
}

.window-notice {
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.message-list {
  overflow-y: auto;
  padding: 26px max(24px, 6vw);
}

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

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

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

.message {
  max-width: min(72%, 620px);
}

.bubble {
  padding: 11px 14px;
  border-radius: 17px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.message-row.in .bubble {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-top-right-radius: 5px;
}

.message-row.out .bubble {
  background: var(--indigo);
  color: white;
  border-top-left-radius: 5px;
}

.message-time {
  margin: 5px 5px 0;
  color: var(--muted);
  font-size: 9px;
}

.message-row.out .message-time {
  text-align: left;
}

.composer {
  padding: 13px 18px 17px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.send-btn {
  min-width: 88px;
  border-radius: 14px;
}

.send-btn:disabled,
textarea:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.details-empty {
  color: var(--muted);
  text-align: center;
  padding-top: 35px;
}

.details-empty span {
  color: var(--text);
  font-weight: 700;
}

.details-empty p {
  font-size: 12px;
}

.details-avatar {
  width: 68px;
  height: 68px;
  margin: 10px auto 16px;
}

#detailsContent {
  text-align: center;
}

#detailsContent h3 {
  direction: ltr;
  margin: 0;
}

#detailsContent > p {
  margin: 5px 0 30px;
  color: var(--muted);
  font-size: 12px;
}

.detail-block {
  padding: 15px 0;
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--line);
  text-align: right;
}

.detail-block span {
  color: var(--muted);
  font-size: 10px;
}

.detail-block strong {
  font-size: 12px;
}

.toast {
  position: fixed;
  bottom: 25px;
  left: 25px;
  z-index: 100;
  padding: 12px 15px;
  border-radius: 12px;
  background: var(--text);
  color: var(--surface-2);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .25s ease;
  font-size: 12px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 300px 1fr;
  }

  .details-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: 62px;
    padding: 0 14px;
  }

  .brand span,
  .connected,
  .text-btn {
    display: none;
  }

  .workspace {
    height: calc(100vh - 62px);
    display: block;
  }

  .conversation-panel {
    width: 100%;
    height: 100%;
    border: 0;
  }

  .chat-panel {
    display: none;
    height: 100%;
  }

  body.chat-open .conversation-panel {
    display: none;
  }

  body.chat-open .chat-panel {
    display: block;
  }

  .mobile-back {
    display: inline-block;
  }

  .message-list {
    padding: 20px 12px;
  }

  .message {
    max-width: 84%;
  }

  .composer {
    padding: 10px;
  }
}
