/* REDESIGN-2026 · S2 — أصناف شاشات المشتريات والمقايسة والأسعار (`s2-*`). الجلسة S2 بس اللي بتكتب هنا. */

/* ── W03 / M04 · المشتريات ─────────────────────────────────────────── */
.s2-screen {
  /* ابن شبكة: من غير `min-width: 0` شريط التبويبات (nowrap) بيمدّ الشاشة برّه الموبايل. */
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: var(--ty-text);
  font-family: var(--ty-font-body);
  font-variant-numeric: tabular-nums;
}
.s2-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.s2-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.s2-step {
  flex-shrink: 0;
  min-height: var(--ty-touch);
  padding: 0 16px;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-s);
  background: var(--ty-surface);
  color: var(--ty-text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.s2-step[aria-selected="true"] {
  border-color: var(--ty-charcoal);
  background: var(--ty-charcoal);
  color: #ffffff;
  font-weight: 700;
}
.s2-step:focus-visible,
.s2-open:focus-visible,
.s2-more__link:focus-visible {
  outline: 3px solid var(--ty-green);
  outline-offset: 2px;
}
.s2-step__count {
  font-weight: 500;
  opacity: 0.7;
}
.s2-step__arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--ty-text-4);
}
.s2-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.s2-hint {
  margin: 0;
  color: var(--ty-text-2);
  font-size: 15px;
  line-height: 1.6;
}
.s2-card-search {
  display: flex;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.s2-card-search .ty-search input {
  width: 100%;
  min-width: 0;
}
.s2-card-search .ty-search {
  flex: 1;
  /* عنصر مرن: من غيرها حقل البحث بياخد عرضه الطبيعي ويخرج من البطاقة على الموبايل. */
  min-width: 0;
  max-width: 360px;
}
.s2-card-scroll {
  overflow-x: auto;
}
.s2-table {
  font-size: 15px;
}
.s2-table td {
  vertical-align: middle;
}
.s2-open {
  display: block;
  width: 100%;
  min-height: var(--ty-touch);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ty-text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
.s2-muted {
  color: var(--ty-text-2);
}
.s2-none {
  margin: 0;
  padding: 20px;
  color: var(--ty-text-3);
  font-size: 14px;
}
.s2-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  color: var(--ty-text-2);
  font-size: 14px;
}
.s2-extra b {
  color: var(--ty-text);
  font-size: 16px;
}
.s2-more,
.s2-fab {
  display: none;
}

@media (max-width: 640px) {
  .s2-screen {
    gap: 14px;
  }
  /* PHONE-FIT: خطوات الشراء كلها باينة — تنزل سطر تاني بدل ما تتسحب يمين وشمال. */
  .s2-steps {
    flex-wrap: wrap;
    width: 100%;
    padding-bottom: 4px;
  }
  .s2-step__arrow,
  .s2-bar .s2-primary {
    display: none;
  }
  .s2-hint {
    font-size: 14px;
  }
  .s2-card-search .ty-search {
    max-width: none;
  }
  .s2-table td:first-child {
    flex: 1 1 100%;
  }
      .s2-more {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .s2-more__title {
    margin: 0;
    color: var(--ty-text-3);
    font-size: 14px;
    font-weight: 600;
  }
  .s2-more__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .s2-more__link {
    min-height: var(--ty-touch);
    padding: 0 16px;
    border: 1px solid var(--ty-line);
    border-radius: var(--ty-radius-s);
    background: var(--ty-surface);
    color: var(--ty-text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
  }
  .s2-fab {
    position: fixed;
    inset-inline: 0;
    bottom: var(--ty-tabbar-h);
    z-index: 2;
    display: block;
    padding: 10px 12px;
    background: var(--ty-bg);
  }
  /* مكان الزر الثابت: آخر صف ما يستخباش وراه. */
  .s2-screen:has(.s2-fab) {
    padding-bottom: 76px;
  }
}

/* ── رأس الشاشة (الشاشة المسجّلة بترسم رأسها بنفسها) ─────────────────── */
.s2-head {
  display: flex;
  flex-direction: column;
}
.s2-head__title {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 28px;
  font-weight: 700;
}

/* ── صفحات السجل في المشتريات ───────────────────────────────────────── */
/* زر «⋯» مالوش قائمة لسه في شاشات S2 (REQUESTS-S2) — زر من غير وظيفة ما يتعرضش. */
.s2-screen [data-record-menu] {
  display: none;
}
.s2-record-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.s2-decide {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--ty-line);
  border-radius: var(--ty-radius-m);
  background: var(--ty-warn-bg);
  color: var(--ty-warn-fg);
  font-size: 15px;
  font-weight: 600;
}
.s2-cell-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
/* INVOICE-FIELDS: صورة الفاتورة في تبويبها — على قد العمود، من غير ما تمدّ الصفحة. */
.s2-invoice-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin-top: 12px;
  border: 1px solid var(--ty-line);
  border-radius: 8px;
}
.s2-cell-note {
  display: block;
  color: var(--ty-text-3);
  font-size: 14px;
  font-weight: 400;
}

@media (max-width: 640px) {
  .s2-head__title {
    font-size: 24px;
  }
  .s2-screen--record {
    gap: 12px;
  }
}

/* ── W17 · المقايسة ──────────────────────────────────────────────────── */
.s2-head--row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.s2-head--row .ty-crumbs {
  margin-bottom: 4px;
}
.s2-tabs {
  padding: 0;
}
.s2-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.s2-filter .ty-search {
  flex: 1 1 240px;
  min-width: 0;
  max-width: 360px;
}
.s2-filter .ty-search input {
  width: 100%;
  min-width: 0;
}
.s2-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--ty-touch);
  color: var(--ty-text-2);
  font-size: 14px;
  cursor: pointer;
}
.s2-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--ty-green);
}
.s2-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.s2-code {
  font-weight: 700;
}
.s2-unit {
  color: var(--ty-text-3);
  font-size: 14px;
}
.s2-meter {
  width: 110px;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--ty-mute-bg);
  appearance: none;
}
.s2-meter::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--ty-mute-bg);
}
.s2-meter::-webkit-progress-value {
  border-radius: 999px;
  background: var(--ty-green);
}
.s2-meter::-moz-progress-bar {
  border-radius: 999px;
  background: var(--ty-green);
}
.s2-meter--over::-webkit-progress-value {
  background: var(--ty-danger);
}
.s2-meter--over::-moz-progress-bar {
  background: var(--ty-danger);
}
.s2-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}
.s2-total td {
  background: var(--ty-surface-2);
}
.s2-section__head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ty-line-soft);
}
.s2-section__head h2 {
  margin: 0;
  font-family: var(--ty-font-head);
  font-size: 17px;
  font-weight: 700;
}
.s2-section__head span {
  color: var(--ty-text-3);
  font-size: 14px;
}
.s2-section__head .s2-section__sum {
  color: var(--ty-bad-fg);
  font-weight: 600;
}
.s2-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--ty-line-soft);
  font-size: 15px;
}
.s2-row:first-of-type {
  border-top: 0;
}

@media (max-width: 640px) {
  .s2-head--row {
    align-items: stretch;
  }
  .s2-head--row .s2-actions .ty-btn {
    flex: 1;
  }
  .s2-filter {
    padding: 12px;
  }
  .s2-filter .ty-search {
    max-width: none;
  }
  .s2-row,
  .s2-section__head {
    padding-inline: 12px;
  }
  /* على الموبايل الصف بطاقة: اسم البند سطر كامل، والأرقام تحته بعناوينها. */
  .s2-table--boq td:first-child,
  .s2-table--cost td:first-child {
    flex: 1 1 100%;
  }
  .s2-table--boq td[data-label]::before,
  .s2-table--cost td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--ty-text-3);
    font-size: 14px;
  }
  /* AUDIT-1022 · 7: الشريحة («من غير توقع»/الفرق) والزر كانوا بيلفّوا مع الأرقام فكل بطاقة شكل —
     الشريحة مرة يمين ومرة شمال والزر تحتها أو جنبها. دلوقتي كل بطاقة نفس الترتيب: الأرقام، ثم
     الشريحة في سطرها، ثم الزر بعرض البطاقة. */
  .s2-table--cost td:nth-last-child(2) {
    flex: 1 1 100%;
  }
  .s2-table--cost td:last-child {
    flex: 1 1 100%;
  }
  .s2-table--cost td:last-child .ty-btn {
    width: 100%;
  }
}

/* AUDIT-1022 · 8: على الكمبيوتر عمود الزر الأخير كان أضيق من «تسجيل توقع» فالزر بيتكسر سطرين. */
.s2-table--cost .ty-btn {
  white-space: nowrap;
}

/* ── W18 تحليل الأسعار · W19 فروق الأسعار ───────────────────────────── */
.s2-split {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}
.s2-split__main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.s2-picker h2 {
  margin: 0;
  padding: 16px 16px 8px;
  font-family: var(--ty-font-head);
  font-size: 16px;
  font-weight: 700;
}
.s2-picker__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 520px;
  padding: 0 8px 12px;
  overflow-y: auto;
}
.s2-pick {
  min-height: var(--ty-touch);
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--ty-radius-s);
  background: transparent;
  color: var(--ty-text);
  font-family: inherit;
  font-size: 15px;
  text-align: start;
  cursor: pointer;
}
.s2-pick[aria-pressed="true"] {
  border-color: var(--ty-green);
  background: var(--ty-green-soft);
  font-weight: 600;
}
.s2-pick:focus-visible {
  outline: 3px solid var(--ty-green);
  outline-offset: 2px;
}
.s2-section__head--row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}
.s2-kv {
  padding: 4px 20px 12px;
}

@media (max-width: 900px) {
  .s2-split {
    grid-template-columns: minmax(0, 1fr);
  }
  .s2-picker__list {
    flex-direction: row;
    max-height: none;
    padding-bottom: 12px;
    overflow-x: auto;
  }
  .s2-pick {
    flex-shrink: 0;
    border-color: var(--ty-line);
    white-space: nowrap;
  }
}
@media (max-width: 640px) {
  .s2-kv {
    padding-inline: 12px;
  }
}
/* SERVER-CARDS ج11 · مدخلات ناتج فروق الأسعار تحت كل مستخلص: سطر اللمس 48px. */
.s2-esc-inputs > summary {
  padding-block: 14px;
  cursor: pointer;
}
.s2-nowrap {
  white-space: nowrap;
}
.s2-esc-inputs ul {
  margin: 0;
  padding-inline-start: 20px;
}
