.client-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  min-height: 620px;
  height: min(720px, calc(100vh - 220px));
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 18px 48px var(--shadow-sm);
  overflow: hidden;
}

.client-chat__main {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--bg-surface);
  
}

.client-chat__topbar {
  display: flex;
  align-items: center;
  min-height: 68px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.client-chat__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.client-chat__avatar,
.client-chat-profile__avatar {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--text-stable-white);
  background: linear-gradient(135deg, var(--gradient-app-start), var(--gradient-app-end));
  font-weight: 800;
  letter-spacing: 0;
}

.client-chat__identity-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.client-chat__identity-text strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-chat__identity-text small {
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 700;
}

.client-chat__messages {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px 20px;
  background: var(--bg-surface);
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: none;
}

.client-chat__state,
.client-chat-summary__state {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--text-secondary);
  font-size: 0.92rem;
  text-align: center;
}

.client-chat__state--error {
  color: var(--danger);
}

.client-chat__load-more {
  display: none;
  padding: 10px 18px 0;
  text-align: center;
}

.client-chat__load-more .btn {
  min-height: 34px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.client-chat-date-separator {
  display: flex;
  justify-content: center;
  margin: 2px 0 4px;
}

.client-chat-date-separator span {
  padding: 4px 12px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--bg-surface-raised);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.client-chat-message {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 3px;
}

.client-chat-message--patient {
  align-items: flex-start;
}

.client-chat-message--nutritionist {
  align-items: flex-end;
}

.client-chat-message__bubble {
  max-width: min(72%, 560px);
  padding: 11px 14px;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  background: var(--bg-surface-raised);
  box-shadow: 0 6px 18px var(--shadow-sm);
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.client-chat-message--patient .client-chat-message__bubble {
  border-radius: 16px 16px 16px 5px;
}

.client-chat-message--nutritionist .client-chat-message__bubble {
  border-color: transparent;
  border-radius: 16px 16px 5px 16px;
  color: var(--text-stable-white);
  background: linear-gradient(135deg, var(--gradient-app-start), var(--gradient-app-end));
  box-shadow: 0 10px 24px var(--shadow-brand-sm);
}

.client-chat-message__time {
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.2;
}

.client-chat__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: end;
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.client-chat__composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 118px;
  padding: 12px 14px;
  resize: vertical;
  border: 1px solid var(--border-input);
  border-radius: 999px;
  color: var(--text-primary);
  background: var(--bg-surface-raised);
  box-shadow: inset 0 1px 2px var(--shadow-sm);
  font: inherit;
  line-height: 1.35;
}

.client-chat__composer textarea:focus {
  border-color: var(--border-input-focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--shadow-focus);
}

.client-chat__send {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  color: var(--text-stable-white);
  background: linear-gradient(135deg, var(--gradient-app-start), var(--gradient-app-end));
  box-shadow: 0 10px 24px var(--shadow-brand-md);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.client-chat__send:hover {
  transform: translateY(-1px);
}

.client-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.client-chat__sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 20px 18px;
  border-left: 1px solid var(--border-light);
  background: var(--bg-surface-raised);
}

.client-chat-profile {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0 4px 2px;
  text-align: center;
}

.client-chat-profile__avatar {
  width: 64px;
  height: 64px;
  margin-bottom: 4px;
  font-size: 1.25rem;
}

.client-chat-profile strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.client-chat-profile span {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.client-chat-profile em {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--success-text);
  background: var(--success-bg);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 800;
}

.client-chat-profile em:empty,
.client-chat-profile em[hidden] {
  display: none;
}

.client-chat-summary {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-surface);
}

.client-chat-summary__card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
}

.client-chat-summary__card:last-child {
  border-bottom: 0;
}

.client-chat-summary__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--info-bg);
}

.client-chat-summary__card--plan .client-chat-summary__icon {
  background: var(--success-bg);
}

.client-chat-summary__card--diet .client-chat-summary__icon {
  background: var(--purple-btn-soft-bg);
}

.client-chat-summary__card--weight .client-chat-summary__icon {
  background: var(--warning-bg);
}

.client-chat-summary__icon .ui-icon {
  width: 17px;
  height: 17px;
}

.client-chat-summary__content {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.client-chat-summary__content small {
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.client-chat-summary__content strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.88rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-chat-summary__content em {
  color: var(--success);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 800;
}

.client-chat-quick {
  display: grid;
  gap: 8px;
}

.client-chat-quick__label {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.client-chat-quick__btn {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  color: var(--text-primary);
  background: var(--bg-surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
}

.client-chat-quick__btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-surface-card);
  box-shadow: 0 8px 22px var(--shadow-sm);
}

.client-chat-quick__btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.62;
}

@media (max-width: 980px) {
  .client-chat {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .client-chat__sidebar {
    order: -1;
    border-left: 0;
    border-bottom: 1px solid var(--border-light);
  }

  .client-chat-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-chat-summary__card {
    border-right: 1px solid var(--border-light);
  }

  .client-chat-summary__card:nth-child(2n),
  .client-chat-summary__card:last-child {
    border-right: 0;
  }

  .client-chat__messages {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .client-chat {
    border-radius: 0;
  }

  .client-chat__topbar,
  .client-chat__messages,
  .client-chat__composer,
  .client-chat__sidebar {
    padding-right: 14px;
    padding-left: 14px;
  }

  .client-chat-summary {
    grid-template-columns: 1fr;
  }

  .client-chat-summary__card,
  .client-chat-summary__card:nth-child(2n) {
    border-right: 0;
  }

  .client-chat-message__bubble {
    max-width: 86%;
  }

  .client-chat__composer {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .client-chat__send {
    width: 44px;
    height: 44px;
  }
}
