:root {
  --rl-font: 'Ubuntu', sans-serif;
  --rl-text: #212529;
  --rl-bg: #fdfdfd;
  --rl-brand: #0d6efd;
  --rl-muted: #6c757d;
  --rl-border: var(--bs-border-color, #dee2e6);
  --rl-radius-sm: .375rem;
  --rl-radius-md: .5rem;
  --rl-radius-lg: .75rem;
  --rl-shadow-sm: 0 2px 8px rgba(0, 0, 0, .04);
}

html,
body {
  height: 100%;
  font-size: 16px;
}

body {
  font-family: var(--rl-font);
  font-size: 1.15rem;
  background: var(--rl-bg);
  color: var(--rl-text);
  line-height: 1.6;
}

.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex-grow: 1;
  padding-top: 20px; /* Отступ для фиксированного хедера */
}

/* Общие стили */
a {
  color: var(--rl-brand);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover,
a:focus {
  text-decoration: underline;
  color: #0a58ca;
}

a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid var(--rl-brand);
  outline-offset: 2px;
}

/* Кнопки и формы */
.btn,
.form-control,
.form-select {
  font-size: 1.1rem;
  border-radius: var(--rl-radius-md);
}

.btn {
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Карточки */
.card {
  border: none;
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Формы */
form .form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card input.form-control {
  font-size: 1rem;
}

.form-text {
  font-size: 0.875rem;
  color: var(--rl-muted);
  margin-top: 0.25rem;
}

/* Утилиты */
.text-danger {
  font-size: 0.875rem;
  color: #dc3545;
}

/* Профиль */
.card-profile {
  max-width: 660px;
  margin: auto;
  border-radius: var(--rl-radius-lg);
  overflow: hidden;
}

@media (max-width: 576px) {
  .card-profile {
    padding: 1rem;
    margin: 1rem;
  }
}

/* Аватар */
.avatar-editable {
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.avatar-editable:hover {
  transform: scale(1.03);
  box-shadow: 0 0 15px rgba(13, 110, 253, 0.3);
}

.avatar-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 200px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: var(--rl-radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-size: 1rem;
  padding: 0.25rem 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
}

.avatar-menu.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.avatar-menu .dropdown-item {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s ease;
}

.avatar-menu .dropdown-item:hover {
  background-color: #f8f9fa;
}

.avatar-menu .dropdown-item.text-danger:hover {
  color: #dc3545;
  background-color: rgba(220, 53, 69, 0.1);
}

@media (max-width: 768px) {
  .card-profile .row.g-3 .col-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .card-profile .position-relative {
    padding-top: 2rem;
  }
}

/* Dropzone */
#dropzone,
#drop-zone {
  cursor: pointer;
  transition: background 0.2s ease;
  border: 2px dashed #dee2e6;
  border-radius: var(--rl-radius-md);
  padding: 2rem;
  text-align: center;
}

#dropzone.dragover,
#drop-zone.dragover {
  background: #e3f2fd;
  border-color: var(--rl-brand);
}

.file-card {
  background: #f8f9fa;
  border: 1px dashed #ced4da;
  border-radius: var(--rl-radius-md);
  padding: 1rem;
  margin-bottom: 0.5rem;
  transition: border-color 0.2s ease;
}

.file-card:hover {
  border-color: var(--rl-brand);
}

/* Поиск пациентов */
.patient-search-form input.form-control {
  flex: 1;
  min-width: 250px;
  max-width: 400px;
  border-radius: var(--rl-radius-md);
}

.patient-search-form button.btn {
  white-space: nowrap;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
}

.patient-list .list-group-item {
  border-radius: var(--rl-radius-md);
  transition: box-shadow 0.2s ease;
  margin-bottom: 0.5rem;
}

.patient-list .list-group-item:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.patient-list .list-group-item span {
  font-size: 1.1rem;
  font-weight: 500;
  color: #2d3436;
}

.patient-list .btn-outline-primary {
  font-weight: 500;
  transition: all 0.2s ease;
}

.patient-list .btn-outline-primary:hover {
  background: var(--rl-brand);
  color: white;
}

/* Пагинация */
.pagination {
  margin-top: 1rem;
}

.pagination .page-link {
  border-radius: 0.4rem;
  padding: 0.5rem 0.75rem;
}

.pagination .page-item.active .page-link {
  font-weight: 600;
  background-color: var(--rl-brand);
  border-color: var(--rl-brand);
}

/* Блог */
.blog-card {
  display: flex;
  gap: 1rem;
  border-radius: var(--rl-radius-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  min-height: 160px;
  background: white;
  border: 1px solid var(--rl-border);
}

.blog-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.blog-card .blog-card-img {
  flex-shrink: 0;
  width: 160px;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--rl-radius-md) 0 0 var(--rl-radius-md);
}

.blog-card .card-body {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.blog-card .card-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--rl-text);
}

.blog-card .card-text {
  font-size: 0.9rem;
  color: #6c757d;
  line-height: 1.5;
}

.blog-card .badge {
  font-size: 0.75rem;
  margin-right: 6px;
  padding: 0.25rem 0.5rem;
}

.blog-card .stretched-link {
  position: relative;
  z-index: 1;
}

@media (max-width: 576px) {
  .blog-card {
    flex-direction: column;
    align-items: stretch;
  }

  .blog-card .blog-card-img {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--rl-radius-md) var(--rl-radius-md) 0 0;
  }

  .blog-card .card-body {
    padding: 1rem;
  }
}

/* Статьи */
.article-container {
  max-width: 800px;
  padding: 2rem 1rem;
  margin: 0 auto;
}

.article-title {
  font-size: 2.2rem;
  margin-bottom: 1.5rem;
  color: var(--rl-text);
  line-height: 1.2;
}

.article-intro {
  font-size: 1.2rem;
  color: #495057;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.comment {
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: var(--rl-radius-md);
  margin-bottom: 1rem;
  border: 1px solid var(--rl-border);
}

/* Бейджи в навигации */
.nav-link .badge {
  font-size: 0.65rem;
  line-height: 1;
  transform: translate(50%, -50%);
  padding: 0.25rem 0.4rem;
}

.dropdown-item.bg-light {
  background-color: #f8f9fa !important;
}

/* Лента */
.feed-container {
  max-width: 820px;
  margin-inline: auto;
  padding: 1rem;
}

.post-card {
  border: 1px solid var(--rl-border);
  border-radius: 14px;
  box-shadow: var(--rl-shadow-sm);
  background: white;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.post-header>img.avatar {
  width: 40px !important;
  height: 40px !important;
  object-fit: cover;
  flex: 0 0 40px !important;
  display: inline-block;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 576px) {
  .post-header>img.avatar {
    width: 36px !important;
    height: 36px !important;
    flex-basis: 36px !important;
  }
}

.post-meta {
  color: var(--rl-muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.post-img-single {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  border-radius: 0.75rem;
}

.post-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

@media (min-width: 768px) {
  .post-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.post-thumb {
  aspect-ratio: 1/1;
  overflow: hidden;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.post-thumb:hover {
  transform: scale(1.02);
}

.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-actions {
  border-top: 1px solid var(--rl-border);
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.post-actions-menu .btn {
  padding: 0.25rem 0.5rem;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.post-actions-menu .dropdown-menu {
  min-width: 220px;
  border-radius: var(--rl-radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.post-actions-menu .dropdown-item .bi {
  opacity: 0.9;
  vertical-align: -0.1em;
  margin-right: 0.5rem;
}

/* Иконки кнопок */
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  line-height: 1;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background-color: #f8f9fa;
  transform: scale(1.1);
}

.btn-icon .bi {
  font-size: 1rem;
}

/* Основное изображение статьи */
.article-main-image {
  background: #f8f9fa;
  border-radius: 0.75rem;
  overflow: hidden;
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  margin-bottom: 2rem;
}

@media (max-width: 576px) {
  .article-main-image {
    aspect-ratio: 4/3;
  }
}

.article-main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Изображения в контенте */
.article-body img,
.richtext img {
  max-width: 100%;
  width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 0.5rem;
  display: block;
}

.richtext .richtext-image.left,
.richtext .richtext-image.right {
  max-width: min(50%, 420px);
  margin: 1rem;
}

@media (max-width: 768px) {
  .richtext .richtext-image.left,
  .richtext .richtext-image.right {
    float: none !important;
    margin: 1rem 0;
    max-width: 100%;
  }
}

/* Миниатюры блога */
.blog-thumb {
  width: 320px;
  aspect-ratio: 16/10;
  display: block;
  background: #f8f9fa;
  border-radius: 0.5rem 0 0 0.5rem;
  overflow: hidden;
}

.blog-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 576px) {
  .blog-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 0.5rem 0.5rem 0 0;
  }
}

/* Лайки */
.btn-like .bi {
  transition: transform 0.15s ease, color 0.15s ease;
}

.btn-like.active .bi {
  transform: scale(1.15);
  color: #dc3545;
}

/* Аватары */
.author-avatar,
.comment-avatar {
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Карточки с миниатюрами */
.card-thumb {
  width: 160px;
  aspect-ratio: 4/3;
  border-radius: var(--rl-radius-md) 0 0 var(--rl-radius-md);
  overflow: hidden;
  background: #f8f9fa;
  display: block;
}

.card-thumb>img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rl-muted);
  font-size: 0.9rem;
}

@media (max-width: 576px) {
  .card-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--rl-radius-md) var(--rl-radius-md) 0 0;
  }
}

/* HR раздел */
.hr-page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem;
}

.hr-card {
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  background: white;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.hr-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.hr-table th {
  overflow: hidden;
  font-weight: 600;
  padding: 1rem;
  background: #f8f9fa;
  border-bottom: 2px solid var(--rl-border);
}

.hr-table td {
  overflow: visible;
  vertical-align: middle;
  padding: 1rem;
  border-bottom: 1px solid var(--rl-border);
  word-break: break-word;
}

.hr-head {
  background: linear-gradient(180deg, #fafbff, #f5f7fb);
  position: sticky;
  top: 0;
  z-index: 1;
}

.hr-th {
  font-weight: 600;
  color: var(--rl-text);
}

.hr-wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}

.hr-nowrap {
  white-space: nowrap;
}

.hr-truncate {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  max-width: 200px;
}

.hr-col-id {
  width: 56px;
}

.hr-col-created {
  width: 150px;
}

.hr-col-username {
  width: 180px;
}

.hr-col-telegram {
  width: 180px;
}

.hr-col-email {
  width: 260px;
}

.hr-col-status {
  width: 120px;
}

.hr-col-actions {
  width: 200px;
}

.hr-actions {
  overflow: visible;
  display: flex;
  gap: 0.5rem;
}

.hr-msg {
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
  line-height: 1.5;
}

.table-responsive {
  overflow-x: auto;
  border-radius: var(--rl-radius-md);
  border: 1px solid var(--rl-border);
}

@media (max-width: 1200px) {
  .hr-col-email {
    display: none;
  }

  .hr-col-username {
    width: 160px;
  }

  .hr-col-telegram {
    width: 160px;
  }

  .hr-col-actions {
    width: 180px;
  }
}

@media (max-width: 768px) {
  .hr-page {
    max-width: 100%;
    padding: 0.5rem;
  }

  .hr-col-created {
    width: 130px;
  }

  .hr-col-actions {
    width: 160px;
  }

  .hr-table .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
  }

  .hr-head {
    position: static;
  }

  .hr-nowrap {
    white-space: normal;
  }
  
  .hr-table th,
  .hr-table td {
    padding: 0.75rem 0.5rem;
  }

  .table-responsive {
    border: 0;
    overflow-x: visible;
  }

  .hr-table,
  .hr-table thead,
  .hr-table tbody,
  .hr-table tr,
  .hr-table th,
  .hr-table td {
    display: block;
    width: 100%;
  }

  .hr-table thead {
    display: none;
  }

  .hr-table tr {
    background: #fff;
    border: 1px solid var(--rl-border);
    border-radius: 12px;
    padding: 0.25rem 0.75rem;
    margin-bottom: 0.75rem;
  }

  .hr-table td {
    border: 0;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .hr-table td.d-lg-table-cell {
    display: flex !important;
  }

  .hr-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--rl-muted);
    min-width: 110px;
    flex-shrink: 0;
  }

  .hr-table td.text-end {
    text-align: left;
  }

  .hr-table td.hr-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
  }

  .hr-table td.hr-actions::before {
    margin-right: auto;
  }
}

/* Подвал */
.footer {
  background: #0B4141;
  color: #FAFAFA;
  margin-top: auto;
}

.footer a {
  color: #B7D0CC;
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer a:hover {
  color: #FAFAFA;
  text-decoration: underline;
}

.footer p {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  opacity: 0.9;
}

.footer h5 {
  color: #FAFAFA;
  margin-bottom: 1rem;
  font-weight: 600;
}

/* Анимации */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Кастомный скроллбар */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Улучшенные отступы для мобильных */
@media (max-width: 768px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  main {
    padding-top: 1rem;
  }
  
  .card, .hr-card {
    border-radius: 12px;
  }
}

/* Тень для контейнеров */
.shadow-soft {
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08) !important;
}

.shadow-medium {
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.12) !important;
}

/* Градиентные тексты */
.text-gradient {
  background: linear-gradient(135deg, #0B4141, #2D9C8A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Загрузка */
.loading-spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #0B4141;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
