/* AdGate — Стили админ-панели */

:root {
  --bg: #1a1a1a;
  --card: #252525;
  --card-hover: #2e2e2e;
  --accent: #ff9f43;
  --accent-hover: #e68a2e;
  --green: #4ecca3;
  --yellow: #f9a825;
  --red: #e94560;
  --blue: #3498db;
  --text: #eee;
  --text-muted: #999;
  --border: #363636;
  --radius: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

/* === Login === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px;
  width: 380px;
  max-width: calc(100% - 30px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-card h1 {
  color: var(--accent);
  margin-bottom: 5px;
  font-size: 1.8em;
}
.subtitle {
  color: var(--text-muted);
  margin-bottom: 25px;
}

/* === Layout === */
.layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  background: var(--card);
  padding: 20px 0;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 10px 20px 25px;
  font-size: 1.4em;
  font-weight: 700;
  color: var(--accent);
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--text-muted);
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--card-hover);
  color: var(--text);
  border-left-color: var(--accent);
}
.sidebar-nav a .icon {
  font-size: 1.1em;
  width: 20px;
  text-align: center;
}
.main {
  margin-left: 240px;
  padding: 30px;
  flex: 1;
  width: calc(100% - 240px);
}

/* === Components === */
.page-title {
  font-size: 1.6em;
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-title .btn,
.page-title button,
.page-title input,
.page-title select {
  font-size: 17px;
  padding: 4px 10px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 25px;
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 5px;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.9em;
}
.stat-card.green .stat-value {
  color: var(--green);
}
.stat-card.red .stat-value {
  color: var(--red);
}
.stat-card.blue .stat-value {
  color: var(--blue);
}
.stat-card.yellow .stat-value {
  color: var(--yellow);
}

/* === Table === */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover {
  background: var(--card-hover);
}

/* === Forms === */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.9em;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95em;
  transition: border-color 0.2s;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea {
  resize: vertical;
  min-height: 80px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.2s;
  text-decoration: none;
  color: #fff;
}
.btn-primary {
  background: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-success {
  background: var(--green);
  color: #111;
}
.btn-success:hover {
  background: #3dbb8f;
}
.btn-danger {
  background: var(--red);
}
.btn-danger:hover {
  background: #c73651;
}
.btn-secondary {
  background: #444;
}
.btn-secondary:hover {
  background: #555;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.85em;
  min-height: 32px;
  line-height: 1.2;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* === Alerts === */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 0.95em;
}
.alert-error {
  background: #3d0f0f;
  color: var(--red);
}
.alert-success {
  background: #0f3d3e;
  color: var(--green);
}
.alert-warning {
  background: #3d3a0f;
  color: var(--yellow);
}
.alert-info {
  background: #0f2d3d;
  color: var(--blue);
}

/* === Badges === */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 600;
}
.badge-bot {
  background: rgba(233, 69, 96, 0.2);
  color: var(--red);
}
.badge-human {
  background: rgba(78, 204, 163, 0.2);
  color: var(--green);
}
.badge-score {
  background: rgba(52, 152, 219, 0.2);
  color: var(--blue);
  min-width: 35px;
  text-align: center;
}
.badge-info {
  background: rgba(52, 152, 219, 0.2);
  color: var(--blue);
}
.badge-success {
  background: rgba(78, 204, 163, 0.2);
  color: var(--green);
}
.badge-danger {
  background: rgba(233, 69, 96, 0.2);
  color: var(--red);
}
.badge-secondary {
  background: rgba(128, 128, 128, 0.2);
  color: var(--text-muted);
}

/* === Global JS tooltip (UA / reason cells) === */
.expand-cell {
  cursor: pointer;
}
.js-tooltip {
  display: none;
  position: fixed;
  z-index: 99999;
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: min(500px, calc(100vw - 16px));
  white-space: pre-line;
  word-break: break-all;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.85em;
  line-height: 1.5;
  pointer-events: none;
  color: var(--text);
}

/* === Pagination === */
.pagination {
  display: flex;
  gap: 5px;
  margin-top: 20px;
  justify-content: center;
}
.pagination a,
.pagination span {
  padding: 8px 14px;
  background: var(--card);
  border-radius: 4px;
  color: var(--text-muted);
}
.pagination a:hover {
  background: var(--card-hover);
  color: var(--text);
}
.pagination .active {
  background: var(--accent);
  color: #fff;
}
.pagination .dots {
  padding: 8px 6px;
  color: var(--text-muted);
  cursor: default;
  background: none;
}

/* === Filters bar === */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: flex-end;
}
.filters-bar .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 140px;
}
.filters-bar .btn {
  align-self: flex-end;
}

/* === Toggle === */
.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #444;
  border-radius: 26px;
  transition: 0.3s;
}
.toggle .slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .slider {
  background: var(--green);
}
.toggle input:checked + .slider:before {
  transform: translateX(22px);
}

/* === Chart placeholder === */
.chart-container {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 20px 0;
}
.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
  transition: height 0.3s;
}
.chart-bar:hover {
  opacity: 0.8;
}
.chart-bar .chart-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75em;
  white-space: nowrap;
  margin-bottom: 5px;
}
.chart-bar:hover .chart-tooltip {
  display: block;
}

/* === Mobile header & burger === */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  z-index: 200;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.burger {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.3em;
  cursor: pointer;
  transition: background 0.15s;
}
.burger:hover {
  background: var(--border);
}
.mobile-brand {
  font-weight: 700;
  font-size: 1.15em;
  color: var(--accent);
  letter-spacing: 0.3px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.open {
  display: block;
}

/* === Title actions (stats page-title buttons) === */
.title-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.title-form-inline {
  display: flex;
  gap: 5px;
  align-items: center;
}
.title-input-days {
  width: 60px;
  padding: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.65em;
}

/* === Expand cells (UA/reason) === */
.expand-cell {
  max-width: 180px;
  position: relative;
}
.expand-cell .short {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
  /* white-space: nowrap; */
  max-width: 100%;
}
.expand-cell .full {
  display: none;
}
.expand-cell:hover .full {
  display: block;
}
.expand-cell:hover .short {
  /* display: none; */
}

/* === Responsive — Планшет (≤1024px) === */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  .sidebar-brand {
    font-size: 1.2em;
  }
  .sidebar-nav a {
    padding: 10px 16px;
    font-size: 0.9em;
  }
  .main {
    margin-left: 200px;
    width: calc(100% - 200px);
    padding: 20px;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }
  .stat-value {
    font-size: 1.6em;
  }
  .card {
    padding: 18px;
  }
  .page-title {
    font-size: 1.3em;
  }
}

/* === Responsive — Мобилка (≤768px) === */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 180;
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
    width: 100%;
    padding: 60px 12px 16px; /* 60px top = под хедер */
  }
  .page-title {
    font-size: 1.15em;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-title > div {
    width: 100%;
  }
  .page-title .btn,
  .page-title button {
    font-size: 15px;
  }
  .page-title input {
    font-size: 0.95em;
  }
  .title-form-inline {
    display: inline;
    white-space: nowrap;
  }
  .title-input-days {
    font-size: 0.95em !important;
    width: 50px;
    padding: 4px 6px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-card {
    padding: 14px 10px;
  }
  .stat-value {
    font-size: 1.4em;
  }
  .stat-label {
    font-size: 0.8em;
  }
  .card {
    padding: 14px;
    margin-bottom: 14px;
  }

  /* Таблицы: горизонтальный скролл */
  .table-wrap {
    margin: 0 -14px;
    padding: 0 14px;
  }
  th,
  td {
    padding: 8px 8px;
    font-size: 0.82em;
    white-space: nowrap;
  }

  /* Формы в одну колонку */
  form[style*="flex"] {
    flex-direction: column !important;
  }
  form[style*="flex"] .form-group {
    min-width: 100% !important;
    flex: unset !important;
  }

  /* Кнопки действий: перенос */
  .campaign-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .campaign-card {
    flex-direction: column;
  }
  .campaign-stats {
    justify-content: space-around;
    width: 100%;
    margin: 10px 0;
  }

  /* Фильтры графика */
  .chart-filters {
    flex-direction: column;
    gap: 8px;
  }

  /* Пагинация компактнее */
  .pagination a,
  .pagination span {
    padding: 6px 10px;
    font-size: 0.85em;
  }

  /* Скрываем длинные колонки */
  .hide-mobile {
    display: none;
  }
}

/* === Responsive — Маленький экран (≤480px) === */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .stat-card {
    padding: 10px 6px;
  }
  .stat-value {
    font-size: 1.2em;
  }
  .page-title {
    font-size: 1em;
  }
  .main {
    padding: 56px 8px 12px;
  }
  .card {
    padding: 10px;
    border-radius: 8px;
  }
  .btn-sm {
    padding: 5px 8px;
    font-size: 0.78em;
  }
  th,
  td {
    padding: 6px 5px;
    font-size: 0.78em;
  }
  .sidebar {
    width: 240px;
  }
}
