/* Экран «Работы» — портировано из style.css Mini App: карточка работы,
   бейджи статуса/категории, карточка-детали, тулбар с поиском/фильтрами/
   сортировкой, поля контактов и переключатель оплаты в форме, фото, блок
   комментария и список действий. Классы 1:1 с оригиналом.

   2026-09-23 — MODERN AUTOMOTIVE: карточка считывается сверху вниз
   (автомобиль → госномер-«табличка» → клиент/статус → сумма), спокойные
   статусы (бледная подложка + цветной текст), единые поля/чипы/сегменты.
   Классы, завязанные на JS (chip--active, segmented__opt--active,
   photo-file-input, photo-thumb--staged), не переименовывались. */

.work-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  color: var(--text);
  width: 100%;
  min-width: 0;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.work-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-md); }
.work-card:active { transform: scale(0.995); }

.work-card--with-photo .work-card__meta,
.work-card--with-photo .work-card__bottom { padding-right: 88px; }

.work-card__thumb {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 74px;
  height: 74px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.work-card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.work-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.work-card__top > div:first-child { min-width: 0; flex: 1; }
.work-card__car { font-size: var(--fs-card); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
/* госномер — как номерная табличка: моноширинный, в тонкой рамке */
.work-card__plate {
  display: inline-block; max-width: 100%;
  font-size: 12px; font-weight: 700; color: #0f172a;
  margin-top: 6px; padding: 2px 16px 2px 8px;
  background: linear-gradient(90deg, #ffffff calc(100% - 9px), #2563eb calc(100% - 9px));
  border: 1.5px solid #1e293b; border-radius: 5px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  letter-spacing: 0.04em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.work-card__price {
  font-size: 16px; font-weight: 700; white-space: nowrap; flex-shrink: 0;
  letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}

.work-card__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: var(--fs-secondary); color: var(--text-secondary); min-width: 0; }
.work-card__bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- Бейджи / статусы ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-pill); padding: 4px 10px; font-size: var(--fs-caption); font-weight: 600;
  line-height: 1.3; white-space: nowrap;
}
.badge--paid { background: var(--success-wash); color: var(--success-text); }
/* долг = «ожидает оплаты» — янтарный, не тревожный красный */
.badge--debt { background: var(--warning-wash); color: var(--warning-text); }
.badge--cat { background: var(--surface-muted); color: var(--text-secondary); font-weight: 500; border: 1px solid var(--border); }

/* ---------- Тулбар: поиск / фильтры / сортировка ---------- */

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.search-box {
  display: flex; align-items: center; gap: 9px;
  min-height: var(--control-h);
  background: var(--surface-field); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 12px;
  color: var(--text-faint);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.search-box input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text); font-size: var(--fs-body); padding: 9px 0;
}
.search-box input::placeholder { color: var(--text-faint); opacity: 0.85; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; border: 1px solid var(--border-strong); background: var(--surface-solid);
  color: var(--text-secondary); border-radius: var(--radius-pill); padding: 7px 14px;
  min-height: 36px;
  font-size: var(--fs-secondary); font-weight: 500; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--primary-border); color: var(--text); }
.chip.chip--active { background: var(--primary-wash); border-color: var(--primary-border); color: var(--primary); font-weight: 600; }

.sort-row { display: flex; align-items: center; gap: 10px; }
.sort-select {
  flex: 1; min-height: var(--control-h); background: var(--surface-field); border: 1px solid var(--border-strong);
  color: var(--text-secondary); border-radius: var(--radius-sm); padding: 8px 12px; font-size: var(--fs-secondary);
}
.sort-dir {
  background: var(--surface-field); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  width: var(--control-h); height: var(--control-h); display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); flex-shrink: 0;
}

.result-count { font-size: var(--fs-caption); color: var(--text-faint); margin: 0 2px 12px; }

.client-link {
  color: var(--text-secondary); font-weight: 500;
  border-bottom: 1px dashed var(--text-faint);
  overflow-wrap: anywhere;
  max-width: 100%;
  min-width: 0;
}

/* ---------- Карточка-детали ---------- */

.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 4px;
}
.detail-hero__icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--primary-wash);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 14px;
}
.detail-hero__title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.detail-hero__subtitle { font-size: var(--fs-secondary); color: var(--text-faint); margin-top: 3px; }

.info-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.info-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 18px; border-top: 1px solid var(--border); font-size: var(--fs-body);
}
.info-row:first-child { border-top: none; }
.info-row__label { color: var(--text-secondary); flex-shrink: 0; }
.info-row__value { font-weight: 600; text-align: right; overflow-wrap: anywhere; min-width: 0; }

.section-title {
  font-size: var(--fs-section);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 28px 2px 12px;
}
.section-title:first-child { margin-top: 4px; }

/* ---------- Поля контактов и переключатель оплаты (форма) ---------- */

.contact-input {
  display: flex; align-items: center; gap: 9px;
  min-height: var(--control-h);
  background: var(--surface-field); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.contact-input:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.contact-input__prefix { color: var(--text-faint); font-weight: 600; font-size: var(--fs-body); flex-shrink: 0; }
.contact-input input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text); font-size: 15px; padding: 9px 0;
}
.contact-input input::placeholder { color: var(--text-faint); opacity: 0.75; }

.segmented {
  display: flex; background: var(--surface-muted); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px; gap: 3px;
}
.segmented__opt {
  flex: 1; text-align: center; padding: 9px 6px; min-height: 38px; border-radius: 9px;
  background: none; border: none;
  font-size: var(--fs-body); font-weight: 600; color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.segmented__opt:hover { color: var(--text); }
.segmented__opt.segmented__opt--active { background: var(--surface-solid); color: var(--primary); box-shadow: var(--shadow-md); }
.segmented__opt[data-value="paid"].segmented__opt--active { background: var(--success-wash); color: var(--success-text); box-shadow: none; }

/* ---------- Фото ---------- */

.photo-group { margin-bottom: 14px; }
.photo-group__label { font-size: var(--fs-caption); color: var(--text-secondary); font-weight: 600; margin-bottom: 8px; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 10px; }

.photo-thumb {
  position: relative;
  width: 84px; height: 84px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb__delete {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(15, 23, 42, 0.72); color: #fff;
  border: none; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
/* фото, выбранное в форме и ещё не отправленное (уйдёт при сохранении заказа) */
.photo-thumb--staged { border: 1.5px dashed var(--primary); }
.photo-thumb__noprev { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--text-faint); }
.photo-thumb--uploading {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border-strong);
}
.photo-thumb__spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  animation: worksPhotoSpin 0.7s linear infinite;
}
@keyframes worksPhotoSpin { to { transform: rotate(360deg); } }

.photo-progress {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  height: 4px; border-radius: 999px; background: var(--surface-muted); overflow: hidden;
}
.photo-progress__bar { height: 100%; width: 0%; background: var(--primary); transition: width 0.15s ease; }

.photo-add-tile {
  position: relative;
  width: 84px; height: 84px;
  border-radius: 12px;
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-muted);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.photo-add-tile:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-wash); }
.photo-add-tile__icon { font-size: 24px; }
.photo-file-input {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0;
  opacity: 0;
  cursor: pointer;
}
.photo-error { font-size: var(--fs-caption); color: var(--danger-text); padding: 8px 0; }

/* ---------- Комментарий и список действий ---------- */

.comment-box {
  background: var(--surface-field); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 2px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.comment-box:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.comment-box textarea {
  width: 100%; min-height: 64px; resize: vertical;
  background: none; border: none; outline: none; color: var(--text);
  font-family: inherit; font-size: var(--fs-body); padding: 12px; line-height: 1.5;
}
.comment-box textarea::placeholder { color: var(--text-faint); opacity: 0.85; }

.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-btn {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 16px; color: var(--text); font: inherit; font-size: var(--fs-body); font-weight: 600; text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.action-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.action-btn__icon { font-size: 17px; }

.btn-back {
  background: none; border: none; color: var(--primary);
  font-size: var(--fs-body); font-weight: 600; padding: 8px 0; margin-bottom: 12px;
  min-height: 40px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-back:hover { color: var(--primary-hover); }

/* ---------- Подпись клиента ---------- */
/* Фон полотна намеренно #fff в обеих темах — подпись рисуется чёрным по
   белому и сохраняется с белой подложкой (как в печатном документе). */
.sign-pad { position: relative; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; cursor: crosshair; }
.sign-pad canvas { display: block; width: 100%; height: 190px; touch-action: none; }
.sign-pad__hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: var(--fs-secondary); pointer-events: none; text-align: center; padding: 0 20px;
}
.sign-saved { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.sign-saved img { display: block; max-width: 100%; }
