/* === Инструмент "История выездов" === */

.main-content:has(.graph-page) { padding: 0 8px; }

.graph-page {
  display: flex;
  flex-direction: column;
  padding-bottom: 40px;
}

.graph-toolbar__count {
  color: var(--color-on-surface-secondary);
  font-weight: 500;
  margin-left: 4px;
}

.graph-page .tool-toolbar {
  padding: 0 4px;
}

/* Переключатель режимов (За месяц / За год / За всё время) — стиль .tool-tabs */
.graph-mode-tabs {
  margin: 8px 4px 4px;
}

/* Шапка периода (< Апрель 2026 >) — паттерн Норма часов */
.graph-period-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  margin: 0 4px;
}
.graph-period-nav {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.graph-period-nav:hover {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.graph-period-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-on-surface);
}

/* Фильтры смен (под графиком) */
.graph-teams-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 4px 8px;
  justify-content: center;
}
.graph-team-btn { font-size: 13px; }

/* Диаграмма */
.graph-chart-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 10px 6px;
  margin: 4px 4px 8px;
  overflow-x: auto;
  /* justify-content:center ломает скролл при узких экранах — SVG обрезается
     по краям. Используем text-align:center, чтобы узкие диаграммы («за год»)
     выравнивались, а широкие («за месяц», 31 столбец) скроллились от 0. */
  text-align: center;
}
.graph-chart {
  display: inline-block;
  vertical-align: top;
}
.graph-chart-grid {
  stroke: var(--color-border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  opacity: 0.55;
}
.graph-chart-axis-label {
  font-family: var(--font-family);
  font-size: 10px;
  fill: var(--color-on-surface-secondary);
}
.graph-chart-axis-label--x {
  font-size: 12px;
  font-weight: 500;
  fill: var(--color-on-surface);
}
.graph-chart-bar-label {
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.graph-chart-total {
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 700;
  fill: var(--color-on-surface);
  pointer-events: none;
}
.graph-chart-bar {
  transition: opacity 0.15s;
}
.graph-chart-bar:hover { opacity: 0.8; }
.graph-chart-empty {
  padding: 32px 12px;
  text-align: center;
  color: var(--color-on-surface-secondary);
  font-size: 14px;
}

/* Рекламный слот (между фильтром смен и списком выездов) */
.graph-ad-slot {
  display: block;
  margin: 4px 4px 8px;
}
.graph-ad-slot:empty {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
}
.graph-ad-slot .yandex-ad { margin: 0; }

/* Список выездов */
.graph-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 4px 24px;
}
.graph-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--color-on-surface-secondary);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}
.graph-empty p { margin: 0 0 6px; }
.graph-empty p:last-child { margin: 0; }

.graph-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: color-mix(in srgb, var(--team-color, var(--color-primary)) 10%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--color-primary)) 35%, transparent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  overflow: hidden;
}
.graph-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.graph-card:active { transform: translateY(1px); }

.graph-card__main {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.graph-card__content {
  flex: 1;
  min-width: 0;
}
.graph-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-on-surface);
  word-break: break-word;
}
.graph-card__duration {
  font-size: 12px;
  color: var(--color-on-surface-secondary);
  margin-top: 2px;
}
.graph-card__desc {
  font-size: 13px;
  color: var(--color-on-surface);
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
.graph-card__staff {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed color-mix(in srgb, var(--team-color, var(--color-primary)) 40%, transparent);
}
.graph-card__staff-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-on-surface-secondary);
  margin-bottom: 4px;
}
.graph-card__staff-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.graph-card__staff-list li {
  font-size: 13px;
  color: var(--color-on-surface);
}
.graph-card__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  flex-shrink: 0;
}
.graph-card__actions .btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
}

/* ============ Модалка Add/Edit ============ */

.graph-edit-modal__body {
  padding: 14px 20px 18px;
}
.graph-edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.graph-edit-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.graph-edit-form__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.graph-edit-form__field--full { grid-column: 1 / -1; }
.graph-edit-form__field > span {
  font-size: 12px;
  color: var(--color-on-surface-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.graph-edit-form__field input[type="datetime-local"],
.graph-edit-form__field input[type="number"],
.graph-edit-form__field textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-on-surface);
  color-scheme: light;
  transition: border-color 0.15s, background 0.15s;
}
[data-theme="dark"] .graph-edit-form__field input,
[data-theme="dark"] .graph-edit-form__field textarea {
  color-scheme: dark;
}
.graph-edit-form__field input:focus,
.graph-edit-form__field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.graph-edit-form__field textarea {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}
.graph-edit-form__teams {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

/* Picker личного состава */
.graph-edit-staff {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px;
  background: var(--color-surface);
}
.graph-edit-staff__empty {
  padding: 16px;
  font-size: 13px;
  color: var(--color-on-surface-secondary);
  text-align: center;
}
.graph-edit-staff__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: background 0.1s;
}
.graph-edit-staff__row:hover { background: var(--color-hover); }
.graph-edit-staff__row--on { background: color-mix(in srgb, var(--color-primary) 10%, transparent); }

/* Свитч (Material-like toggle) */
.graph-edit-staff__switch {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  min-width: 0;
}
.graph-edit-staff__switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.graph-edit-staff__switch-ui {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  background: var(--color-border);
  border-radius: 999px;
  transition: background 0.15s;
}
.graph-edit-staff__switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.graph-edit-staff__switch input[type="checkbox"]:checked ~ .graph-edit-staff__switch-ui {
  background: var(--color-primary);
}
.graph-edit-staff__switch input[type="checkbox"]:checked ~ .graph-edit-staff__switch-ui::after {
  transform: translateX(16px);
}
.graph-edit-staff__switch input[type="checkbox"]:focus-visible ~ .graph-edit-staff__switch-ui {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.graph-edit-staff__person {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.graph-edit-staff__name {
  font-size: 14px;
  color: var(--color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.graph-edit-staff__team {
  font-size: 12px;
  color: var(--color-on-surface-secondary);
}
.graph-edit-staff__gdzs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.graph-edit-staff__gdzs > span {
  font-size: 11px;
  color: var(--color-on-surface-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.graph-edit-staff__gdzs input {
  width: 72px;
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-on-surface);
  text-align: right;
  color-scheme: light;
}
[data-theme="dark"] .graph-edit-staff__gdzs input { color-scheme: dark; }
.graph-edit-staff__gdzs input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.graph-edit-staff__gdzs input[disabled] { opacity: 0.4; }

.graph-edit-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.graph-edit-modal__footer-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

@media (max-width: 900px) {
  .graph-edit-form__row { grid-template-columns: 1fr; }
  .graph-edit-staff__row { flex-wrap: wrap; }
  .graph-edit-staff__gdzs { margin-left: 24px; }
}
