/* ================== ШРИФТ ================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');

/* ================== ГЛОБАЛЬНЫЕ ФИКСЫ ================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

/* ================== BODY ================== */
body {
    font-family: 'JetBrains Mono', monospace;
    background: linear-gradient(to bottom, #2b2b2b 0%, #1e1e1e 100%);
    color: #e0d7c6;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* ================== КОНТЕЙНЕР ================== */
.container {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 100rem;
    height: 100%;
    margin: 0 auto;
    padding: 1rem 1rem;
    background: rgba(40, 40, 40, 0.9);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    overflow-x: hidden; /* ЖЁСТКО запрещаем вылет */
}

/* ================== ВКЛАДКИ ================== */
.top-tabs {
    display: flex;
    margin-bottom: 1rem;
    gap: 8px;
    flex: none;
}

.tab-button {
    flex: 1;
    padding: 10px;
    font-size: 1.1rem;
    color: #e0d7c6;
    background: rgba(40, 40, 40, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.05);
    box-shadow:
        0 0 12px 4px rgba(224, 215, 198, 0.7),   /* основне свічення */
        0 0 4px 2px rgba(224, 215, 198, 0.4);    /* додатковий блік */
}

.tab-button.active {
    background: rgba(224, 215, 198, 1);
    color: rgba(0, 0, 0, 0.8);
}

.tab-button.active:hover {
    background: rgba(224, 215, 198, 0.9);
    box-shadow:
        0 0 12px 4px rgba(0, 0, 0, 0.7),   /* основне свічення */
        0 0 4px 2px rgba(9, 9, 9, 0.4);    /* додатковий блік */
}

.tab-content {
  flex: 1;
  display: none;
  overflow: hidden;
}

.tab-content.active {
  display: block;
}

#map-view {
  position: relative;
}

#map {
  height: 100%;
  min-height: 500px;
}

/* ================== TG TOAST ================== */
#tg-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 360px;
  background: #1e2a38;
  color: #e0e0e0;
  padding: 16px 48px 16px 16px;     /* Збільшений правий відступ під хрестик */
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  z-index: 1500;
  display: none;
  font-size: 1rem;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  user-select: none;
  word-wrap: break-word;
}

#tg-toast a {
  color: #4db8ff;
  text-decoration: underline;
  font-weight: 600;
}

/* Хрестик */
#tg-toast span#tg-toast-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.2rem;
  line-height: 1;
  color: #ccc;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
  transition: all 0.18s ease;
  z-index: 2;                      /* на випадок накладання */
}

#tg-toast span#tg-toast-close:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.25);
  transform: scale(1.2);
}

/* ================== DATE SWITCH ================== */
.date-switch {
  position: absolute;
  top: auto;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.5);
  padding: 5px;
  border-radius: 5px;
  z-index: 1000;
}

.date-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.2em;
  cursor: pointer;
}

.map-date {
  margin: 0 10px;
  font-weight: bold;
}

/* ================== ТАБЛИЦЯ ================== */
#table-view {
  overflow: auto;
}

.houses-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;        /* КРИТИЧНО */
    border-collapse: collapse; /* КРИТИЧНО */
}

/* ===== фіксуємо ширину колонок ===== */
.houses-table th:nth-child(1),
.houses-table td:nth-child(1) { width: 45%; }

.houses-table th:nth-child(2),
.houses-table td:nth-child(2) { width: 15%; }

.houses-table th:nth-child(3),
.houses-table td:nth-child(3) { width: 20%; }

.houses-table th:nth-child(4),
.houses-table td:nth-child(4) { width: 20%; }

/* ================== РЯДКИ ================== */
.houses-table tr {
    font-size: 0.85em;
    height: 2rem;
}

/* hover БЕЗ transform */
.houses-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ================== КОМІРКИ ================== */
.houses-table th,
.houses-table td {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;

    /* ===== САМЫЙ ВАЖНЫЙ БЛОК ===== */
    min-width: 0;                 /* ОБЯЗАТЕЛЬНО */
    overflow-wrap: anywhere;      /* ОБЯЗАТЕЛЬНО */
    word-break: break-word;
    hyphens: auto;
    white-space: normal;
}

/* ================== ПОШУК ================== */
#searchInput {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: inherit;
    font-family: inherit;
    border-radius: 4px;
}

#searchInput:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
}

/* ================== СМАРТФОН ================== */
@media (max-width: 786px) and (orientation: portrait) {
    body {
        font-size: 0.9rem;  /* подбираем удобный размер для мобильных */
    }

    .container {
        width: 96%;        /* растягиваем почти на весь экран */
        max-width: 96%;
        padding: 1rem 0.5rem;
        margin: 0 auto;
    }

    .tab-button {
        padding: 6px 4px;    /* Зменшуємо внутрішні відступи (верх/низ та ліво/право) */
        font-size: 0.8rem;   /* Зменшуємо розмір шрифту */
    }

    .houses-table {
        width: 100%;
        font-size: 0.85rem;   /* таблица чуть меньше основного текста */
    }

    .houses-table th,
    .houses-table td {
        padding: 0.1rem 0.1rem 0.1rem 0.2rem;
    }

#tg-toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
    padding: 20px 60px 20px 20px;   /* ще більше місця праворуч */
    font-size: 1.1rem;
    line-height: 1.5;
    border-radius: 16px;
  }

  #tg-toast span#tg-toast-close {
    top: 10px;
    right: 14px;
    font-size: 1.6rem;              /* помітно більший */
    padding: 6px 12px;
    background: rgba(0,0,0,0.3);
  }

  /* Додатковий захист від перекриття */
  #tg-toast > *:first-child {
    padding-right: 20px;            /* запас для довгих рядків */
  }
}