/* widgets.css — базові стилі всіх віджетів платформи. */
/* Тут лише скелет вигляду; рендер даних і поведінку реалізують *Widget.js (Чат 8). */
/* Формат: 1 селектор = 1 рядок. Змінні успадковуються з app.css. */

/* ── Спільна оболонка віджета ──────────────────────────────────────────────── */
.widget { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; font-size: var(--fs-base); color: var(--ink); }
.widget__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.widget__title { font-weight: 600; font-size: var(--fs-md); }
.widget__actions { display: flex; align-items: center; gap: var(--sp-1); }
.widget__body { flex: 1 1 auto; min-height: 0; }
.widget__loading { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: var(--sp-6); color: var(--muted); }
.widget__empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: var(--sp-6); color: var(--muted); text-align: center; font-size: var(--fs-sm); }
.widget__error { padding: var(--sp-3); border-radius: var(--radius-sm); background: var(--danger-050); color: var(--danger); font-size: var(--fs-sm); }

/* ── TextWidget: текст / число / дата / бейдж ──────────────────────────────── */
.w-text { display: flex; flex-direction: column; gap: 4px; }
.w-text__label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.w-text__value { font-size: var(--fs-lg); font-weight: 600; color: var(--ink); }
.w-text__value--metric { font-size: var(--fs-2xl); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.w-text__delta { font-size: var(--fs-sm); font-weight: 600; }
.w-text__delta--up { color: var(--success); }
.w-text__delta--down { color: var(--danger); }

/* ── InputWidget: поле вводу / select / toggle / файл ──────────────────────── */
.w-input { display: flex; flex-direction: column; gap: 6px; }
.w-input__toggle { position: relative; display: inline-flex; align-items: center; width: 42px; height: 24px; border-radius: var(--radius-pill); background: var(--line-strong); cursor: pointer; transition: background var(--dur) var(--ease); }
.w-input__toggle.is-on { background: var(--accent); }
.w-input__toggle::after { content: ""; position: absolute; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.w-input__toggle.is-on::after { transform: translateX(18px); }
.w-input__file { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: var(--fs-sm); cursor: pointer; }
.w-input__file:hover { border-color: var(--accent); color: var(--accent-700); }

/* ── ButtonWidget ──────────────────────────────────────────────────────────── */
.w-button { display: flex; align-items: center; }

/* ── TableWidget ───────────────────────────────────────────────────────────── */
.w-table { display: flex; flex-direction: column; height: 100%; }
.w-table__toolbar { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); flex-wrap: wrap; }
.w-table__scroll { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); }
.w-table table { width: 100%; border-collapse: collapse; }
.w-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.w-table th .sort-ind { margin-left: 4px; opacity: .6; }
.w-table td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); }
.w-table tbody tr:hover td { background: var(--surface-2); }
.w-table__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.pager { display: inline-flex; align-items: center; gap: 4px; }
.pager__btn { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: var(--fs-sm); }
.pager__btn:hover:not(:disabled) { border-color: var(--accent); }
.pager__btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager__btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── CardWidget ────────────────────────────────────────────────────────────── */
.w-card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.w-card__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.w-card__key { color: var(--muted); font-size: var(--fs-sm); }
.w-card__val { font-weight: 550; text-align: right; }

/* ── FormWidget ────────────────────────────────────────────────────────────── */
.w-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.w-form__actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-2); }

/* ── ChartWidget ───────────────────────────────────────────────────────────── */
.w-chart { display: flex; flex-direction: column; height: 100%; }
.w-chart__canvas { flex: 1 1 auto; min-height: 160px; }
.w-chart__legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--muted); }
.w-chart__legend-item { display: inline-flex; align-items: center; gap: 6px; }
.w-chart__swatch { width: 10px; height: 10px; border-radius: 3px; }
.w-progress { height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.w-progress__fill { height: 100%; border-radius: var(--radius-pill); background: var(--accent); transition: width var(--dur) var(--ease); }

/* ── KanbanWidget ──────────────────────────────────────────────────────────── */
.w-kanban { display: flex; gap: var(--sp-3); height: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--sp-2); }
.w-kanban__col { display: flex; flex-direction: column; flex: 0 0 268px; max-height: 100%; background: var(--surface-3); border-radius: var(--radius); }
.w-kanban__col-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3); font-weight: 600; font-size: var(--fs-sm); }
.w-kanban__count { min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; }
.w-kanban__list { flex: 1 1 auto; min-height: 40px; overflow-y: auto; padding: 0 var(--sp-2) var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); }
.w-kanban__card { padding: var(--sp-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-1); cursor: grab; }
.w-kanban__card.is-dragging { opacity: .6; }
.w-kanban__list.is-drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--radius-sm); }

/* ── CalendarWidget (календар / шахматка) ──────────────────────────────────── */
.w-cal { display: flex; flex-direction: column; height: 100%; }
.w-cal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.w-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.w-cal__dow { padding: var(--sp-2); background: var(--surface-2); text-align: center; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; color: var(--muted); }
.w-cal__cell { min-height: 84px; padding: 6px; background: var(--surface); font-size: var(--fs-sm); }
.w-cal__cell.is-out { background: var(--surface-2); color: var(--faint); }
.w-cal__cell.is-today .w-cal__date { background: var(--accent); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-grid; place-items: center; }
.w-cal__event { margin-top: 4px; padding: 2px 6px; border-radius: 4px; background: var(--accent-050); color: var(--accent-700); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Шахматка (рядки = ресурси, колонки = дати) */
.w-grid-board { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); }
.w-grid-board table { border-collapse: collapse; width: 100%; }
.w-grid-board th, .w-grid-board td { border: 1px solid var(--line); padding: var(--sp-2); font-size: var(--fs-sm); white-space: nowrap; }
.w-grid-board th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.w-grid-board .cell-busy { background: var(--accent-050); color: var(--accent-700); }

/* ── FilterWidget ──────────────────────────────────────────────────────────── */
.w-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.w-filter__label { font-size: var(--fs-sm); font-weight: 550; color: var(--muted); }

/* ── Адаптив віджетів ──────────────────────────────────────────────────────── */
@media (max-width: 560px) { .w-kanban__col { flex-basis: 82vw; } .w-text__value--metric { font-size: var(--fs-xl); } .w-card__row { flex-direction: column; align-items: flex-start; gap: 2px; } .w-card__val { text-align: left; } }
