:root {
  --bg: #f0f1f5;
  --panel: #ffffff;
  --muted: #7d8391;
  --text: #252a35;
  --accent: #6d2ee6;
  --accent-soft: #efe7ff;
  --bubble-user: #eef1f6;
  --border: #e6e8ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #dfe1e6;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
}

html[dir="rtl"] body {
  direction: rtl;
}

.phone-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.chat-card {
  width: min(430px, 100%);
  height: min(860px, 95vh);
  background: var(--panel);
  border-radius: 30px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  border: 1px solid #d7dbe7;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 12px;
}

.logo {
  font-weight: 800;
  color: var(--accent);
  font-size: 20px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f8f9fc;
  color: #57607a;
}

.reset-btn {
  color: #9c1f1f;
  border-color: #efc9c9;
  background: #fff5f5;
}

.clinic-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 12px;
}

.clinic-avatar {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: linear-gradient(135deg, #d9dde8, #bbc4dc);
}

.clinic-meta h3 {
  margin: 0;
  font-size: 13px;
}

.clinic-meta p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.consult-btn {
  background: #222;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
}

.consult-actions {
  display: grid;
  gap: 6px;
}

.user-info-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fafbff;
}

.user-info-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.user-info-grid {
  display: grid;
  grid-template-columns: 1fr 90px 110px;
  gap: 8px;
}

.user-info-grid input,
.user-info-grid select {
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 34px;
  padding: 0 8px;
  background: #fff;
}

.auth-key-input {
  margin-top: 8px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 34px;
  padding: 0 8px;
  background: #fff;
}

.start-chat-btn {
  margin-top: 8px;
  width: 100%;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.messages {
  overflow: auto;
  padding: 2px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 82%;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  animation: msgIn 220ms ease-out;
}

.msg.user {
  align-self: flex-end;
  background: var(--bubble-user);
}

.msg.bot {
  align-self: flex-start;
  background: var(--accent-soft);
  color: #2f195d;
}

.msg.bot strong {
  font-weight: 700;
}

.msg.bot em {
  font-style: italic;
}

.msg.bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  background: rgba(109, 46, 230, 0.12);
  border-radius: 6px;
  padding: 1px 5px;
}

.msg.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-style: italic;
  color: #4a2e87;
  min-height: 38px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6d2ee6;
  opacity: 0.4;
  animation: dotPulse 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.suggest-wrap {
  background: #f3ecff;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  border: 1px solid #e3d6ff;
  animation: panelIn 260ms ease-out;
}

.suggest-title {
  margin: 0;
  font-size: 12px;
  color: #4a2e87;
  font-weight: 700;
}

.suggest-row {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 2px;
}

.suggest-chip {
  min-width: 150px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 8px;
}

.suggest-chip h4 {
  margin: 0;
  font-size: 12px;
}

.suggest-chip p {
  margin: 3px 0 0;
  font-size: 11px;
  opacity: 0.9;
}

.service-card {
  min-width: 220px;
  max-width: 230px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  overflow: hidden;
}

.service-card-image {
  width: 100%;
  height: 104px;
  object-fit: cover;
  display: block;
}

.service-card-content {
  padding: 8px;
}

.service-card-content h4 {
  margin: 0;
  font-size: 12px;
}

.service-card-content p {
  margin: 4px 0 0;
  font-size: 11px;
  opacity: 0.92;
}

.preview-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 6px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-preview {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: white;
}

.hidden {
  display: none;
}

.list-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}

.list-modal.hidden {
  display: none;
}

.list-modal-card {
  width: min(560px, 96vw);
  max-height: 78vh;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.list-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.list-modal-header h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.list-modal-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f8fc;
  cursor: pointer;
}

.list-modal-body {
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
}

.list-modal-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fafbff;
}

.list-modal-item h4 {
  margin: 0;
  font-size: 13px;
}

.list-modal-item p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.upload-btn,
.send-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.upload-btn {
  background: #f5f6fa;
}

.send-btn {
  background: var(--accent);
  color: white;
  border: none;
  position: relative;
  transition: opacity 160ms ease, transform 160ms ease;
}

.send-btn.is-disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.send-btn.is-loading {
  color: transparent;
}

.send-btn.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  position: absolute;
  inset: 0;
  margin: auto;
  animation: spin 0.8s linear infinite;
}

.message-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 38px;
  padding: 0 10px;
}

.language-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  display: grid;
  place-items: center;
  z-index: 1100;
  padding: 16px;
}

.language-modal.hidden {
  display: none;
}

.language-modal-card {
  width: min(430px, 94vw);
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--border);
}

.language-modal-card h2 {
  margin: 0;
  font-size: 20px;
}

.language-modal-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.language-actions {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.language-btn {
  border: 1px solid var(--border);
  background: #f7f8fd;
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
}

.language-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
