.calculator {
  background-color: #ffffff;
}
.calculator-page {
  padding-top: 10px;
  overflow-x: hidden;
}
/* --- Заголовок --- */
.calc-header {
  margin-bottom: clamp(20px, 4vw, 30px);
}
.calc-title {
  font-size: clamp(20px, 4vw, 32px);
  margin: 0 0 10px 0;
  font-weight: 700;
  color: #333333;
}
.calc-subtitle {
  color: #666666;
  margin: 0;
  font-size: 16px;
}

/* --- Сітка калькулятора --- */
.calc-wrapper {
  padding-bottom: 50px;
}
.calc-main-container {
  display: flex;
  gap: 30px;
  align-items: flex-start;
}
.calc-column-left {
  flex: 1;
  max-width: 500px;
}
.calc-column-right {
  flex: 1;
  min-width: 0;
}

/* --- Секції "параметри рулону", "напрямок малюнку", Деталі --- */
.calc-section {
  background: #f8f8f8;
  padding: 10px;
  margin-bottom: clamp(15px, 4vw, 30px);
  border-radius: 10px;
}
.calc-section-title {
  font-size: 20px;
  margin: 0 0 20px 0;
  font-weight: 600;
  color: #333333;
}

/* --- Поля вводу --- */
.calc-form-grid {
  display: flex;
  gap: 20px;
  margin-bottom: 0;
}
.calc-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.calc-input-group label {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #333333;
}
.calc-input {
  padding: 10px;
  border: 1px solid #cccccc;
  border-radius: 6px;
  font-size: 16px;
  width: 100%;
  color: #333333;
  transition: border-color 0.2s;
}
.calc-input:focus {
  border-color: #790000; /* Ваш акцентний колір */
  outline: none;
}
.calc-input.error {
  border-color: #ff4d4d;
  background-color: #fff5f5;
}
.calc-hint {
  font-size: 12px;
  color: #666666;
  margin-top: 12px;
}
/* --- Стилі для стрілок у кнопках Вздовж -Поперек --- */
.arrow {
  font-size: 18px; /* Базовий розмір */
  color: #333333;
  display: inline-block;
  margin-right: 5px;
  transition: color 0.2s;
}

.arrow.vertical {
  transform: rotate(
    90deg
  ); /* Обертає стрілку вниз, роблячи її "вертикальною" */
}

/* Підказка на рівні секції (поза calc-input-group) */
.full-width {
  width: 100%;
}
/* ================== Inline label + dropdown ================== */

.calc-input-group.inline {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* label без переносу */
.calc-input-group.inline label {
  margin-bottom: 0;
  white-space: nowrap;
}

/* фіксована ширина select */
.calc-input-group.inline .calc-input {
  width: 140px;
  padding-right: 40px; /* місце під стрілку */
}

/* Кастомна стрілка select (опціонально) */
select.calc-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  cursor: pointer;
}

/* ===== стилізація Toggle-кнопки зі стрілками"напрямлення руху"===== */
.direction-control {
  display: flex;
  gap: 10px;
}

.direction-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  padding: 12px 16px;
  min-width: 120px;

  background-color: #f7f5e9;
  color: #1f3f7a;

  border: 1px solid #c7daf8;
  border-radius: 6px;

  font-size: 16px;
  font-weight: 500;
  line-height: 1;

  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

/* Активний стан */
.direction-btn.active {
  background-color: #c7daf8;
  border-color: #9fbdf0;
}

/* Hover */
.direction-btn:hover:not(.active) {
  background-color: #e3edfc;
}

/* Натискання */
.direction-btn:active {
  background-color: #9fbdf0;
}
/* ========================================================== */

/* --- Таблиця деталей --- */
.calc-parts-header {
  display: flex;
  gap: 10px;
  font-size: 16px;
  color: #666666;
  margin-bottom: 10px;
  text-align: center;
}
.calc-part-row {
  display: flex;
  gap: clamp(5px, 2vw, 10px);
  margin-bottom: 10px;
  align-items: center;
}
.calc-col-name,
.calc-col-size,
.calc-col-qty,
.calc-part-row {
  min-width: 0;
}
/* Ширина колонок */
.calc-col-name {
  flex: 2;
}
.calc-col-size {
  flex: 1;
  max-width: 110px;
}
.calc-col-qty {
  width: 60px;
  text-align: center;
}
.calc-col-del {
  width: 30px;
  display: flex;
  justify-content: center;
}

/* Стилізація інпутів у таблиці */
.calc-part-row .calc-input {
  width: 100%;
  min-width: 0;
  padding: clamp(4px, 2vw, 8px);
  text-align: center;
}
.calc-part-row .part-name {
  text-align: left;
}

/* Показуємо спіннер для числових полів */
.calc-part-row input[type="number"] {
  appearance: textfield;
}

.calc-part-row input[type="number"]::-webkit-outer-spin-button,
.calc-part-row input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: inner-spin-button;
  appearance: inner-spin-button;
  opacity: 1;
}

/* Кнопки */
.calc-btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: #ff4d4d;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.calc-btn-delete:hover {
  color: #790000;
}
/* =======Кнопка Додати ще деталь======= */
.calc-btn-add {
  background: #c7daf8; /* Ваш акцентний колір */
  color: #333;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 16px;
  margin-top: 10px;
  transition: background-color 0.2s;
}
.calc-btn-add:hover {
  background-color: #9fbdf0; /* Трохи темніший для ховера */
}
/* Стиль для знака "+" в кнопці  */
.plus-icon {
  font-size: 34px; /* Змініть на бажаний розмір, наприклад, 30px для ще більшого */
  display: inline-block; /* Допомагає з вирівнюванням */
  margin-right: 5px; /* Відступ від тексту */
  color: #333333; /* Колір, сумісний з вашим дизайном (можна змінити) */
  transition: color 0.2s; /* Плавний перехід, як у полів вводу */
  line-height: 1; /* Важливо: скидає line-height, щоб не впливало на висоту кнопки */
  vertical-align: middle; /* Вирівнює знак вертикально */
}

.calc-actions {
  display: flex;
  gap: 15px;
  margin-top: clamp(15px, 4vw, 30px);
}
.calc-btn-primary {
  background: #790000; /*  акцентний колір */
  color: #ffffff;
  border: none;
  padding: 14px 25px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;

  transition: background-color 0.2s;
}
.calc-btn-primary:hover {
  background-color: #5e0000; /* Трохи темніший для ховера */
}

/* ========================= ПРАВА КОЛОНКА: ВІЗУАЛІЗАЦІЯ =============== */

.calc-visual-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0;
  padding: 20px 2px 0 20px;
  border-radius: 10px;
  margin-bottom: 16px;
}

/* ===========Верхня частина ============ */
/* Сцена візуалізації */
.calc-visual-stage {
  display: flex;
  align-items: stretch;
  height: 350px;
}

/* ================верхня горизонтальна лінійка ========== */
.calc-ruler-top {
  position: absolute; /* позиціонуємо над canvas */
  top: 0; /*  по вертикалі */
  left: 0; /* починається після рулону (ширина .calc-roll-graphic) */
  right: 60px; /* закінчується на правому краю */
  width: auto; /* ширина мінус ширина рулону */
  max-width: 100%; /* не виходить за межі */
  display: flex;
  justify-content: center; /* центр */
  align-items: center;
  height: 20px;
  padding: 0 20px; /* відступ з боків для безпеки */
  box-sizing: border-box;
  gap: clamp(12px, 3vw, 20px);
}

/* Ліва/права стрілка */
.calc-arrow-left,
.calc-arrow-right {
  flex: 1; /* розширюється до країв */
  max-width: none; /* без обмеження ширини */
  min-width: clamp(70px, 10vw, 100px);
  height: 1px; /* товщина лінії */
  background-color: #333;
  position: relative;
}

/* Трикутник на кінці лівої стрілки */
.calc-arrow-left::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 6px solid #333;
}

/* Трикутник на кінці правої стрілки */
.calc-arrow-right::before {
  content: "";
  position: absolute;
  top: -3px;
  right: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #333;
}

/* ================права вертикальна лінійка ========== */

.calc-ruler-left {
  padding-left: 0;
  padding-right: 20px;
  width: 20px;
  position: absolute;
  top: 20px; /* відступ від верху контейнера */
  bottom: 20px; /* відступ від низу контейнера */
  left: 0; /* прилягає до правого краю */
  right: auto;
  display: flex;
  flex-direction: column; /* вертикальне розташування */
  align-items: center; /* центр по горизонталі */
  justify-content: space-between; /* рівномірний розподіл стрілок і цифри */
  height: auto; /* висота підлаштовується під top/bottom */
  z-index: 10; /* щоб бути над полотном тканини */
}

/* Вирівнювання центру цифри */
.ruler-vertical-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 🔥 ВАЖЛИВО */
  height: 100%; /* Займає всю висоту батьківського контейнера */
  gap: 12px;
}

/* Центр цифри */
/* Вирівнювання контейнера */
.calc-ruler-left .calc-ruler-value {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1.2;
}

/* 🔥 Поворот всього тексту (число + см) */
.calc-ruler-left #display-roll-width-visual {
  display: inline-block;
  transform: rotate(-90deg); /* повертаємо весь блок вертикально */
  transform-origin: center;
  white-space: nowrap; /* не переносимо на новий рядок */
}

/* Стрілки вертикальної лінійки */
.calc-arrow-up,
.calc-arrow-down {
  flex: 1; /* розширюється до країв */
  max-height: none; /* без обмеження висоти */
  min-height: 100px; /* мінімальна висота */
  width: 1px; /* товщина лінії */
  background-color: #333;
  position: relative;
  margin: 0 auto; /* центруємо */
}

.calc-arrow-up {
  margin-bottom: 12px; /* відступ від цифри */
}

.calc-arrow-down {
  margin-top: 12px; /* відступ від цифри */
}

/* Верхня стрілка: трикутник */
.calc-arrow-up::before {
  content: "";
  position: absolute;
  left: -4px; /* центруємо по горизонталі */
  top: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid #333; /* стрілка вниз від верху */
}

/* Нижня стрілка: трикутник */
.calc-arrow-down::before {
  content: "";
  position: absolute;
  left: -4px; /* центруємо по горизонталі */
  bottom: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid #333; /* стрілка вверх від низу */
}

/* =========Графіка рулону ================*/
.calc-roll-graphic {
  width: 60px;
  /* Градієнт для ефекту об'єму циліндра */
  background: linear-gradient(90deg, #4a0000 0%, #790000 55%, #4a0000 100%);
  border-radius: 4px 0 0 4px;
  position: relative;
  z-index: 2;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
}

/* Верхній зріз рулону */
.calc-roll-graphic::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);

  width: 92%;
  height: 14px;

  background: radial-gradient(
    ellipse at center,
    #8f0000 0%,
    #790000 55%,
    #4a0000 100%
  );

  border-radius: 50%;
  box-shadow:
    inset 0 3px 4px rgba(255, 255, 255, 0.25),
    inset 0 -3px 6px rgba(0, 0, 0, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.25);
}
/* нижній зріз рулону */
.calc-roll-graphic::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  height: 14px;

  background: radial-gradient(
    ellipse at center,
    #5a0000 0%,
    #4a0000 55%,
    #220000 100%
  );

  border-radius: 50%;
  box-shadow:
    inset 0 3px 4px rgba(255, 255, 255, 0.15),
    inset 0 -3px 6px rgba(0, 0, 0, 0.45),
    0 -2px 4px rgba(0, 0, 0, 0.3);
}

/* =========Полотно тканини ================ */
.calc-fabric-plane {
  flex: 1;
  background-color: #790000; /* темний фон */
  position: relative;
  overflow-x: auto; /* Дозволяємо прокрутку для синхронізації */
  overflow-y: hidden;
  border: 1px solid #4a0000; /* рамка */
  scrollbar-width: none; /* Приховуємо стандартну прокрутку в Firefox */
  -ms-overflow-style: none; /* Приховуємо стандартну прокрутку в IE/Edge */

  display: block; /*  */
}

.calc-fabric-plane::-webkit-scrollbar {
  display: none; /* Приховуємо стандартну прокрутку в Chrome/Safari */
}

/* Вертикальні лінії (напрямок "Вздовж" - vertical) */
.calc-fabric-plane.direction-vertical {
  background-image: repeating-linear-gradient(
    to bottom,
    /* Напрямок градієнта вертикально */ rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.1) 2px,
    transparent 2px,
    transparent 10px
  );
}

/* Горизонтальні лінії (напрямок "Поперек" - horizontal) */
.calc-fabric-plane.direction-horizontal {
  background-image: repeating-linear-gradient(
    to right,
    /* Напрямок градієнта горизонтально */ rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.1) 2px,
    transparent 2px,
    transparent 10px
  );
}

/* ====== Горизонтальна полоса прокрутки  ========== */
/* ====== Горизонтальна полоса прокрутки ========== */
.calc-horizontal-scrollbar {
  margin-left: 0;
  margin-right: 0; /* Змінено: прибираємо фіксований відступ */
  margin-top: 10px;
  height: 17px;
  width: 100%; /* Змінено: ширина на всю доступну ширину */
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
}

/* Стилі для кнопок прокручування */
.calc-scrollbar-btn {
  flex-shrink: 0;
  width: 20px;
  height: 17px;
  padding: 0;
  border: 1px solid #c0c0c0;
  background-color: #e8e8e8;
  color: #333;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.2s,
    border-color 0.2s;
  box-sizing: border-box;
}

.calc-scrollbar-btn:hover {
  background-color: #d0d0d0;
  border-color: #a0a0a0;
}

.calc-scrollbar-btn:active {
  background-color: #b8b8b8;
}

.calc-scrollbar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.calc-scrollbar-track {
  flex: 1;
  min-width: 0;
  height: 13px;
  background-color: #e0e0e0;
  border: 1px solid #c0c0c0;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  box-sizing: border-box;
  /* Додаємо внутрішні відступи, щоб повзунок не вилазив за межі кнопок */
  padding-left: 20px; /* Додано: місце для лівої кнопки */
  padding-right: 20px; /* Додано: місце для правої кнопки */
}

.calc-scrollbar-thumb {
  height: 11px;
  background-color: #c0c0c0;
  border: 1px solid #808080;
  border-radius: 2px;
  position: absolute;
  left: 0;
  top: 1px;
  min-width: 20px;
  max-width: calc(
    100% - 40px
  ); /* Додано: не більше ширини треку мінус відступи */
  cursor: grab;
  transition: background-color 0.2s;
  box-sizing: border-box;
}

.calc-scrollbar-thumb:hover {
  background-color: #a0a0a0;
}

.calc-scrollbar-thumb:active {
  cursor: grabbing;
  background-color: #909090;
}

/* Додатковий клас, коли повзунок потрібно сховати */
.calc-scrollbar-thumb-hidden {
  display: none;
}

/* ======Приклади деталей на полотні==== */
.part-demo {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.15); /* Прозорий білий */
}

/* Залишки тканини на полотні */
.waste-demo {
  position: absolute;
  border: 2px dashed #aaaaa9;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(252, 251, 250, 0.1); /* Прозорий помаранчевий */
}

.waste-text {
  color: #e0e0e0;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ============================================================ */
/* --- Блок підсумків --- */
.calc-summary-box {
  background: #ffffff;
  max-width: 500px;
  border-radius: 10px;
  padding: 25px;
}
.calc-summary-title {
  font-size: 20px;
  letter-spacing: 1px;
  margin: 0 0 20px 0;
  font-weight: 700;
  color: #333333;
}
.calc-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  font-size: 18px;
  color: #333333;
}
.calc-highlight {
  font-size: 20px;
  color: #333333;
}

.calc-summary-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* Базові стилі для кнопки "Експорт в PDF" та  "Поділитися" */
.calc-summary-actions button {
  padding: 12px 26px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: #333333;
  border: none; /* Додано, щоб прибрати дефолтну рамку */
  transition:
    background 0.25s,
    transform 0.15s;
}

/* PDF кнопка */
.action-btn--pdf {
  background: #c7daf8;
}

.action-btn--pdf:hover {
  background: #a9c4f2;
}

.action-btn--pdf:active {
  background: #4a0000;
  transform: translateY(0);
}

/* Share кнопка */
.action-btn--share {
  background: #c7daf8;
}

.action-btn--share:hover {
  background: #a9c4f2;
}

.action-btn--share:active {
  background: #4a0000;
  transform: translateY(0);
}

.calc-btn-secondary {
  background: #e0e0e0;
  color: #333333;
  border: none;
  padding: 14px 25px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}
.calc-btn-secondary:hover {
  background: #d0d0d0;
}

/* ======адаптив==== */

/* кнопки одна під одною */
@media (max-width: 419px) {
  /* == кнопки Розрахувати схему/Очистити  */
  .calc-actions {
    flex-direction: column; /* одна під одною */
  }

  .calc-btn-primary,
  .calc-btn-secondary {
    width: 100%; /* на всю ширину */
  }
  .calc-btn-add {
    display: block;
    margin: 10px auto 0 auto; /* авто по боках = центр */
  }
  /* == кнопки Експорт та Поділитись */
  .calc-summary-actions {
    flex-direction: column;
  }

  .calc-summary-actions button {
    width: 100%;
  }
}

@media (max-width: 435px) {
  .calc-ruler-value {
    font-size: 12px; /* менші цифри */
    gap: 4px; /* менше відстані між цифрами і "см" */
    padding: 0 5px; /* менші відступи всередині контейнера */
    width: calc(100% - 10px); /* ширина під маленькі екрани */
    text-align: center;
  }

  #display-layout-width {
    font-size: 14px; /* цифри трохи більші ніж "см" */
  }
}
@media (max-width: 480px) {
  .calc-input-group.inline {
    flex-direction: column;
    align-items: stretch;
  }

  .calc-input-group.inline label {
    white-space: normal;
  }

  .calc-input-group.inline .calc-input {
    width: 100%;
  }
}
@media (max-width: 768px) {
  /* Забираємо спінери лише для ширини та довжини */
  input.part-width::-webkit-inner-spin-button,
  input.part-width::-webkit-outer-spin-button,
  input.part-length::-webkit-inner-spin-button,
  input.part-length::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  input.part-width,
  input.part-length {
    -moz-appearance: textfield; /* Для Firefox */
  }

  .part-name::placeholder {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 1100px) {
  .calc-main-container {
    flex-direction: column;
  }

  .calc-column-left,
  .calc-column-right {
    max-width: 100%;
    width: 100%;
  }
  .calc-visual-wrapper {
    max-width: 100%;
  }
}
