/* ===== Lists ===== */
.message-list,
.message-chain{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.message-list.bubbles-layout{ padding:2px; }

/* ===== Bubble card ===== */
.message-card.bubble{
  position:relative;
  border:1px solid #e6e9ef;
  background:#ffffff;
  border-radius:16px;
  box-shadow:0 6px 18px rgba(2,6,23,.08);
  padding:12px;
  max-width:min(82ch,100%);
  animation:msg-pop .16s ease-out;
}
@keyframes msg-pop{ from{opacity:0; transform:translateY(3px)} to{opacity:1; transform:none} }

/* выравнивание + фоны */
.message-card.bubble.you{
  margin-left:auto;
  background:linear-gradient(180deg,#eef4ff,#e8f0ff);
  border-color:rgba(37,99,235,.35);
}
.message-card.bubble.other{
  margin-right:auto;
  background:linear-gradient(180deg,#f8fafc,#eef2f7);
}

/* хвостики */
.message-card.bubble.you::after,
.message-card.bubble.other::after{
  content:"";
  position:absolute;
  bottom:12px;
  width:12px; height:12px;
  background:inherit;
  border:inherit; border-left:none; border-top:none;
  transform:rotate(45deg);
  box-shadow:inherit;
}
.message-card.bubble.you::after{ right:-6px; }
.message-card.bubble.other::after{ left:-6px; }

/* непрочитанное */
.message-card.bubble.is-unread{
  border-color:#93c5fd;
  box-shadow:0 10px 28px rgba(37,99,235,.16);
}
.message-card.bubble.is-unread::before{
  content:"";
  position:absolute; inset:0 auto 0 0; width:3px;
  background:linear-gradient(180deg,#60a5fa,#2563eb);
  border-radius:16px;
}

/* ===== Header ===== */
.bubble .bubble__header{
  display:grid;
  grid-template-columns:auto 1fr auto;
  gap:10px; align-items:center;
  margin-bottom:6px;
}
.bubble .bubble__avatar{
  width:32px; height:32px; border-radius:50%;
  display:grid; place-items:center;
  font-weight:800; color:#1e3a8a;
  background:rgba(37,99,235,.12);
  box-shadow: inset 0 0 0 1px rgba(37,99,235,.25);
}
.bubble.you .bubble__avatar{
  color:#065f46;
  background:rgba(16,185,129,.12);
  box-shadow: inset 0 0 0 1px rgba(16,185,129,.35);
}
.bubble .bubble__title{ display:grid; gap:2px; }
.bubble .bubble__name{ font-size:14px; font-weight:700; color:#0f172a; }
.bubble .bubble__arrow{ color:#64748b; margin:0 6px; }
.bubble .bubble__time{ font-size:12px; color:#64748b; }

/* бейдж статуса */
.bubble .bubble__badge{
  font-size:11px; line-height:1;
  padding:6px 8px; border-radius:999px; white-space:nowrap;
  background:#ecfdf5; color:#065f46; border:1px solid rgba(16,185,129,.35);
}
.bubble.is-unread .bubble__badge{
  background:#fff7ed; color:#7c2d12; border-color:rgba(245,158,11,.4);
}

/* ===== Body ===== */
.bubble .bubble__body{
  font-size:15px; line-height:1.6; color:#0f172a;
  word-break:break-word;
}
.bubble .bubble__body p{ margin:.4em 0; }

/* ===== Footer ===== */
.bubble .bubble__footer{
  margin-top:8px; display:flex; justify-content:flex-end;
}
.bubble .bubble__permalink{
  font-size:12px; color:#64748b; text-decoration:none;
  border-bottom:1px dashed transparent;
}
.bubble .bubble__permalink:hover{
  color:#2563eb; border-bottom-color:rgba(37,99,235,.35);
}

/* ===== Reply form (composer) ===== */
.reply-form{
  position:sticky; bottom:0; z-index:5;
  border:1px solid #e6e9ef;
  background:rgba(255,255,255,.92);
  backdrop-filter:saturate(1.4) blur(6px);
  border-radius:16px;
  padding:14px; margin:18px 0 0;
  box-shadow:0 18px 46px rgba(2,6,23,.12);
}
.reply-form h3{
  margin:0 0 8px; font-size:16px; font-weight:800; color:#0f172a;
}
.reply-form label{
  display:block; font-size:13px; color:#64748b; margin:10px 0 6px;
}
.reply-form input[type="text"],
.reply-form textarea{
  width:100%;
  border:1px solid #e6e9ef; border-radius:12px;
  padding:10px 12px; background:#ffffff; color:#0f172a;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.reply-form textarea{ min-height:120px; resize:vertical; }
.reply-form input:focus,
.reply-form textarea:focus{
  border-color:#2563eb;
  box-shadow:0 0 0 4px rgba(37,99,235,.15);
  outline:none;
}
.reply-form button[type="submit"]{
  margin-top:10px;
  padding:10px 14px; border:0; border-radius:14px;
  background:linear-gradient(180deg,#2563eb,#1d4ed8);
  color:#ffffff; font-weight:700; letter-spacing:.2px;
  box-shadow:0 8px 20px rgba(37,99,235,.28);
  cursor:pointer;
  transition:transform .06s ease, box-shadow .2s ease, filter .15s ease;
}
.reply-form button[type="submit"]:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 24px rgba(37,99,235,.34);
}
.reply-form button[type="submit"]:active{
  transform:translateY(0);
  filter:brightness(.95);
}


/* ===== Layout ===== */
.chat-layout{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap:16px;
  align-items:stretch;
  margin:10px 0 20px;
}
@media (max-width: 980px){
  .chat-layout{ grid-template-columns: 1fr; }
}

/* ===== Sidebar ===== */
.chat-sidebar{
  border:1px solid #e6e9ef;
  background:#ffffff;
  border-radius:16px;
  box-shadow:0 6px 18px rgba(2,6,23,.08);
  display:flex; flex-direction:column;
  min-height:520px; max-height:80vh;
}
.chat-sidebar__head{
  padding:12px 14px;
  border-bottom:1px solid #e6e9ef;
}
.chat-sidebar__head h2{
  margin:0; font-size:14px; font-weight:800; color:#0f172a; text-transform:uppercase; letter-spacing:.5px;
}
.chat-sidebar__list{
  padding:6px; overflow:auto; flex:1; display:flex; flex-direction:column; gap:6px;
  scrollbar-width: thin; scrollbar-color: rgba(100,116,139,.5) transparent;
}
.chat-sidebar__list::-webkit-scrollbar{ width:8px; }
.chat-sidebar__list::-webkit-scrollbar-thumb{ background:rgba(100,116,139,.45); border-radius:999px; }

.chat-item{
  display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px;
  border:1px solid #e6e9ef; background:#fff; border-radius:12px;
  padding:10px; text-decoration:none; color:#0f172a;
  transition: border-color .15s ease, transform .06s ease, background .15s ease;
}
.chat-item:hover{ border-color:#bcd2ff; transform: translateY(-1px); background:#f9fbff; }
.chat-item.is-active{ border-color:#93c5fd; background:linear-gradient(180deg,#eef4ff,#e8f0ff); }

.chat-item__avatar{
  width:36px; height:36px; border-radius:50%; display:grid; place-items:center;
  font-weight:800; color:#1e3a8a; background:rgba(37,99,235,.12); 
  box-shadow: inset 0 0 0 1px rgba(37,99,235,.25);
}
.chat-item__meta{ display:grid; gap:3px; }
.chat-item__top{ display:grid; grid-template-columns:1fr auto; gap:8px; align-items:center; }
.chat-item__name{ font-size:14px; font-weight:700; color:#0f172a; }
.chat-item__time{ font-size:12px; color:#64748b; }
.chat-item__last{ font-size:13px; color:#475569; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-item__badge{
  justify-self:end;
  font-size:12px; line-height:1; padding:6px 8px; border-radius:999px;
  background:#2563eb; color:#fff; box-shadow:0 6px 16px rgba(37,99,235,.35);
}

/* ===== Thread ===== */
.chat-thread{
  border:1px solid #e6e9ef; background:#ffffff; border-radius:16px;
  box-shadow:0 6px 18px rgba(2,6,23,.08);
  display:grid; grid-template-rows:auto 1fr auto; min-height:520px; max-height:80vh;
}
.chat-thread__head{
  padding:12px 14px; border-bottom:1px solid #e6e9ef; display:flex; align-items:center; justify-content:space-between;
}
.chat-thread__title{ font-size:16px; font-weight:800; color:#0f172a; }

.chat-thread__body{
  padding:12px; overflow:auto;
  scrollbar-width: thin; scrollbar-color: rgba(100,116,139,.5) transparent;
}
.chat-thread__body::-webkit-scrollbar{ width:8px; }
.chat-thread__body::-webkit-scrollbar-thumb{ background:rgba(100,116,139,.45); border-radius:999px; }

.chat-thread__composer{
  padding:12px 14px; border-top:1px solid #e6e9ef; background:#fff; border-radius:0 0 16px 16px;
}

/* ===== Empty text ===== */
.chat-empty{
  color:#64748b; font-size:14px; padding:16px; text-align:center;
}

/* (пузырьковые стили из прошлых сообщений — оставь как есть) */


/* ====== TABS ====== */
.messages-tabs {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin: 10px 0 0;
}

.messages-tabs .tab {
  appearance: none;
  border: 1px solid #cbd5e1;           /* slate-300 */
  border-bottom: none;
  background: #f8fafc;                 /* slate-50 */
  color: #0f172a;                       /* slate-900 */
  padding: 10px 14px;
  line-height: 1.2;
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative;
  top: 1px; /* чтобы визуально «садилась» на рамку контейнера */
}

.messages-tabs .tab:hover {
  background: #eef2f7;                 /* чуть темнее */
  border-color: #94a3b8;               /* slate-400 */
}

.messages-tabs .tab.is-active {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
  box-shadow: 0 1px 0 #ffffff inset;   /* сливаемся с контейнером снизу */
}

/* Контейнер контента вкладок — единая рамка */
.tabs-content {
  border: 1px solid #cbd5e1;
  border-radius: 0 12px 12px 12px;
  background: #ffffff;
  padding: 16px;
  margin-top: 0;
}

/* Показ/скрытие блоков вкладок (твоя логика через класс .show) */
.info-block {
  display: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.info-block.show {
  display: block;
  opacity: 1;
}

/* ====== MESSAGE LIST / CARDS ====== */
.message-list {
  display: grid;
  gap: 12px;
}

/* Универсальная карточка сообщения */
.message-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;                    /* gray-200 */
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
  position: relative;
}

/* Акцентная полоска слева: вы — синий, входящее — фиолетовый */
.message-card.you::before,
.message-card.other::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 14px 0 0 14px;
  background: #4f46e5;                           /* indigo-600 default для входящих */
}
.message-card.you::before { background: #2563eb; } /* blue-600 для исходящих */

.message-card.is-unread {
  border-color: #93c5fd;                          /* blue-300 */
  background: #f8fbff;
}

/* Заголовочная строка карточки */
.message-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.message-card__title {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
}

.message-card__title a {
  color: #0f172a;
  text-decoration: none;
}
.message-card__title a:hover {
  text-decoration: underline;
}

/* Бейдж «Прочитано / Не прочитано» справа */
.message-card__badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #f1f5f9;                            /* slate-100 */
  color: #334155;                                  /* slate-700 */
}

.message-card.is-unread .message-card__badge {
  background: #dbeafe;                             /* blue-100 */
  color: #1e40af;                                  /* blue-800 */
  border-color: #93c5fd;                           /* blue-300 */
}

/* Метаданные (дата/отправитель/получатель) */
.message-card__meta {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}

.meta-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  line-height: 1.3;
}
.meta-label {
  min-width: 80px;
  color: #64748b;                                 /* slate-500 */
}
.meta-value a {
  color: #0f172a;
  text-decoration: none;
}
.meta-value a:hover {
  text-decoration: underline;
}

/* Отрывок текста, если используешь */
.message-card__excerpt {
  margin-top: 10px;
  color: #334155;                                  /* slate-700 */
  font-size: 14px;
  line-height: 1.55;
}

/* ====== Фолбэк-верстка .pm-item (когда нет card-message.php) ====== */
.pm-item {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
}
.pm-item.unread { border-color: #93c5fd; background: #f8fbff; }
.pm-head {
  font-size: 13px;
  color: #0f172a;
  font-weight: 700;
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}
.pm-head time {
  font-weight: 400;
  color: #64748b;
}
.pm-body {
  font-size: 14px;
  color: #334155;
  line-height: 1.6;
}

/* Пагинация */
.pm-pagination {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pm-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #0f172a;
  text-decoration: none;
  font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.pm-pagination .page-numbers:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.pm-pagination .current {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

/* Заголовки разделов */
.msg-col h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

/* ====== Адаптив ====== */
@media (max-width: 900px) {
  .tabs-content { padding: 12px; border-radius: 8px; }
  .messages-tabs .tab { padding: 8px 12px; font-size: 13px; }
  .message-card { padding: 12px; border-radius: 12px; }
  .message-card__title { font-size: 15px; }
  .meta-label { min-width: 70px; }
}

/* ====== Необязательно: чуть лучшая видимость фокуса клавиатурой ====== */
.messages-tabs .tab:focus-visible,
.pm-pagination .page-numbers:focus-visible,
.message-card a:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}


/* ===== Dark mode overrides ===== */
@media (prefers-color-scheme: dark){
  .message-card.bubble{
    border:1px solid #1e293b;
    background:#0f172a;
    box-shadow:0 10px 26px rgba(0,0,0,.35);
  }
  .message-card.bubble.you{
    background:linear-gradient(180deg,#0f1b3a,#0c1630);
    border-color:rgba(37,99,235,.35);
  }
  .message-card.bubble.other{
    background:linear-gradient(180deg,#0f172a,#0c1222);
  }
  .bubble .bubble__name{ color:#e5e7eb; }
  .bubble .bubble__arrow,
  .bubble .bubble__time{ color:#93a4b8; }
  .bubble .bubble__avatar{
    background:rgba(37,99,235,.15);
    color:#a5b4fc;
    box-shadow: inset 0 0 0 1px rgba(37,99,235,.35);
  }
  .bubble.you .bubble__avatar{
    background:rgba(16,185,129,.12);
    color:#86efac;
    box-shadow: inset 0 0 0 1px rgba(16,185,129,.35);
  }
  .bubble .bubble__body{ color:#e5e7eb; }
  .bubble .bubble__permalink{ color:#93a4b8; }
  .reply-form{
    border:1px solid #1e293b;
    background:rgba(15,23,42,.75);
    box-shadow:0 26px 60px rgba(0,0,0,.5);
  }
  .reply-form h3{ color:#e5e7eb; }
  .reply-form label{ color:#93a4b8; }
  .reply-form input[type="text"],
  .reply-form textarea{
    background:#0f172a; color:#e5e7eb; border:1px solid #1e293b;
  }
}
