/* Строка клиента и всё, что в ней и под ней: метки с подсказкой, число дней тепловой картой,
   пять значков связи, кнопки, панель канала с переключателем, поле «Коммуникация» и история.
   На телефоне строка — карточка, на компьютере — строка таблицы; ширина столбцов — по подсказке
   функции (--col-* в style.css). Цвета — переменные style.css. */

/* Метка с подсказкой */
.tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tag-wrap { position: relative; display: inline-block; }
.tag {
  display: inline-block; padding: 3px 10px; border: 0; border-radius: 6px;
  font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tag--red { background: var(--red-bg); color: var(--red-text); }
.tag--yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.tag--green { background: var(--green-bg); color: var(--green-text); }
.tag--plain { background: var(--separator); color: var(--text); }
.tip {
  position: absolute; z-index: 10; top: calc(100% + 8px); right: 0; width: max-content; max-width: 250px;
  padding: 10px 12px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 400; line-height: 1.35; text-align: left;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.tip::before {
  content: ""; position: absolute; top: -6px; right: 14px;
  border: 6px solid transparent; border-top: 0; border-bottom-color: var(--text);
}

/* Число дней — тепловая карта (цвет ставит скрипт) */
.days {
  display: inline-block; min-width: 2.2em; padding: 0 6px; border-radius: 6px;
  text-align: center; font-weight: 600;
}

/* Строки клиентов: на телефоне — карточки */
.client-table__head { display: none; }
.client-row {
  display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding: 12px;
  border-radius: 10px; background: var(--surface);
}
.client-row__name { font-weight: 600; overflow-wrap: anywhere; }
.client-row__phone { font-size: 14px; color: var(--hint); }
.client-row .client-table__cell[data-label] { display: flex; justify-content: space-between; gap: 8px; }
.client-row .client-table__cell[data-label]::before { content: attr(data-label); color: var(--hint); }
.client-row .client-table__cell--empty[data-label] { display: none; }
.client-row__tail { display: flex; flex-direction: column; gap: 8px; overflow-wrap: normal; }

/* Средняя ширина (720–1139 точек): карточки клиентов по две в ряд, а не во всю ширину */
@media (min-width: 720px) and (max-width: 1139px) {
  .client-table { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .client-table__head { display: none; }
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions__error { flex-basis: 100%; margin: 0; font-size: 14px; color: var(--danger); }
.actions__error:empty { display: none; }

/* Пять значков связи: на телефоне — отдельной строкой под полями, на компьютере — в хвосте строки */
.contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.contact {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  padding: 0; border: 0; border-radius: 50%; color: #ffffff; cursor: pointer;
}
.contact svg { width: 22px; height: 22px; fill: currentColor; }
.contact__text { font: 800 10.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.contact--telegram { background: var(--button); color: var(--button-text); }
.contact--whatsapp { background: var(--whatsapp); }
.contact--max { background: linear-gradient(135deg, var(--max-from), var(--max-to)); }
.contact--sms, .contact--call { background: var(--phone-green); }
.contact--off { background: var(--contact-grey); opacity: 0.5; } /* «Нет в …» — нажимается */
.contact.is-open { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--button); }
.contact:disabled { background: var(--contact-grey); opacity: 1; cursor: default; } /* нет телефона */

/* Под строкой: панель канала или история */
.drawer { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--separator); }
.panel__title { margin-bottom: 8px; font-weight: 600; }
.panel__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel__note { margin: 6px 0 0; font-size: 14px; color: var(--hint); }
.panel__note:empty { display: none; }
.panel__note.note--error { color: var(--danger); }
.toggle { display: inline-flex; border: 1.5px solid var(--separator); border-radius: 10px; overflow: hidden; }
.toggle__half {
  min-height: 36px; padding: 0 12px; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
}
.toggle__half + .toggle__half { border-left: 1.5px solid var(--separator); }
.toggle__half--on { background: var(--button); color: var(--button-text); font-weight: 600; cursor: default; }
.toggle__half--off { background: var(--separator); font-weight: 600; cursor: default; }

/* Поле «Коммуникация» и история */
.comm {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; padding: 0; border: 0;
  background: none; color: var(--text); font: inherit; text-align: right;
}
.comm__lines { display: flex; flex-direction: column; min-width: 0; }
.client-row .client-table__cell[data-label]::before { flex-shrink: 0; } /* подпись поля не сжимается */
button.comm { cursor: pointer; }
.comm__chevron { display: inline-block; flex-shrink: 0; color: var(--link); transition: transform 0.15s; }
.comm.is-open .comm__chevron { transform: rotate(90deg); }
.comm__reason { display: block; font-size: 14px; color: var(--danger); }
.comm__note { display: block; overflow: hidden; font-size: 14px; color: var(--hint); white-space: nowrap; text-overflow: ellipsis; }
.history__item { padding: 6px 0; border-top: 1px solid var(--separator); }
.history__item:first-child { border-top: 0; }
.history__item--grey { color: var(--hint); }
.history__head {
  display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit;
  font: inherit; font-size: 15px; text-align: left;
}
button.history__head { cursor: pointer; }
.history__note { font-size: 13px; color: var(--hint); }
.history__chevron { display: inline-block; margin-left: 6px; color: var(--link); transition: transform 0.15s; }
.history__head.is-open .history__chevron { transform: rotate(90deg); }
.history__details { margin-top: 6px; padding: 6px 0 0 12px; border-left: 3px solid var(--separator); }
.history__details-title { margin: 0 0 4px; font-weight: 600; color: var(--text); }
.history__empty, .history__failed { margin: 0; color: var(--hint); }
.history__action { margin-top: 6px; min-height: 32px; font-size: 14px; }
.history__item .actions__error { margin: 4px 0 0; }

/* Широкий экран: клиенты — таблицей, панель и история — полосой на всю ширину. С 1140 точек: уже
   все столбцы с меткой и десятью буквами не помещаются — там строки остаются карточками */
@media (min-width: 1140px) {
  .client-table { display: grid; align-items: stretch; grid-template-columns: var(--table-columns); }
  .client-table__head, .client-row { display: contents; }
  .client-table__head .client-table__cell {
    display: flex; align-items: flex-end; padding: 8px 12px 8px 0; font-size: 13px; color: var(--hint);
  }
  .client-row > .client-table__cell,
  .client-row > .client-table__cell[data-label],
  .client-row > .client-table__cell--empty[data-label] {
    display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
    min-width: 0; padding: 10px 12px 10px 0; border-top: 1px solid var(--separator);
    overflow-wrap: anywhere;
  }
  .client-row .client-table__cell[data-label]::before { content: none; }
  .client-row > .client-row__tail { gap: 8px; padding-right: 0; }
  .contacts { flex-wrap: nowrap; margin-top: 0; }
  .contact { width: 36px; height: 36px; }
  .contact svg { width: 20px; height: 20px; }
  .actions { flex-wrap: wrap; max-width: 300px; } /* три кнопки — в две линии, надписи не рвутся */
  .actions .button--small { flex: 1 1 auto; padding: 0 10px; font-size: 14px; white-space: nowrap; }
  .tags { align-items: flex-start; }
  .tip { right: auto; left: 0; }
  .tip::before { right: auto; left: 14px; }
  .comm { text-align: left; }
  .drawer {
    grid-column: 1 / -1; margin: 0 0 6px; padding: 10px 12px 12px; border-top: 0;
    border-radius: 10px; background: var(--surface);
  }
}
