/* css/components/keyword-tools.css — Правила ключевых слов, меню Tools над Keywords, боковая панель Batch Tools.
   Порядок подключения всех стилей задан в layout/head.php — он важен. */
/* ===== KEYWORD RULES (всегда открыт, каждый инструмент со своей строки) ===== */

.keyword-rules-panel {
  margin-top: 0px;
  padding-top: 14px;
  /* border-top: 1px solid rgba(124, 92, 255, 0.15); */
}

.kr-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 10px;
}

.kr-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 14px;
}

/* Keyword Format и чекбоксы — на всю ширину, под тройкой Include/Exclude/Trademarks */
.kr-body .kr-field-wide,
.kr-body .kr-checks {
  grid-column: 1 / -1;
}

/* Include/Exclude/Trademarks — одна строка, одинаковая высота (не
   растёт под контент по-отдельности, иначе три поля с разной длиной
   текста визуально "прыгают" друг относительно друга). !important
   перебивает и field-sizing:content ниже, и инлайн-height, который на
   input ставит autoResizeTextarea() в settings.js. */
.kr-field-row textarea {
  field-sizing: fixed !important;
  height: 70px !important;
  overflow-y: auto !important;
  resize: none !important; /* фиксированная высота — ручка ресайза только путала бы */
}

@media (max-width: 760px) {
  .kr-body { grid-template-columns: 1fr; }
}

.kr-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
	width: 100%;   /* перекрывает базовый label { width: fit-content } */
}

.kr-field textarea,
.kr-field select,
.kr-field input[type="text"],
.cp-limits-grid input[type="number"] {
  width: 100%;
	min-width: 166px;
  box-sizing: border-box;     /* ключевое: padding теперь входит в 100%, а не добавляется сверху */
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(124, 92, 255, 0.2);
  background: linear-gradient(180deg, rgba(20,28,45,0.95), rgba(12,18,32,0.98));
  color: #ffffff;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, height .1s ease;
}

.kr-field textarea {
  /* resize: none;      /* высота теперь управляется JS, ручное растягивание больше не нужно */
  overflow: hidden;
	field-sizing: content;
  max-height: 300px; /* по вкусу */
}

/* #spShowDescription (окно Show Profiles) — resize:vertical
   само по себе НЕ ограничивает растягивание одной осью, пока активен
   field-sizing:content (унаследован от .kr-field textarea выше) — то же
   самое уже задокументировано у #universalCategoriesModal textarea ниже:
   field-sizing:content и resize конфликтуют, надо явно вернуться на
   field-sizing:fixed, чтобы resize:vertical реально работал (проверено на
   живом сервере — без этого поле тянулось во все стороны). */
#spShowDescription {
  field-sizing: fixed;
  resize: vertical;
  overflow: auto;
  height: 70px;
  min-height: 50px;
  max-height: 400px;
}

.kr-field select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.kr-field textarea:focus,
.kr-field select:focus {
  border-color: rgba(124, 92, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.kr-checks {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.kr-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.kr-checkbox input {
  accent-color: #7c5cff;
  cursor: pointer;
}


/* ===== KEYWORD TOOLBAR (кнопка ⚙ Tools над textarea Keywords) ===== */

.kw-toolbar {
  position: relative;
  align-self: flex-start;
  margin-bottom: 4px;
}

/* .field .kw-tools-btn (0,2,0) — .field button (строка ~1396, специфичность
   0,1,1: класс+элемент) иначе перебивает border/background/width отсюда,
   т.к. .kw-toolbar лежит внутри .field вместе с кнопкой копирования (⧉),
   для которой .field button и задуман. Та же ловушка со специфичностью,
   что уже не раз чинили в этом заходе (.puter-stats-btn, .kr-field textarea) —
   именно из-за неё "Tools" выглядела квадратной кнопкой-пилюлей вместо
   обычной текстовой ссылки. */
.field .kw-tools-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--text-link);
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease;
}

.field .kw-tools-btn:hover {
  background: none;
  color: #ffffff;
  box-shadow: none;
}

/* Пункты меню — та же ловушка, что и у .kw-tools-btn выше: .field button
   (0,1,1, ниже по файлу) перебивал им width:100% -> 40px и background:none
   -> голубую заливку, из-за чего фон был виден только вокруг иконки.
   Поднимаем до 0,2,1. */
.field .kw-tools-menu button {
  width: 100%;
  background: none;
  border-radius: 6px;
  color: #e6e6e6;
}
.field .kw-tools-menu button:hover {
  background: rgba(124, 92, 255, 0.15);
  color: #ffffff;
  box-shadow: none;
}

/* Обёртка иконка+текст (Lucide SVG вместо эмодзи-префикса) — единое
   выравнивание везде, где раньше был просто "emoji Текст" инлайном.
   currentColor в самой SVG уже наследует цвет — здесь только раскладка. */
.ic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: -3px;
}
.ic svg {
  flex-shrink: 0;
}

.kw-tools-btn .kw-icon {
  font-size: 12px;
  line-height: 1;
}

.kw-caret {
  font-size: 9px;
  line-height: 1;
  transition: transform 0.15s ease;
  color: var(--text-dim);
}

.kw-tools-btn.open .kw-caret {
  transform: rotate(180deg);
}

.kw-tools-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: max-content;
  min-width: 200px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(124, 92, 255, 0.2);
  background: linear-gradient(180deg, rgba(20,28,45,0.98), rgba(10,16,28,0.98));
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 0 20px rgba(124,92,255,0.1);
  animation: kwMenuIn 0.15s ease;
  transform-origin: top left;
}

@keyframes kwMenuIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.kw-tools-menu.open { display: block; }

.kw-tools-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin: 2px 0;
  text-align: left;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  color: #e6e6e6;
  font-size: 12.5px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease;
}

.kw-tools-menu button:hover {
  background: rgba(124, 92, 255, 0.15);
  color: #ffffff;
}

.kw-tools-menu .kw-icon {
  flex-shrink: 0;
  width: 15px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
}

.field-change-info {
  font-size: 11px;
  color: var(--success);
  margin-top: 2px;
  min-height: 14px;
}


/* ===== BATCH TOOLS (боковая панель, прозрачная) ===== */

.batch-tools-panel {
  position: fixed;
  right: -340px;
  top: 0;
  height: 100%;
  width: 340px;
  background: linear-gradient(180deg, rgba(20, 28, 45, 0.99), rgba(10, 16, 28, 0.99));
  border-left: 1px solid rgba(124, 92, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: right 0.25s ease;
  z-index: 1000;
  padding: 20px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 92, 255, 0.4) transparent;
}

.batch-tools-panel.open { right: 0; }

.btp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.01em;
  margin: -20px -24px 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(124, 92, 255, 0.12);
}

.btp-header button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(124, 92, 255, 0.15);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.btp-header button:hover {
  background: rgba(255, 92, 122, 0.1);
  border-color: rgba(255, 92, 122, 0.3);
  color: #ff5c7a;
}

.btp-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* :not(.stats-account-body) — эта общая раскладка "список кнопок на всю
   ширину" сделана под Batch Tools/CSV Export/History (простые списки
   действий). Панель CVB Balance/Puter Account (.stats-account-body,
   см. pages/modals/stats-panel.php) переиспользует .btp-body только ради
   отступов/скролла, но содержит СВОИ кнопки со своей вёрсткой
   (.puter-stats-btn/.pro-token-clear-btn/.pro-resend-link) — без :not()
   это правило перебивало их ширину/выравнивание (width:100% гнул
   маленькую кнопку-глаз на всю ширину, text-align:left сдвигал
   "Resend it" от центра). :not(.custom-platform-manage-btn) — та же
   ловушка для кнопки-шестерёнки рядом с select (Custom Platform/CSV
   Preset, см. .puter-stats-btn.custom-platform-manage-btn ниже): у
   селектора здесь есть тег button, специфичность (0,2,1) выше, чем у
   (0,2,0) — без исключения это правило перебивало фиксированный
   квадрат 42×42, растягивая кнопку на всю ширину и сжимая select
   до иконки-каретки. */
.btp-body:not(.stats-account-body) button:not(.custom-platform-manage-btn) {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(124, 92, 255, 0.15);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btp-body button .kw-icon {
  flex-shrink: 0;
  width: 15px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
}

.btp-body:not(.stats-account-body) button:not(.custom-platform-manage-btn):hover {
  border-color: rgba(0, 229, 255, 0.3);
  color: #ffffff;
  background: rgba(124, 92, 255, 0.12);
}

.btp-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 4px;
}

