/* ===== base ===== */
:root{
  --section-gap:25px;      /* отступ сверху у кнопки "Запустить парсинг" */
  --progress-gap:20px;     /* симметрия вокруг прогресс-бара */
}

body{
  background-color:#f5f7fa;
  font-family:"Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin:0; padding:0;
  display:flex; justify-content:center; align-items:center;
  min-height:100vh; color:#2a2a2a;
}

.container{
  background:#fff; padding:40px 30px; border-radius:12px;
  box-shadow:0 12px 40px rgba(0,0,0,.06);
  width:100%; max-width:750px; box-sizing:border-box;
}

.hidden{display:none;}

input,select,textarea,button{
  width:100%; margin-top:8px; margin-bottom:18px; padding:12px 14px;
  font-size:16px; border-radius:6px; border:1px solid #ccc;
  box-sizing:border-box; transition:all .2s ease-in-out;
}
input:focus,select:focus,textarea:focus{
  border-color:#007bff; outline:none; box-shadow:0 0 5px rgba(0,123,255,.2);
}
textarea{resize:none; min-height:80px; overflow-y:auto;}

button{
  background-color:#007bff; color:#fff; border:none; cursor:pointer;
  font-weight:bold; transition:background-color .3s ease;
}
button:hover{ background-color:#0056b3; }

/* login box (если используется) */
.login-screen{ background:#fff; padding:40px 30px; border-radius:12px; box-shadow:0 12px 40px rgba(0,0,0,.06); width:100%; max-width:400px; box-sizing:border-box; }
.login-screen h2{ margin-bottom:20px; text-align:center; color:#333; }

.tooltip-icon{ display:inline-block; margin-left:6px; color:#007bff; cursor:pointer; font-size:18px; }
.tooltip-text{ display:none; background:#f0f0f0; border-left:3px solid #007bff; padding:10px 14px; font-size:14px; margin-top:6px; margin-bottom:10px; border-radius:5px; color:#333; }

label{ display:block; margin-top:25px; font-weight:600; font-size:15px; }

/* ===== actions & progress ===== */
#startBtn{ margin-top:var(--section-gap); margin-bottom:0; }

#progress-container{ margin:20px; opacity:1; transition:opacity .4s ease; }
.progress-bar{
  width:100%; height:18px; background:#e0e0e0; border-radius:10px; overflow:hidden;
  margin:var(--progress-gap) 0;          /* центр между кнопками */
}
#progress-bar-fill{ height:100%; width:0%; background:#007bff; transition:width .3s ease-in-out; }

#downloadBtn{ margin-top:0; background-color:#28a745; transition:background-color .3s ease, opacity .3s ease; }
#downloadBtn:hover{ background-color:#218838; }

#progress-container.hidden{ opacity:0; height:0; overflow:hidden; margin:0; transition:opacity .4s ease, height .4s ease, margin .4s ease; }

#spinner{ margin-left:10px; animation:spin 1s linear infinite; display:inline-block; }
.spinner{ display:inline-block; width:16px; height:16px; border:2px solid rgba(0,0,0,.2); border-top-color:#000; border-radius:50%; animation:spin .6s linear infinite; vertical-align:middle; margin-left:8px; }
@keyframes spin{ to{ transform:rotate(360deg); }}

/* ===== header cta ===== */
button.logout-btn{ background-color:#dc3545; width:auto; white-space:nowrap; }
button.logout-btn:hover{ background-color:#c82333; }

/* ===== categories grid ===== */
.categories-grid{
  display:grid; grid-template-columns:repeat(3,1fr); gap:12px;
}

/* общая плитка */
.category-card{
  background:#f8f9fa; border:1px solid #ddd; border-radius:6px; padding:12px;
  text-align:center; cursor:pointer; font-size:14px; line-height:1.3;
  display:flex; align-items:center; justify-content:center; min-height:40px;
  transition:all .2s ease; box-sizing:border-box; position:relative;
}
.category-card:hover{
  background:#007bff; color:#fff; transform:translateY(-2px);
  box-shadow:0 4px 12px rgba(0,0,0,.12);
}
.category-card.expandable{ font-weight:600; }

/* открытая родительская */
.category-card.expandable.open{
  background:#f8f9fa; border:1px solid #ddd; border-radius:6px; position:relative; z-index:2; color:#2a2a2a;
}

/* контейнер подкатегорий (рамка) */
.category-card.expandable.open + .subgrid{
  margin-top:0; border:1px solid #ddd; border-radius:6px; background:#f8f9fa;
  padding:12px; position:relative; z-index:1;
}

/* ===== subgrid ===== */
.subgrid{
  grid-column:1 / -1; display:grid; grid-template-columns:repeat(3,1fr);
  gap:12px; margin:10px 0 20px 0; padding:12px; background:#f1f3f5; border-radius:6px; border:1px solid #ddd;
}
.subgrid.hidden{ display:none; }

/* плитка внутри подкатегорий — НЕ меняем текст на белый и НЕ двигаем */
.subgrid .category-card{ background:#fff; border:1px solid #ddd; border-radius:6px; color:#2a2a2a; }
.subgrid .category-card:hover{ background:#f8f9fa; color:#2a2a2a; transform:none; box-shadow:none; }

/* выбор */
.category-card.selected{ background-color:#28a745; color:#fff; border-color:#1e7e34; }

/* ===== responsive (2 колонки на мобилках/планшетах) ===== */
@media (max-width:1024px){
  .categories-grid, .subgrid{ grid-template-columns:repeat(2,1fr); }
}

@media (max-width:600px){
  .container{ padding:24px 16px; }
  /* если шапка "ломится", она сама перенесётся; спец-правил не нужно, т.к. logout-btn шириной auto */
}
/* одинаковый hover для всех карточек */
.subgrid .category-card:hover,
.category-card:hover {
  background:#007bff;
  color:#fff;
  transform:translateY(-2px);
  box-shadow:0 4px 12px rgba(0,0,0,.12);
}

/* эффект нажатия — лёгкое утопление */
.subgrid .category-card:active,
.category-card:active {
  transform:translateY(0);
  box-shadow:0 2px 6px rgba(0,0,0,.2) inset;
}

/* FIX: кнопка "Выйти" не вылезает на мобильных */
@media (max-width: 640px){
  /* разрешаем перенос элементов шапки */
  #config-screen > div:first-child{
    flex-wrap: wrap;           /* кнопка уйдёт на новую строку при нехватке места */
    align-items: flex-start;
  }
  /* заголовок занимает всю строку */
  #config-screen > div:first-child h1{
    flex: 1 1 100%;
    margin: 0 0 10px;
    line-height: 1.2;
  }
  /* кнопка прижимается вправо на своей строке */
  #logout-btn{
    margin-left: auto;
    width: auto;               /* на всякий случай */
    white-space: nowrap;
  }
}



/* === FIX: ровные колонки на мобилках (и вообще) === */

/* колонки всегда ровные: используем minmax(0,1fr) вместо 1fr */
.categories-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.subgrid         { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* на планшетах/мобилках — 2 одинаковых колонки */
@media (max-width: 1024px){
  .categories-grid,
  .subgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* карточки не могут распирать колонку своей “минимальной шириной” */
.category-card {
  min-width: 0;          /* ключевая строчка */
  width: 100%;           /* на всякий случай, чтобы всегда растягивалась */
  overflow-wrap: anywhere;  /* если вдруг попадётся длинное слово */
}



