/* Consultation Plugin - UIkit стили */

/* Скрываем значок reCAPTCHA (разрешено по правилам Google при наличии текста в соглашении) */
.grecaptcha-badge {
  visibility: hidden !important;
}

/* Одна карточка в истории диалогов — без вложенных «карточек» */
#cnslt-thread-list .cnslt-thread-card .cnslt-payment-block,
#cnslt-thread-list .cnslt-thread-card .cnslt-thread-card-badge {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
#cnslt-thread-list .cnslt-thread-card.uk-card-default {
  border: 1px solid #b2b2b2;
  color: #65645f;
}
#cnslt-thread-list .cnslt-thread-card.uk-card-default * {
  color: #65645f;
}
#cnslt-thread-list .cnslt-thread-card.uk-card-default .uk-button-primary {
  color: #fff;
}
#cnslt-thread-list .cnslt-thread-card.uk-card-secondary,
#cnslt-thread-list .cnslt-thread-card.uk-card-secondary * {
  color: #ffffff;
}
/* Единые бейджи статусов (кабинет и админка): фон, скругление 15px, контрастный текст */
.cnslt-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 500;
  border: none;
}
.cnslt-badge-new {
  background: #b85454;
  color: #fff;
}
.cnslt-badge-in_progress {
  background: #d4a84b;
  color: #1d1d1d;
}
.cnslt-badge-waiting_patient {
  background: #d4925c;
  color: #1d1d1d;
}
.cnslt-badge-closed {
  background: #5b7c9e;
  color: #fff;
}
.cnslt-badge-closed_rated {
  background: #4a6b5c;
  color: #fff;
}
.cnslt-cabinet .cnslt-badge,
#cnslt-thread-list .cnslt-badge,
.cnslt-thread-header .cnslt-badge {
  font-size: 11px;
}

#cnslt-thread-list .cnslt-thread-card.uk-card-secondary .uk-button {
  color: #943232 !important;
}
#cnslt-thread-list .cnslt-thread-card.uk-card-secondary .uk-button:hover {
  color: #fff !important;
  background: none !important;
  border-color: #fff !important;
}
#cnslt-thread-list .cnslt-thread-card .cnslt-payment-block {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 959px) {
  #cnslt-thread-list .cnslt-thread-card .cnslt-payment-block {
    display: none !important;
  }
}

/* Блок оплаты в диалоге (после первого сообщения) */
.cnslt-payment-block-in-dialog {
  border: 1px solid #cd3636 !important;
  color: #65645f;
}
.cnslt-payment-block-in-dialog p,
.cnslt-payment-block-in-dialog .uk-button {
  color: #65645f;
}
.cnslt-payment-block-in-dialog .uk-button.uk-button-primary {
  color: #fff;
}
@media (min-width: 960px) {
  .cnslt-payment-block-in-dialog {
    width: 500px;
    max-width: 100%;
  }
}

/* Обертка кабинета */
.cnslt-wrap {
  margin-top: -40px;
  height: calc(100vh - 100px);
  overflow: hidden;
  padding-top: 10px !important;
}

/* На мобильных устройствах больше отступ вверх */
@media (max-width: 959px) {
  .uk-section .cnslt-wrap,
  .uk-container .cnslt-wrap,
  div.cnslt-wrap {
    margin-top: -50px !important;
  }
  
  /* Перебиваем UIKit стили для cnslt-wrap */
  .uk-margin-remove-adjacent + .cnslt-wrap,
  .uk-margin-remove-first-child > .cnslt-wrap:first-child,
  * > .cnslt-wrap {
    margin-top: -50px !important;
  }

  /* Левая колонка без обёртки-карточки на мобильном */
  .cnslt-cabinet .cnslt-left-col-card {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Аватар всегда круглый на мобильном */
  .cnslt-user #cnslt-avatar {
    flex-shrink: 0;
    min-width: 60px;
    width: 60px !important;
    height: 60px !important;
  }
  
  /* Больше gap между аватаркой и информацией на мобильном */
  .cnslt-profile-grid {
    gap: 20px !important;
  }
}

/* Аватар всегда круглый на десктопе */
@media (min-width: 960px) {
  .cnslt-user #cnslt-avatar {
    width: 120px !important;
    height: 120px !important;
  }
  
  /* Десктопная раскладка - центр */
  .cnslt-profile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .cnslt-profile-info {
    margin-top: 10px;
  }
  
  .cnslt-contacts {
    margin-top: 10px;
  }
  
  .cnslt-contacts > div {
    margin-top: 8px;
  }
}

/* Мобильная раскладка - flex row */
@media (max-width: 959px) {
  .cnslt-profile-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
    text-align: left;
  }
  
  .cnslt-avatar {
    flex-shrink: 0;
  }
  
  .cnslt-profile-info {
    flex: 1;
    min-width: 0;
  }
  
  .cnslt-user-name {
    margin-bottom: 4px;
  }
  
  .cnslt-contacts > div {
    margin-top: 2px;
  }
  
  /* Кнопка "Выйти" на мобильном - только иконка по центру */
  .cnslt-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Мобильная навигация - скрываем чат по умолчанию */
  .cnslt-chat-column {
    display: none;
  }
  
  /* Когда показываем чат - скрываем список */
  .cnslt-cabinet.cnslt-show-chat .cnslt-chat-column {
    display: block;
  }
  
  .cnslt-cabinet.cnslt-show-chat > div:first-child {
    display: none;
  }
}

/* На десктопе всё видно */
@media (min-width: 960px) {
  .cnslt-chat-column {
    display: block !important;
  }
  
  /* Заголовок диалога на десктопе */
  .cnslt-thread-title {
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.2;
  }
}

/* Заголовок диалога на мобильном */
@media (max-width: 959px) {
  .cnslt-thread-header {
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
  
  .cnslt-thread-title {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.3;
    flex: 1;
    word-break: break-word;
  }
  
  .cnslt-thread-status {
    flex-shrink: 0;
  }
  
  /* Блок сообщений на мобильном - меньше высота */
  .cnslt-messages {
    min-height: 200px !important;
    max-height: 35vh !important;
  }
}

/* Убираем padding у секции на странице кабинета */
.uk-section:has(.cnslt-wrap) {
  padding-top: 20px;
  padding-bottom: 0;
}

/* Запрещаем скролл на странице кабинета (только десктоп) */
@media (min-width: 960px) {
  body:has(.cnslt-wrap),
  html:has(.cnslt-wrap) {
    overflow: hidden !important;
    height: 100vh !important;
  }

  /* Убираем скролл у основного контейнера */
  body:has(.cnslt-wrap) .tm-page,
  body:has(.cnslt-wrap) .uk-section,
  body:has(.cnslt-wrap) #tm-main {
    overflow: hidden !important;
  }
}

/* Список диалогов */
.cnslt-list {
  max-height: 50vh;
  overflow-y: auto;
}

.cnslt-list a.uk-card {
  transition: all 0.2s ease;
}

.cnslt-list a.uk-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Скрываем заголовок "Кабинет консультаций" на странице кабинета */
/* Если заголовок находится внутри uk-article, который содержит cnslt-cabinet */
.uk-article:has(.cnslt-cabinet) h1.uk-article-title,
.uk-article:has(.cnslt-wrap) h1.uk-article-title,
.uk-article:has(.cnslt-cabinet) .uk-article-title {
  display: none !important;
}

/* Fallback через JavaScript будет добавлен */

/* Сообщения в диалоге */
.cnslt-messages {
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 20px;
  background: #f5f5f5;
  transition: max-height 0.35s ease, min-height 0.35s ease, padding 0.35s ease;
}
/* При открытой форме отзыва врачу: скрываем блок сообщений до отправки отзыва (ПК и мобильный) */
.cnslt-messages.cnslt-messages-review-open {
  display: none !important;
}

/* Контейнер сообщения */
.cnslt-msg-wrapper {
  display: flex;
  margin-bottom: 15px;
}

.cnslt-msg-wrapper:last-child {
  margin-bottom: 0;
}

/* Пузырьки сообщений */
.cnslt-msg-bubble {
  max-width: 70%;
  padding: 5px 10px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Сообщение пациента (справа) */
.cnslt-msg-patient {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  margin-left: auto;
  border-radius: 18px 18px 0 18px; /* Нижний правый угол острый */
}

/* Сообщение врача (слева) */
.cnslt-msg-doctor {
 background: #ffffff;
  border: 1px solid #2f5f5f;
  margin-right: auto;
  border-radius: 0px 18px 18px 0px;
}

/* Заголовок сообщения */
.cnslt-msg-header {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 6px;
  font-weight: 600;
}

/* Тело сообщения */
.cnslt-msg-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  color: #333;
}

.cnslt-msg-doctor .cnslt-msg-body {
  color: #2f5f5f;
}

/* Время сообщения */
.cnslt-msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 6px;
  text-align: right;
}

/* Файлы в сообщении */
.cnslt-msg-files {
  margin-top: 10px;
}

/* Файлы в сообщениях */
.cnslt-files-grid {
  margin-top: 10px;
}

.cnslt-files-grid .uk-card img,
.cnslt-files-grid .uk-card video,
.cnslt-files-grid .uk-card iframe {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.cnslt-files-grid .uk-card .file-icon {
  font-size: 48px;
  text-align: center;
  padding: 20px;
}

/* Инлайн редактирование */
.cnslt-inline-edit {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* Адаптивность */
@media (max-width: 960px) {
  .cnslt-wrap {
    display: block !important;
  }
  
  .cnslt-wrap > div {
    width: 100% !important;
    margin-bottom: 20px;
  }
}

/* Стили для формы (дополняют UIkit) */
.cnslt-form-wrap {
  padding: 20px 0;
}

.cnslt-msg {
  margin: 10px 0;
  padding: 12px 16px;
  border-radius: 4px;
  background: #fff6e5;
  border: 1px solid #ffe0a6;
}

.cnslt-consent {
  font-size: 13px;
  color: #666;
  margin-top: 8px;
}

.cnslt-files-note {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
}

/* Загрузка файлов */
.cnslt-file-upload {
  position: relative;
  display: inline-block;
  width: 100%;
}

.cnslt-file-upload input[type="file"] {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.cnslt-file-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px dashed #ddd;
  border-radius: 4px;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 50px;
}

.cnslt-file-upload-label:hover {
  border-color: #1e87f0;
  background: #f0f8ff;
}

.cnslt-file-upload-label .uk-icon {
  font-size: 18px;
  color: #1e87f0;
}

/* Блок цены */
.cnslt-price-block {
  text-align: center;
  padding: 16px;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  background: #f8f9fa;
}

/* Валидация ошибок */
.cnslt-validation-errors {
  background: #fff3cd !important;
  border: 1px solid #ffeaa7 !important;
  color: #856404 !important;
  padding: 12px 16px !important;
  border-radius: 4px !important;
  margin-bottom: 16px !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  animation: cnsltErrorSlideIn 0.3s ease-out;
}

@keyframes cnsltErrorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Адаптивность формы */
@media (max-width: 768px) {
  .cnslt-form .uk-grid-medium > * {
    width: 100% !important;
  }
}
