﻿/* TimeLine Studio — UI kit (SoT)
   Host: /assets/tls-ui.css. Only .tls-* selectors (no bare button/input).
   Visual language: winDesk «Заказы». Link after tls-tokens.css. */

/* ——— Buttons ——— */
.tls-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--inset-btn);
  min-height: var(--control-height);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-family: inherit;
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-tight);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.tls-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.tls-btn--block {
  width: 100%;
}

.tls-btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 1px 2px rgba(26, 29, 66, 0.12);
}

.tls-btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.tls-btn--primary:focus-visible {
  outline: 2px solid var(--primary-ring);
  outline-offset: 2px;
}

.tls-btn--secondary {
  background: var(--surface);
  color: var(--link);
  border-color: var(--primary-light);
  font-weight: var(--font-weight-medium);
}

.tls-btn--secondary:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.tls-btn--secondary.tls-btn--danger,
.tls-btn--secondary.btn-danger {
  color: var(--danger);
  border-color: rgba(212, 59, 59, 0.45);
}

.tls-btn--secondary.tls-btn--danger:hover,
.tls-btn--secondary.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #b82e2e;
}

.tls-btn--ghost {
  background: transparent;
  color: var(--link);
  border: none;
  padding: var(--space-1) var(--space-2);
  font-weight: var(--font-weight-medium);
}

.tls-btn--ghost:hover {
  background: var(--primary-subtle);
  color: var(--primary-hover);
}

.tls-btn--danger {
  color: var(--danger);
}

.tls-btn--ghost.tls-btn--danger:hover {
  background: var(--danger-bg);
  color: #b82e2e;
}

.tls-btn--sm {
  padding: var(--inset-btn-sm);
  min-height: 1.75rem;
  font-size: var(--font-size-sm);
}

.tls-btn--icon {
  width: var(--control-height);
  min-width: var(--control-height);
  padding: 0;
  gap: 0;
}

.tls-btn--icon.tls-btn--sm {
  width: 1.75rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
}

.tls-btn--icon svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  pointer-events: none;
}

.tls-btn-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.tls-btn-modal-close:hover {
  background: var(--primary-subtle);
  color: var(--text);
}

/* ——— Fields ——— */
.tls-field {
  margin-bottom: var(--gap-form);
}

.tls-field label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--muted);
  margin-bottom: var(--space-1);
}

.tls-input,
.tls-select,
.tls-textarea,
.tls-field input,
.tls-field select,
.tls-field textarea {
  width: 100%;
  padding: var(--inset-input);
  min-height: var(--control-height);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  box-sizing: border-box;
}

.tls-textarea,
.tls-field textarea {
  min-height: 5rem;
  resize: vertical;
}

.tls-input:focus,
.tls-select:focus,
.tls-textarea:focus,
.tls-field input:focus,
.tls-field select:focus,
.tls-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.tls-input:disabled,
.tls-select:disabled,
.tls-textarea:disabled,
.tls-field input:disabled,
.tls-field select:disabled,
.tls-field textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg);
}

.tls-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-form);
}

.tls-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  align-items: center;
  margin-top: var(--gap-md);
}

/* ——— Toolbar ——— */
.tls-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-md);
  margin-bottom: var(--space-4);
  background: var(--surface);
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.tls-toolbar--filters {
  flex-direction: column;
  justify-content: stretch;
  align-items: stretch;
  gap: 0.625rem;
}

.tls-toolbar--actions {
  justify-content: flex-end;
}

/* List screens: toolbar sits above a growing table, no extra bottom gap */
.tls-toolbar--flush {
  margin-bottom: 0;
  flex: 0 0 auto;
  width: 100%;
}

/* Mode switcher (План/Архив, Канбан/Список) */
.tls-segmented {
  display: inline-flex;
  align-items: stretch;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.tls-segmented__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--control-height);
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.tls-segmented__btn:hover:not(:disabled) {
  color: var(--text);
}

.tls-segmented__btn:focus-visible {
  outline: 2px solid var(--primary-ring);
  outline-offset: 2px;
}

.tls-segmented__btn.is-active,
.tls-segmented__btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.tls-segmented__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Transient status over a list screen */
.tls-toast {
  position: absolute;
  top: var(--space-2);
  left: 50%;
  transform: translateX(-50%);
  z-index: 75;
  margin: 0;
  max-width: min(36rem, calc(100% - var(--space-6)));
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-tight);
  text-align: center;
  box-shadow: var(--shadow-elevated);
}

.tls-toast.is-hidden,
.tls-toast[hidden] {
  display: none;
}

.tls-toast--error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-bg);
}

.tls-toast--success {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, var(--border));
  background: var(--ok-bg);
}

.tls-toast--info {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: var(--primary-subtle);
}

/* ——— Table / card ——— */
.tls-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.tls-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tls-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-family-sans);
  font-size: var(--table-font-size);
  color: var(--text);
  background: var(--surface);
}

.tls-table th,
.tls-table td {
  box-sizing: border-box;
  height: var(--table-row-height);
  padding: 0 var(--inset-cell-x);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  line-height: var(--table-cell-line-height);
}

.tls-table th {
  height: var(--table-header-height);
  font-size: var(--table-header-font-size);
  color: var(--muted);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--table-header-letter-spacing);
  background: var(--bg);
  white-space: nowrap;
}

.tls-table thead th {
  border-bottom: 1px solid var(--border);
}

.tls-table tbody tr:last-child td {
  border-bottom: none;
}

.tls-table tbody tr:hover {
  background: var(--row-hover);
}

.tls-table tbody tr.is-selected,
.tls-table tbody tr[aria-selected="true"] {
  background: var(--row-selected);
}

.tls-table tbody tr[data-id] {
  cursor: pointer;
}

.tls-table .num,
.tls-table .tls-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tls-table a,
.tls-table .tls-link {
  color: var(--link);
  text-decoration: none;
}

.tls-table a:hover,
.tls-table .tls-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.tls-table td.empty,
.tls-table td.tls-empty-cell {
  text-align: center;
  color: var(--muted);
  padding: var(--space-6) var(--inset-cell-x);
  height: auto;
  cursor: default;
}

/* Dense rows (settings lists, secondary grids) */
.tls-table--compact th,
.tls-table--compact td {
  height: var(--table-row-height-compact);
  padding: 0 var(--inset-cell-compact-x);
}

.tls-table--compact th {
  height: var(--table-row-height-compact);
}

/* Sticky header inside .tls-table-wrap / scroll parent */
.tls-table--sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ——— Badge / typography / empty ——— */
.tls-badge {
  display: inline-block;
  padding: var(--inset-badge);
  border-radius: 4px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.tls-badge--muted {
  background: var(--bg);
  color: var(--muted);
}

.tls-badge--ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.tls-badge--warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.tls-badge--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ——— Feature flags (признаки) — единый вид во всех плагинах ——— */
.tls-flags,
.im-bom-flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.tls-flag,
.im-flag,
.mp-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  border: 1px solid transparent;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  background: var(--bg, #e6eaf4);
  color: var(--text, #1a1d42);
  box-sizing: border-box;
}

.tls-flag__code,
.im-flag__code,
.mp-flag__code {
  font-family: var(--font-family-mono, Consolas, monospace);
  font-weight: 500;
  opacity: 0.75;
  font-size: 0.95em;
}

.tls-flag--temper,
.im-flag--temper,
.mp-flag--temper {
  background: rgba(196, 90, 30, 0.12);
  border-color: rgba(196, 90, 30, 0.28);
  color: #9a4518;
}

.tls-flag--temper-fz,
.im-flag--temper-fz,
.mp-flag--temper-fz {
  background: rgba(180, 45, 45, 0.1);
  border-color: rgba(180, 45, 45, 0.28);
  color: #a32d2d;
}

.tls-flag--thermo,
.im-flag--thermo,
.mp-flag--thermo {
  background: rgba(47, 85, 200, 0.1);
  border-color: rgba(47, 85, 200, 0.25);
  color: #2f55c8;
}

.tls-flag--ral,
.im-flag--ral,
.mp-flag--ral {
  background: rgba(78, 85, 117, 0.1);
  border-color: rgba(78, 85, 117, 0.22);
  color: #3d4460;
}

.tls-flag--film,
.im-flag--film,
.mp-flag--film {
  background: rgba(59, 168, 232, 0.12);
  border-color: rgba(59, 168, 232, 0.28);
  color: #1f6f9a;
}

.tls-flag--fire,
.im-flag--fire,
.mp-flag--fire {
  background: rgba(180, 45, 45, 0.1);
  border-color: rgba(180, 45, 45, 0.25);
  color: #a32d2d;
}

.tls-flag--shape,
.im-flag--shape,
.mp-flag--shape,
.tls-flag--assembly,
.mp-flag--assembly {
  background: rgba(31, 155, 98, 0.1);
  border-color: rgba(31, 155, 98, 0.25);
  color: #1f9b62;
  font-weight: 500;
}

.tls-flag--glass,
.mp-flag--glass {
  background: rgba(47, 85, 200, 0.1);
  border-color: rgba(47, 85, 200, 0.25);
  color: #2f55c8;
}

.tls-flag--grind,
.mp-flag--grind {
  background: rgba(120, 90, 40, 0.1);
  border-color: rgba(120, 90, 40, 0.28);
  color: #6b4e1e;
}

.tls-flag--spacer,
.mp-flag--spacer {
  background: rgba(78, 85, 117, 0.1);
  border-color: rgba(78, 85, 117, 0.22);
  color: #3d4460;
}

.tls-flag--user,
.mp-flag--user {
  background: rgba(126, 58, 168, 0.1);
  border-color: rgba(126, 58, 168, 0.28);
  color: #6b2f8a;
}

.tls-flag--default,
.mp-flag--default {
  background: var(--bg, #e6eaf4);
  border-color: var(--border, #c8cee0);
}

.tls-flag--off {
  opacity: 0.48;
  border-style: dashed;
  font-weight: 500;
}

.tls-page-title {
  margin: 0;
  font-size: var(--font-h1);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text);
}

.tls-muted {
  color: var(--muted);
}

.tls-empty {
  text-align: center;
  color: var(--muted);
  padding: var(--space-6);
}

/* ——— Modal chrome ——— */
.tls-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(26, 29, 66, 0.45);
  box-sizing: border-box;
  overscroll-behavior: none;
}

/* display:flex above would otherwise override [hidden] / .hidden */
.tls-modal-overlay.hidden,
.tls-modal-overlay[hidden] {
  display: none;
}

.tls-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  max-width: min(640px, 100%);
  max-height: min(90dvh, 100%);
  overflow: auto;
  overscroll-behavior: contain;
  width: 100%;
}

/*
 * While a form/card overlay is open, page (and marked list panes) must not scroll.
 * Plugins may also toggle body.tls-overlay-open / body.modal-open.
 */
body.tls-overlay-open,
body.modal-open,
body:has(.tls-modal-overlay:not(.hidden)),
body:has(dialog[open]) {
  overflow: hidden;
}

body.tls-overlay-open [data-tls-scroll-main],
body.modal-open [data-tls-scroll-main],
body:has(.tls-modal-overlay:not(.hidden)) [data-tls-scroll-main],
body:has(dialog[open]) [data-tls-scroll-main] {
  overflow: hidden !important;
}

.tls-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  justify-content: flex-end;
  padding: var(--inset-modal-footer);
  border-top: 1px solid var(--border);
}

/* Touch: taller controls without changing desktop Orders look */
@media (max-width: 767px) {
  .tls-btn:not(.tls-btn--sm):not(.tls-btn--ghost) {
    min-height: var(--control-height-touch);
  }

  .tls-btn--icon:not(.tls-btn--sm) {
    width: var(--control-height-touch);
    min-width: var(--control-height-touch);
  }

  .tls-segmented {
    max-width: 100%;
  }

  .tls-segmented__btn {
    min-height: var(--control-height-touch);
  }

  .tls-input,
  .tls-select,
  .tls-field input,
  .tls-field select {
    min-height: var(--control-height-touch);
  }
}

@media (hover: none) and (pointer: coarse) {
  .tls-btn:not(.tls-btn--sm):not(.tls-btn--ghost) {
    min-height: var(--control-height-touch);
  }

  .tls-btn--icon:not(.tls-btn--sm) {
    width: var(--control-height-touch);
    min-width: var(--control-height-touch);
  }
}
