/**
 * FMS Sticky Stacking Checklist Component
 * Style: Swiss Grid + Tech Brutalism
 * Mechanics: Sticky Stack + 44px Header Step Offset + Tab Sync
 * Strict rules: zero emojis, flat high-contrast typography, clip-path 45deg cut
 */

:root {
  --stack-header-h: 44px;
  --stack-top-base: 100px;
}

/* 1. СЕКЦИЯ С ИНЖЕНЕРНОЙ СЕТКОЙ */
.fms-stack-section {
  position: relative;
  width: 100%;
  background-color: #ebebeb;
  background-image: 
    linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  padding: 24px 16px 80px;
  box-sizing: border-box;
}

.fms-stack-container {
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

/* 2. ПРИЛИПАЮЩАЯ ШАПКА С ТАБАМИ */
.fms-stack-sticky-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(235, 235, 235, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 12px 0 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.fms-stack-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.fms-stack-title-kicker {
  font-family: "Roboto Mono", "Courier New", monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #52525b;
}

.fms-stack-overall-progress {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  color: #18181b;
  background: #ffffff;
  border: 1px solid #d4d4d8;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ПАНЕЛЬ ТАБОВ-ПИЛЮЛЬ */
.fms-stack-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.fms-stack-tab-btn {
  background: #ffffff;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  padding: 6px 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: #52525b;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fms-stack-tab-btn:hover {
  border-color: #18181b;
  color: #18181b;
}

.fms-stack-tab-btn.active {
  background: #18181b;
  color: #ffffff;
  border-color: #18181b;
}

/* 3. КОНТЕЙНЕР СТЕКА КАРТОЧЕК */
.fms-stack-cards-flow {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-bottom: 140px;
}

/* 4. БАЗОВАЯ КАРТОЧКА */
.fms-stack-card {
  position: sticky;
  width: 100%;
  min-height: 40vh;
  box-sizing: border-box;
  border-radius: 18px;
  /* Срезанный под 45 градусов верхний правый угол */
  clip-path: polygon(0 0, calc(100% - 32px) 0, 100% 32px, 100% 100%, 0 100%);
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.14));
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* СТУПЕНИ ЛЕСЕНКИ (КАЖДАЯ СЛЕДУЮЩАЯ НА +44px НИЖЕ ПРЕДЫДУЩЕЙ) */
.fms-stack-card[data-card-index="0"] {
  top: var(--stack-top-base);
  z-index: 10;
}

.fms-stack-card[data-card-index="1"] {
  top: calc(var(--stack-top-base) + 44px);
  z-index: 20;
}

.fms-stack-card[data-card-index="2"] {
  top: calc(var(--stack-top-base) + 88px);
  z-index: 30;
}

.fms-stack-card[data-card-index="3"] {
  top: calc(var(--stack-top-base) + 132px);
  z-index: 40;
}

/* 5. ЦВЕТОВОЕ КОДИРОВАНИЕ КАРТОЧЕК */
/* КАРТОЧКА 01: ГРАФИТ */
.fms-stack-card--graphite {
  background: #18181b;
  color: #f4f4f5;
  border: 1px solid #27272a;
}
.fms-stack-card--graphite .fms-card-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
}
.fms-stack-card--graphite .fms-card-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.fms-stack-card--graphite .fms-card-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* КАРТОЧКА 02: КРАФТ / БЕЖ */
.fms-stack-card--kraft {
  background: #d6c3a5;
  color: #18181b;
  border: 1px solid #c2ad8d;
}
.fms-stack-card--kraft .fms-card-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.04);
}
.fms-stack-card--kraft .fms-card-item {
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.fms-stack-card--kraft .fms-card-item:hover {
  background: rgba(255, 255, 255, 0.65);
}

/* КАРТОЧКА 03: ИНДУСТРИАЛЬНЫЙ СЕРЫЙ */
.fms-stack-card--industrial {
  background: #b0b5b9;
  color: #18181b;
  border: 1px solid #9aa0a5;
}
.fms-stack-card--industrial .fms-card-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.04);
}
.fms-stack-card--industrial .fms-card-item {
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.fms-stack-card--industrial .fms-card-item:hover {
  background: rgba(255, 255, 255, 0.65);
}

/* КАРТОЧКА 04: ЧИСТО БЕЛАЯ */
.fms-stack-card--white {
  background: #ffffff;
  color: #09090b;
  border: 1px solid #e4e4e7;
}
.fms-stack-card--white .fms-card-header {
  border-bottom: 1px solid #f4f4f5;
  background: #fafafa;
}
.fms-stack-card--white .fms-card-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.fms-stack-card--white .fms-card-item:hover {
  background: #f1f5f9;
}

/* 6. ТЕХНИЧЕСКИЙ БАР (44px) */
.fms-card-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px 0 18px;
  flex-shrink: 0;
}

.fms-card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.fms-card-dots {
  letter-spacing: 2px;
  opacity: 0.6;
}

.fms-card-badge-status {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.85;
}

/* 7. ТЕЛО КАРТОЧКИ */
.fms-card-body {
  padding: 16px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fms-card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.fms-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.fms-card-stage-count {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.7;
}

/* ИНТЕРАКТИВНЫЙ СПИСОК ПУНКТОВ */
.fms-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fms-card-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.fms-card-checkbox {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: #ff451a;
  cursor: pointer;
  flex-shrink: 0;
}

.fms-card-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fms-card-item-title {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
}

.fms-card-item-desc {
  font-size: 11px;
  line-height: 1.35;
  opacity: 0.75;
}

.fms-card-item.checked .fms-card-item-title {
  text-decoration: line-through;
  opacity: 0.6;
}

.fms-card-item.checked .fms-card-item-desc {
  opacity: 0.45;
}

/* 8. ПОДВАЛ КАРТОЧКИ (ШТРИХКОД + САНПИН) */
.fms-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: auto;
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  opacity: 0.75;
}

.fms-card-barcode-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fms-card-barcode {
  background: repeating-linear-gradient(
    90deg,
    currentColor 0,
    currentColor 2px,
    transparent 2px,
    transparent 4px,
    currentColor 4px,
    currentColor 7px,
    transparent 7px,
    transparent 9px
  );
  height: 16px;
  width: 64px;
  opacity: 0.7;
}

/* ЯРКАЯ АКЦЕНТНАЯ ОРАНЖЕВАЯ КНОПКА (КАРТОЧКА 04) */
.fms-stack-btn-action {
  width: 100%;
  background: #ff451a;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(255, 69, 26, 0.35);
  margin-top: 4px;
}

.fms-stack-btn-action:hover {
  background: #e03b14;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 69, 26, 0.45);
}

.fms-stack-btn-action:active {
  transform: translateY(1px);
}

/* МОБИЛЬНЫЙ АДАПТИВ */
@media (max-width: 640px) {
  :root {
    --stack-top-base: 86px;
  }
  .fms-stack-section {
    padding: 16px 10px 60px;
  }
  .fms-stack-card {
    min-height: 42vh;
  }
  .fms-card-title {
    font-size: 14.5px;
  }
  .fms-stack-tab-btn {
    font-size: 10px;
    padding: 5px 2px;
  }
}
