/* css/calc-page.css */

/* ============================================================
   БАЗА СТРАНИЦЫ
   ============================================================ */

body.calc-page {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

body.calc-page header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
}

.calc-page-main {
  height: 100vh;
  padding: 96px 24px 24px;
  box-sizing: border-box;
  overflow: hidden;
}

.calc-page-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ============================================================
   ЛЕВАЯ КОЛОНКА
   ============================================================ */

.calc-page-left {
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

/* ============================================================
   ЗАГОЛОВОК — ВЫРОВНЕН С chat-head СПРАВА (68px)
   ============================================================ */

.calc-page-left .calc-page-header {
  flex: 0 0 68px;
  height: 68px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
}

.calc-page-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 1px;
}

.calc-page-title span {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.calc-page-sub {
  color: var(--gray);
  font-size: 0.72rem;
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   ЦЕНТРАЛЬНЫЙ БЛОК — РАСТЯГИВАЕТСЯ И АДАПТИРУЕТСЯ
   ============================================================ */

.calc-page-left .calc-form {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;   /* равномерное распределение по высоте */
  gap: 10px;
  overflow: hidden;
}

.calc-page-left .calc-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 1;
  min-height: 0;
}

.calc-page-left .calc-group label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--dark);
  line-height: 1.2;
}

.calc-page-left .calc-group label b {
  color: var(--accent);
  font-size: 0.85rem;
}

.calc-page-left .range {
  width: 100%;
  margin: 0;
  height: 6px;
}

/* ============================================================
   ЧИПЫ — СЖИМАЕМЫЕ
   ============================================================ */

.calc-page-left .chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.calc-page-left .chip {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  text-align: left;
  transition: all .18s ease;
  color: var(--dark);
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  flex-shrink: 1;
}

.calc-page-left .chip:hover {
  border-color: var(--dark);
}

.calc-page-left .chip.active {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
  box-shadow: 0 6px 16px -8px rgba(18, 20, 29, 0.45);
}

.calc-page-left .chip.active small {
  color: rgba(255, 255, 255, 0.7);
  opacity: 1;
}

.calc-page-left .chip small {
  display: block;
  font-weight: 500;
  opacity: 0.55;
  font-size: 0.68rem;
  margin-top: 1px;
}

/* ============================================================
   ИТОГ — ВЫРОВНЕН С chat-foot СПРАВА (84px)
   ============================================================ */

.calc-page-total {
  flex: 0 0 84px;
  height: 84px;
  background: var(--dark);
  color: #fff;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-sizing: border-box;
}

.calc-page-total .label {
  color: rgba(255, 255, 255, .55);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 600;
}

.calc-page-total .sum {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin: 1px 0 1px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.calc-page-total .hint {
  color: rgba(255, 255, 255, .45);
  font-size: 0.65rem;
  line-height: 1.2;
}

.calc-page-total .btn {
  background: #fff;
  color: var(--dark);
  white-space: nowrap;
  padding: 10px 18px;
  font-size: 0.82rem;
  border-radius: 100px;
  flex-shrink: 0;
}

.calc-page-total .btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ============================================================
   ПРАВАЯ КОЛОНКА — ЧАТ
   ============================================================ */

.calc-page-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.chat-inline {
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-inline .chat-head {
  flex: 0 0 68px;
  height: 68px;
  padding: 0 20px;
  background: var(--dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
}

.chat-inline .chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  position: relative;
  flex-shrink: 0;
}

.chat-inline .chat-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border: 2px solid var(--dark);
  border-radius: 50%;
}

.chat-inline .chat-head b {
  display: block;
  font-size: 0.88rem;
}

.chat-inline .chat-head small {
  opacity: .6;
  font-size: 0.72rem;
}

.chat-inline .chat-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  background: #f6f4f1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-inline .msg {
  font-size: 0.88rem;
  padding: 10px 14px;
}

.chat-inline .chat-foot {
  flex: 0 0 84px;
  height: 84px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
  box-sizing: border-box;
}

.chat-inline .chat-foot input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 100px;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  transition: .2s;
  min-width: 0;
}

.chat-inline .chat-foot input:focus {
  border-color: var(--accent);
}

.chat-inline .chat-foot button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: .2s;
  flex-shrink: 0;
}

.chat-inline .chat-foot button:hover {
  background: var(--accent);
}

.chat-inline .chat-foot button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.chat-inline .calc-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================================
   АНИМАЦИЯ ПОДСВЕТКИ
   ============================================================ */

.range.flash-field,
.chip.flash-field {
  animation: fieldFlash 0.9s ease;
}

@keyframes fieldFlash {
  0%   { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0); }
  30%  { box-shadow: 0 0 0 6px rgba(255, 107, 53, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0); }
}

/* ============================================================
   СКРОЛЛБАР (только у чата)
   ============================================================ */

.chat-inline .chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-inline .chat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */

@media (max-width: 1024px) {
  body.calc-page {
    height: auto;
    overflow: auto;
  }

  .calc-page-main {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 96px 16px 24px;
  }

  .calc-page-grid {
    grid-template-columns: 1fr;
    height: auto;
    gap: 16px;
  }

  .calc-page-left,
  .calc-page-right {
    height: auto;
  }

  .chat-inline {
    height: 500px;
  }
}

@media (max-width: 640px) {
  .calc-page-main {
    padding: 88px 12px 16px;
  }

  .calc-page-left .calc-page-header {
    padding: 0 18px;
    flex: 0 0 60px;
    height: 60px;
  }

  .calc-page-title {
    font-size: 0.92rem;
  }

  .calc-page-sub {
    font-size: 0.68rem;
  }

  .calc-page-left .calc-form {
    padding: 12px 18px;
    gap: 10px;
  }

  .calc-page-total {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    flex: 0 0 auto;
    padding: 14px 18px;
    gap: 10px;
  }

  .calc-page-total .btn {
    width: 100%;
  }

  .chat-inline {
    height: 60vh;
    min-height: 400px;
  }
}

/* Низкие экраны — ещё сильнее сжимаем */
@media (max-height: 820px) and (min-width: 1025px) {
  .calc-page-main {
    padding: 84px 20px 16px;
  }

  .calc-page-left .calc-page-header,
  .chat-inline .chat-head {
    flex: 0 0 60px;
    height: 60px;
  }

  .calc-page-title {
    font-size: 0.95rem;
  }

  .calc-page-sub {
    font-size: 0.68rem;
  }

  .calc-page-left .calc-form {
    padding: 12px 22px;
    gap: 8px;
  }

  .calc-page-left .calc-group {
    gap: 5px;
  }

  .calc-page-left .calc-group label {
    font-size: 0.78rem;
  }

  .calc-page-left .chip {
    padding: 7px 11px;
    font-size: 0.78rem;
  }

  .calc-page-left .chip small {
    font-size: 0.64rem;
  }

  .calc-page-total,
  .chat-inline .chat-foot {
    flex: 0 0 72px;
    height: 72px;
  }

  .calc-page-total .sum {
    font-size: 1.25rem;
  }

  .calc-page-total .hint {
    font-size: 0.6rem;
  }
}

/* Совсем низкие (768px) — минимальный режим */
@media (max-height: 770px) and (min-width: 1025px) {
  .calc-page-left .calc-page-header,
  .chat-inline .chat-head {
    flex: 0 0 56px;
    height: 56px;
  }

  .calc-page-left .calc-form {
    padding: 10px 22px;
    gap: 6px;
  }

  .calc-page-left .calc-group {
    gap: 4px;
  }

  .calc-page-left .chip {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .calc-page-left .chip small {
    font-size: 0.6rem;
  }

  .calc-page-total,
  .chat-inline .chat-foot {
    flex: 0 0 64px;
    height: 64px;
  }
}