/* ═══════════════════════════════════════════════════════════════════════════
   METRICS BASE — общая обёртка, grid-контейнер, drag/resize, утилиты
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Виджет-обёртка ────────────────────────────────────────────────────────── */
.t-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  position: relative;
  container-type: size;
  container-name: metric;
  transition: box-shadow .15s;
}

/* Цветные акценты — тонкая полоска сверху */
.t-metric--checkpoints   { border-top: 3px solid #6366f1; }
.t-metric--progress_bar  { border-top: 3px solid #0ea5e9; }
.t-metric--counter       { border-top: 3px solid #f59e0b; }
.t-metric--stages        { border-top: 3px solid #8b5cf6; }
.t-metric--checklist     { border-top: 3px solid #10b981; }
.t-metric--attendance    { border-top: 3px solid #ef4444; }
.t-metric--grades        { border-top: 3px solid #f97316; }
.t-metric--deadlines     { border-top: 3px solid #ec4899; }
.t-metric--streak        { border-top: 3px solid #f59e0b; }
.t-metric--effort_hours  { border-top: 3px solid #14b8a6; }
.t-metric--rating_history { border-top: 3px solid #6366f1; }

/* ── Заголовок ─────────────────────────────────────────────────────────────── */
.t-metric-header {
  display: flex;
  align-items: center;
  padding: 6px 10px 4px;
  flex-shrink: 0;
  gap: 6px;
}
.t-metric-title {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ── Кнопка переименования в заголовке ────────────────────────────────────── */
.t-metric-rename-btn {
  width: 16px;
  height: 16px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .12s;
}
.t-metric:hover .t-metric-rename-btn { color: var(--muted); }
.t-metric-rename-btn:hover { color: var(--ink) !important; }
/* Скрыть кнопку переименования когда активен режим перетаскивания (там появляется крестик удаления) */
.t-metrics-grid.drag-mode .t-metric-rename-btn { color: transparent !important; pointer-events: none; }

/* ── Тело ──────────────────────────────────────────────────────────────────── */
.t-metric-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 10px 10px;
  overflow: hidden;
}

/* ── Пустое состояние ──────────────────────────────────────────────────────── */
.t-metric-empty {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* ── Крестик удаления — только в drag-mode ────────────────────────────────── */
.t-metric .delete-metric-btn {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
  width: 18px;
  height: 18px;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .1s;
}
.t-metric .delete-metric-btn:hover { background: #fef2f2; border-color: #ef4444; color: #ef4444; }
[data-theme="dark"] .t-metric .delete-metric-btn:hover { background: rgba(239,68,68,.15); }
.t-metrics-grid.drag-mode .delete-metric-btn { display: flex; }

/* ── Resize-ручка ──────────────────────────────────────────────────────────── */
.t-metric-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  cursor: se-resize;
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
  color: var(--border);
  z-index: 5;
  transition: color .12s;
}
.t-metric-resize:hover { color: var(--muted); }
.t-metrics-grid.drag-mode .t-metric-resize { display: flex; }
.t-metric-resize svg { pointer-events: none; }

/* ── Drag ──────────────────────────────────────────────────────────────────── */
.t-metrics-grid.drag-mode .t-metric { cursor: grab; }
.t-metrics-grid.drag-mode .t-metric:active { cursor: grabbing; }
.t-metric.drag-ghost {
  opacity: .3;
  outline: 2px dashed var(--green);
  outline-offset: -2px;
}
.t-metric.drag-over {
  outline: 2px solid var(--green);
  outline-offset: -2px;
  background: var(--mint);
}

/* ── Подсветка навигации ───────────────────────────────────────────────────── */
@keyframes metric-highlight {
  0%,60% { box-shadow: 0 0 0 3px var(--green); }
  100%   { box-shadow: 0 0 0 0 transparent; }
}
.t-metric.highlight { animation: metric-highlight 1.8s ease-out forwards; }

/* ═══ Grid-контейнер ══════════════════════════════════════════════════════════ */
.t-metrics-grid {
  --mg-cols: 3;
  --mg-gap:  12px;
  --row-h:   120px;
  display: grid;
  grid-template-columns: repeat(var(--mg-cols), 1fr);
  grid-auto-rows: var(--row-h);
  gap: var(--mg-gap);
  align-items: stretch;
}
@media (max-width: 900px) { .t-metrics-grid { --mg-cols: 2; } }
@media (max-width: 560px) { .t-metrics-grid { --mg-cols: 1; } }

.t-metric.gw-2 { grid-column: span 2; }
.t-metric.gw-3 { grid-column: span 3; }
.t-metric.gh-1 { grid-row: span 1; }
.t-metric.gh-2 { grid-row: span 2; }
.t-metric.gh-3 { grid-row: span 3; }
.t-metric.gh-4 { grid-row: span 4; }

@media (max-width: 900px) {
  .t-metric.gw-2,
  .t-metric.gw-3 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .t-metric.gw-2,
  .t-metric.gw-3 { grid-column: span 1; }
}

/* ── Кнопка "Расположение" ─────────────────────────────────────────────────── */
.t-grid-edit-btn {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all .12s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.t-grid-edit-btn:hover,
.t-grid-edit-btn.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--mint);
}

/* ── Общий мини-бар (переиспользуется в типах) ─────────────────────────────── */
.t-m-bar-track {
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  flex-shrink: 0;
}
.t-m-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .35s cubic-bezier(.4,0,.2,1);
}
