/* ============================================================================
   ORTAK ÜRÜN SATIR TABLOSU — TEK KAYNAK (2026-08-04)

   Hızlı Teklif'in (/teklif — index.html thead + quote.js renderProduct) ürün
   listesi tasarımı, kullanıcı kararıyla uygulamanın TEK ürün listesi tasarımı:
   "tamamen aynısı olsun hiçbir fark istemiyorum". ERP.satir (erp-sql.js) da
   artık bu sınıfları basar (products-table / col-*).

   - Kurallar styles.css'ten KES-YAPIŞTIR taşındı; kural SIRASI korunmuştur.
     styles.css'te bu bloklardan geriye yalnız işaret yorumu kaldı.
   - Dosya index.html'de styles.css'ten HEMEN SONRA GLOBAL yüklenir
     (quote statik markup — page-loader moduleStyles onu karşılayamaz).
   - Quote'a özel kalanlar styles.css'te: .custom-select bileşeni (araç seçici
     de kullanıyor), #teklifPage.quote-wizard-enabled ezmeleri, .quote-section-card,
     .modal-image-view, genel .autocomplete-* bileşeni.
   - ERP'ye özgü davranış sınıfları (espd-sug*, espd-kod*, espd-eslesme*,
     espd-select) erp-belge-form.css'te yaşar; bu dosyada yalnız onların
     TABLO ile kesişen taşma/z-index kuralları var (sondaki ERP bölümü).
   ============================================================================ */

/* Products Table */
.products-table-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  margin: var(--spacing-md) 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  position: relative;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Custom scrollbar for table wrapper */
.products-table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.products-table-wrapper::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: 4px;
}

.products-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--color-gray-400);
  border-radius: 4px;
}

.products-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-500);
}

.products-table {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-xs);
  table-layout: auto;
}

.products-table thead {
  background: var(--color-gray-50);
  position: sticky;
  top: 0;
  z-index: 10;
}

.products-table th {
  padding: 8px var(--spacing-sm);
  text-align: left;
  font-weight: 600;
  color: var(--color-gray-700);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  font-size: var(--font-size-xs);
}

.products-table tbody tr {
  transition: all var(--transition-fast);
  background: var(--color-white);
  position: relative;
  overflow: visible;
}

/* Increase z-index when dropdown is active */
.products-table tbody tr:has(.custom-select.active),
.products-table tbody tr:has(.autocomplete-dropdown.active) {
  z-index: 10000;
}

.products-table tbody tr:nth-child(even) {
  background: var(--color-gray-50);
}

.products-table tbody tr:hover {
  background: rgba(255, 140, 0, 0.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.products-table td {
  padding: 6px var(--spacing-sm);
  border-bottom: 1px solid var(--color-border-light);
  position: relative;
  overflow: visible;
  vertical-align: middle;
  max-width: 100%;
  box-sizing: border-box;
}

.products-table .col-row-number {
  width: 40px;
  min-width: 40px;
  text-align: center;
}

.products-table .col-image {
  width: 140px;
  min-width: 140px;
}

.products-table .col-product-name {
  min-width: 200px;
  max-width: 350px;
  width: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.products-table .col-company-code,
.products-table .col-product-code {
  width: 110px;
  min-width: 110px;
}

.products-table .col-unit {
  width: 80px;
  min-width: 80px;
  position: relative;
  overflow: visible !important;
}

.products-table .col-unit-price {
  width: 110px;
  min-width: 110px;
}

.products-table .col-qty {
  width: 80px;
  min-width: 80px;
}

.products-table .col-kdv {
  width: 90px;
  min-width: 90px;
  position: relative;
  overflow: visible !important;
}

.products-table .col-discount {
  width: 64px;
  min-width: 64px;
}

.products-table .col-total {
  width: 120px;
  min-width: 120px;
}

.products-table .col-actions {
  width: 50px;
  min-width: 50px;
}

/* Compact rows: quotes are entered fast, so keep vertical rhythm tight. */
.products-table th,
.products-table td {
  padding: 6px 8px;
}

.products-table .input-line-discount {
  width: 100%;
  text-align: center;
  padding: 4px 2px;
  -moz-appearance: textfield;
}

.products-table .input-line-discount::-webkit-outer-spin-button,
.products-table .input-line-discount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firma Kodu sadece Bursa firması için gösterilir */
.products-table.hide-company-code th.col-company-code,
.products-table.hide-company-code td.col-company-code {
  display: none;
}

.products-table th.col-row-number,
.products-table th.col-image,
.products-table th.col-company-code,
.products-table th.col-product-code,
.products-table th.col-product-name,
.products-table th.col-unit,
.products-table th.col-qty,
.products-table th.col-kdv,
.products-table th.col-discount,
.products-table th.col-unit-price,
.products-table th.col-total,
.products-table th.col-actions {
  text-align: center;
}

.products-table td.col-row-number,
.products-table td.col-image,
.products-table td.col-company-code,
.products-table td.col-product-code,
.products-table td.col-unit,
.products-table td.col-qty,
.products-table td.col-kdv,
.products-table td.col-discount,
.products-table td.col-unit-price,
.products-table td.col-total,
.products-table td.col-actions {
  text-align: center;
}

.products-table td.col-product-name {
  text-align: left;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 350px;
}

.products-table .row-number {
  text-align: center;
  font-weight: 600;
  color: var(--color-gray-600);
}

/* Product Image Cell */
.product-image-cell {
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.product-image-container {
  position: relative;
  display: inline-block;
}

.products-table .product-image-container {
  width: auto;
  height: auto;
  margin-bottom: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-image-preview {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 2px solid var(--color-border);
  transition: all var(--transition-fast);
}

.product-image-preview:hover {
  border-color: var(--color-primary);
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.product-image-upload-label {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--color-white);
  transition: all var(--transition-fast);
  position: relative;
}

.product-image-upload-label:hover {
  border-color: var(--color-primary);
  background: var(--color-white);
  border-style: solid;
  transform: scale(1.05);
}

.product-image-upload-label svg {
  color: var(--color-gray-400);
  transition: color var(--transition-fast);
  pointer-events: none;
}

.product-image-upload-label:hover svg {
  color: var(--color-primary);
}

.btn-remove-product-image {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  transition: all var(--transition-fast);
}

.btn-remove-product-image:hover {
  background: #E62E24;
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.products-table input,
.products-table select,
.products-table textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-family: inherit;
  background: transparent;
  color: var(--color-black);
  transition: all var(--transition-fast);
  min-height: 38px;
  line-height: 1.4;
  vertical-align: middle;
}

.products-table td .autocomplete-wrapper {
  display: flex !important;
  position: relative;
  width: 100%;
}

.products-table td.col-product-name .autocomplete-wrapper {
  align-items: center !important;
  min-height: 48px;
  border: 1.5px solid transparent;
  transition: all var(--transition-fast);
}

.products-table .input-product-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 10px 10px;
  width: 100%;
  background: transparent;
  border: none;
  resize: none;
  overflow: hidden;
  display: block;
}

.products-table td.col-product-name .autocomplete-wrapper:focus-within {
  border-radius: var(--radius-sm);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
  border-color: var(--color-primary);
}

.products-table .input-product-name:focus {
  outline: none;
  box-shadow: none;
  background: transparent;
}

.products-table .input-product-unit,
.products-table .input-price,
.products-table .input-quantity {
  min-height: 48px;
  padding: 10px 10px;
  font-size: 13px;
}

.products-table .input-product-unit,
.products-table .input-quantity {
  padding: 4px 4px;
}

.products-table .input-quantity {
  min-height: 48px;
  padding: 10px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  -moz-appearance: textfield;
  width: 100%;
}

.products-table .input-quantity::-webkit-outer-spin-button,
.products-table .input-quantity::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.products-table .input-quantity:hover {
  border-color: var(--color-primary);
  background: var(--color-gray-100);
}

.products-table input:focus,
.products-table select:focus,
.products-table textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
}

.products-table .input-product-unit,
.products-table .input-quantity,
.products-table .input-kdv {
  text-align: center;
}

.products-table .input-price {
  text-align: right;
  padding-right: 10px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  width: 100%;
}

.products-table .input-product-code {
  text-align: center;
  min-height: 48px;
  padding: 10px 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  width: 100%;
}

.products-table .input-product-name,
.products-table .input-product-code {
  text-transform: uppercase;
}

/* KDV Select - Compact style */
.products-table .input-kdv {
  text-align: center !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--color-gray-800) !important;
  background: var(--color-bg-tertiary) !important;
  background-color: var(--color-bg-tertiary) !important;
  padding: 10px 30px 10px 10px !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer !important;
  min-width: 74px !important;
  width: 100% !important;
  min-height: 48px !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  position: relative !important;
  display: block !important;
  line-height: 1.4 !important;
  box-sizing: border-box !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

/* Custom dropdown arrow */
.products-table td:has(.input-kdv) {
  position: relative;
}

.products-table td:has(.input-kdv)::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8L10 12L14 8'/%3E%3C/svg%3E") no-repeat center;
  background-size: 12px 12px;
  opacity: 0.7;
  pointer-events: none;
  z-index: 10;
  line-height: 1;
}

.products-table .input-kdv:focus {
  border-color: var(--color-primary) !important;
  background: var(--color-white) !important;
  background-color: var(--color-white) !important;
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.12) !important;
  outline: none !important;
}

.products-table .input-kdv:hover {
  border-color: var(--color-primary) !important;
  background: var(--color-gray-100) !important;
  background-color: var(--color-gray-100) !important;
}

.products-table .input-kdv option {
  color: var(--color-gray-800) !important;
  background: var(--color-white) !important;
  background-color: var(--color-white) !important;
  padding: 12px !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

/* Unit (custom select) size to match quantity/price */
.products-table .custom-select-trigger {
  min-height: 48px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Force selected value visibility */
.products-table .input-kdv,
.products-table .input-kdv:not([multiple]),
.products-table .input-kdv[value] {
  color: var(--color-gray-800) !important;
}

/* Override any inherited transparent backgrounds */
.products-table td .input-kdv {
  background-image: none !important;
}

.products-table .product-total {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  display: block;
  text-align: right;
  padding-right: var(--spacing-sm);
}

.products-table .action-buttons-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.products-table .btn-remove-product,
.products-table .btn-insert-product {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-gray-500);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.products-table .btn-remove-product:hover {
  background: var(--color-danger);
  color: var(--color-white);
  transform: scale(1.1);
}

.products-table .btn-insert-product {
  font-size: 16px;
}

.products-table .btn-insert-product:hover {
  background: var(--color-primary);
  color: var(--color-white);
  transform: scale(1.1);
}

/* Collapse toggle + mobile summary cell are mobile-only (see mobile media queries below) */
.products-table .btn-toggle-row-collapse,
.products-table .col-mobile-brief {
  display: none;
}

/* "⋯" secondary-actions menu. On desktop the wrappers are transparent
   (display: contents) so insert/remove render inline exactly as before and
   the ⋯ toggle + text labels stay hidden. The mobile media query below turns
   it into a real popover. */
.products-table .product-row-more,
.products-table .product-row-more-menu {
  display: contents;
}

.products-table .btn-row-more,
.products-table .row-more-label {
  display: none;
}

/* Add Product Button */
.btn-add-product {
  width: 100%;
  padding: 10px var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  background: var(--color-bg-tertiary);
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add-product:hover {
  background: var(--color-primary);
  color: var(--color-white);
  border-style: solid;
  transform: scale(1.01);
}

.btn-add-product svg {
  transition: transform var(--transition-fast);
}

.btn-add-product:hover svg {
  transform: rotate(90deg);
}

/* Autocomplete katmanı — tablo ile kesişen z-index kuralları
   (genel .autocomplete-* bileşeni styles.css'te) */
.products-table td {
  position: relative;
  z-index: 1;
  overflow: visible;
}

.products-table td .autocomplete-wrapper {
  z-index: 10001;
  position: relative;
}

.products-table tbody {
  position: relative;
}

/* Ürün Adı hücresindeki seçici tetiği. Alan "sessiz grid" olduğu için buton da
   sessiz durur; satır hover'ında ya da odakta belirginleşir. */
.col-product-name .autocomplete-wrapper {
  position: relative;
}

.col-product-name .input-product-name {
  padding-right: 26px;
}

/* Dikey ORTALI: ürün adı sarınca textarea büyüyor (resizeProductNameInput) ve
   köşeye çivili buton alanın dışına düşmüş gibi duruyordu.
   ⚠ `transform` YALNIZ butonda kalmalı — sarmalayıcıya ya da hücreye taşınırsa
   öneri listesinin portal katmanı (position:fixed) transform'lu ataya göre
   kırpılır; quote.js:searchProducts yorumu bu tuzağı anlatıyor. */
.btn-product-browse {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 3px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-gray-400, #9ca3af);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.product-row:hover .btn-product-browse,
.btn-product-browse:hover,
.btn-product-browse:focus-visible {
  opacity: 1;
  background: var(--color-gray-100, #f3f4f6);
  color: var(--color-primary, #ff8c00);
}

.btn-product-browse[hidden] {
  display: none !important;
}

/* ============================================================================
   ERP eklentileri — quote'ta karşılığı olmayan, ortak tabloya ERP.satir'ın
   getirdiği parçalar. Görsel dil yukarıdaki quote spec'iyle birebir.
   ============================================================================ */

/* ERP satır bileşeninin kökü (espd-satirlar erp-belge-form.css'te kalır;
   buradaki kurallar yalnız tablo-kesişimi). Öneri kutusu (espd-sug) inline
   position:absolute — açıkken kaydırma kabı paneli KIRPMASIN (erp-belge-form
   .espd-tablewrap:has() kuralının products-table eşleniği). */
.products-table-wrapper:has(.espd-sug:not([hidden])) { overflow: visible; }

/* açık öneri listesi diğer satırların üstünde kalsın */
.products-table tbody tr:has(.espd-sug:not([hidden])) { position: relative; z-index: 30; }
.products-table td:has(.espd-sug:not([hidden])) { z-index: 40; }

/* Depo kolonu — yalnız ERP formlarında (mal girişi, mal kabul, iade kabul,
   sipariş revizyonu). Quote'ta yok; genişlik cömert model ile uyumlu. */
.products-table .col-depo {
  width: 130px;
  min-width: 130px;
  position: relative;
  overflow: visible !important;
}

.products-table th.col-depo,
.products-table td.col-depo {
  text-align: center;
}

/* Birim seçicisi — ERP native <select> (ERP.birimSelectHtml; birim elle
   yazılmaz kuralı). Kapalı halde quote'un custom-select-trigger'ı ile
   piksel-aynı: .input-kdv spec'inin birebir eşleniği. Ok, td:has()::after
   ile gelir — select'e background KISAYOLU yazmak oku SİLMEZ (espd-select
   tuzağının aksine), yine de yazma. */
.products-table .input-unit-select {
  text-align: center !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--color-gray-800) !important;
  background: var(--color-bg-tertiary) !important;
  background-color: var(--color-bg-tertiary) !important;
  padding: 10px 30px 10px 10px !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer !important;
  min-width: 64px !important;
  width: 100% !important;
  min-height: 48px !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  display: block !important;
  line-height: 1.4 !important;
  box-sizing: border-box !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  background-image: none !important;
}

.products-table td:has(.input-unit-select)::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8L10 12L14 8'/%3E%3C/svg%3E") no-repeat center;
  background-size: 12px 12px;
  opacity: 0.7;
  pointer-events: none;
  z-index: 10;
  line-height: 1;
}

.products-table .input-unit-select:focus {
  border-color: var(--color-primary) !important;
  background: var(--color-white) !important;
  background-color: var(--color-white) !important;
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.12) !important;
  outline: none !important;
}

.products-table .input-unit-select:hover {
  border-color: var(--color-primary) !important;
  background: var(--color-gray-100) !important;
  background-color: var(--color-gray-100) !important;
}

/* Yazılabilir satır toplamı (ERP tutarYazilir kipi — talep formu, 2026-08-04
   kullanıcı isteği). Görünüm quote'un .product-total'ı ile birebir; input
   olduğu belli olmasın diye çerçevesiz, odakta genel input halkası gelir. */
.products-table .product-total-input {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  display: block;
  text-align: right;
  padding-right: var(--spacing-sm);
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: 38px;
  font-size: var(--font-size-xs);
}

.products-table .product-total-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-white);
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
  color: var(--color-primary);
}

/* Boş liste durumu + ekle düğmesi arası (espd-add kuralının btn-add-product eşi) */
.espd-satirlar > .erp-state + .btn-add-product {
  margin-top: var(--spacing-sm);
}

/* Seçim tabloları (fatura kes sipariş/irsaliye, mal kabul paneli) sayı
   kolonlarını sağa yaslar — erp-table'daki .num geleneğinin buradaki eşi. */
.products-table th.num,
.products-table td.num {
  text-align: right;
}

/* UrunGorsel tam ekran görüntüleme — kendi overlay'i (quote .modal-image-view
   modalına bağlanılmaz: çifte handler riski). */
#ugLightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2400;
  background: rgba(0, 0, 0, 0.82);
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

#ugLightbox.open {
  display: flex;
}

#ugLightbox img {
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  background: var(--color-white);
}

/* UrunGorsel kırpma overlay'i — quote crop modalının işlevsel eşi (kendi ID'si). */
#ugCrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2400;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#ugCrop.open { display: flex; }

#ugCrop .ug-crop-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(94vw, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#ugCrop .ug-crop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

#ugCrop .ug-crop-busy { font-size: 12px; color: var(--color-gray-500); }

#ugCrop .ug-crop-body {
  background: var(--color-gray-100);
  max-height: 60vh;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ugCrop .ug-crop-body img { max-width: 100%; max-height: 60vh; display: block; }

#ugCrop .ug-crop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

#ugCrop .ug-crop-ratios,
#ugCrop .ug-crop-actions { display: inline-flex; gap: 8px; }

#ugCrop .ug-crop-foot button {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-white);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#ugCrop .ug-crop-ratios button.active,
#ugCrop .ug-crop-foot button.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

#ugCrop .ug-crop-foot button:disabled { opacity: 0.5; cursor: default; }

/* ===== Mobile & Tablet Responsive ===== */
@media (max-width: 1024px) {

  /* Tablet optimizations */
  .products-table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .products-table {
    font-size: var(--font-size-xs);
    min-width: 800px;
  }

  .products-table th,
  .products-table td {
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .products-table .input-kdv {
    font-size: 13px !important;
    padding: 8px 30px 8px 12px !important;
    min-width: 76px !important;
  }

  .products-table td:has(.input-kdv)::after {
    right: 14px;
    width: 12px;
    height: 12px;
    background-size: 12px 12px;
  }
}

@media (max-width: 768px) {

  /* ==========================================
     MOBILE PRODUCT CARD VIEW (REFINED GRID)
     ========================================== */
  .products-table-wrapper {
    background: transparent;
    border: none;
    overflow: visible;
    margin: 10px 0 40px 0;
    /* Extra bottom margin */
  }

  .products-table {
    display: block;
    min-width: 100%;
    background: transparent;
  }

  /* Hide Table Header */
  .products-table thead {
    display: none;
  }

  .products-table tbody {
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Increased gap */
  }

  /* Card Container - CSS Grid */
  .products-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-radius: 20px;
    /* More rounded */
    padding: 20px;
    /* Header strip holds the row-number badge and the 44px action buttons. */
    padding-top: 64px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    /* Premium shadow */
    position: relative;
    align-items: start;
    transition: transform 0.2s ease;
  }

  .products-table tr:focus-within {
    transform: translateY(-2px);
    border-color: var(--color-primary-light);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    /* Lift on focus */
  }

  /* A `transform` here creates a new containing block, which hijacks fixed
     birim/KDV and product-autocomplete panels. Drop the lift instantly while
     either dropdown is open so viewport coordinates stay viewport-relative. */
  .products-table tr:focus-within:has(.custom-select.active),
  .products-table tr:focus-within:has(.autocomplete-dropdown.active) {
    transform: none;
    transition: transform 0s;
  }

  /* Reset TD styles for Grid Items */
  .products-table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    border: none;
    width: auto;
    gap: 6px;
    min-height: 0;
    position: relative;
  }

  /* Label Styling - Premium Look */
  .products-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-left: 2px;
    width: 100%;
  }

  /* Input Styling - Premium Look - High Specificity to override desktop */
  .products-table input,
  .products-table select,
  .products-table .input-product-code,
  .products-table .input-price,
  .products-table .input-quantity,
  .products-table .input-product-unit,
  .products-table .input-kdv {
    width: 100% !important;
    text-align: left !important;
    border: 1px solid var(--color-border) !important;
    background: var(--color-white) !important;
    /* 16px minimum: iOS Safari auto-zooms the page when focusing an input
       with a smaller font, which is the "garip"/jumpy feel on mobile. */
    font-size: 16px !important;
    font-weight: 500;
    color: var(--color-gray-800);
    padding: 12px !important;
    border-radius: 12px !important;
    height: 48px !important;
    min-height: 48px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    -webkit-appearance: none;
    appearance: none;
    opacity: 1 !important;
  }

  /* Textarea Specific (Flexible Height for Auto-Resize) */
  .products-table textarea,
  .products-table .input-product-name {
    width: 100% !important;
    text-align: left !important;
    border: 1px solid var(--color-border) !important;
    background: var(--color-white) !important;
    /* 16px minimum: prevents iOS Safari focus zoom (see input rule above). */
    font-size: 16px !important;
    font-weight: 500;
    color: var(--color-gray-800);
    padding: 12px !important;
    border-radius: 12px !important;
    min-height: 48px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    -webkit-appearance: none;
    appearance: none;
    opacity: 1 !important;
  }

  .products-table input:focus,
  .products-table select:focus {
    background: var(--color-white);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
  }

  .products-table .input-quantity,
  .products-table .input-kdv {
    text-align: center !important;
    font-weight: 600;
    background: var(--color-bg-tertiary) !important;
    font-variant-numeric: tabular-nums;
  }

  /* Birim fiyat otherwise falls under the generic "text-align: left" mobile
     input rule and looks misaligned next to the centered Miktar field. */
  .products-table .input-price {
    text-align: center !important;
  }

  /* === GRID PLACEMENT & VISIBILITY === */

  .products-table textarea:focus {
    background: var(--color-white);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
    outline: none;
  }

  /* Row Number - Badge Style */
  .products-table td.col-row-number {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
    border-radius: 50%;
    /* Circle badge */
    font-size: 13px;
    padding: 0;
  }

  .products-table td.col-row-number::before {
    display: none;
  }

  /* Delete Action - Top Right */
  .products-table td.col-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    width: auto;
    z-index: 5;
  }

  /* ⋯ menü açıkken: aksiyon hücresini ürün-adı hücresinin (z:20) üstüne
     çıkar; aksi halde popover ürün içeriğinin ARKASINDA kalıyordu. */
  .products-table td.col-actions:has(.product-row-more.is-open) {
    z-index: 100;
  }

  .products-table td.col-actions::before {
    display: none;
  }

  .products-table td.col-actions .btn-icon-danger {
    width: 36px;
    height: 36px;
    background: var(--color-gray-50);
    color: var(--color-gray-400);
    border-radius: 50%;
    transition: all 0.2s;
  }

  .products-table td.col-actions .btn-icon-danger:active {
    background: var(--color-danger-light);
    color: var(--color-danger);
  }

  /* Product Name - High priority & Z-Index fix */
  .products-table td.col-product-name {
    grid-column: 1 / -1;
    order: 1;
    margin-bottom: 24px;
    /* CRITICAL FIX for Autocomplete Z-Index */
    z-index: 20;
  }

  /* Ensure the dropdown container breaks out */
  .products-table td.col-product-name .autocomplete-wrapper {
    position: relative;
    width: 100%;
  }

  .products-table td.col-product-name .autocomplete-dropdown {
    width: 100%;
    top: 100%;
    left: 0;
    margin-top: 4px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--color-gray-100);
  }

  /* Image - Centered Top */
  .products-table td.col-image {
    display: flex;
    grid-column: 1 / -1;
    order: 0;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    padding-top: 4px;
  }

  .products-table td.col-image::before {
    display: none;
  }

  /* Normalize field widths inside the grid */
  .products-table td.col-company-code,
  .products-table td.col-product-code,
  .products-table td.col-unit-price,
  .products-table td.col-qty,
  .products-table td.col-unit,
  .products-table td.col-discount,
  .products-table td.col-kdv,
  .products-table td.col-depo {
    width: 100%;
    min-width: 0;
  }

  /* Codes - Half Width Each */
  .products-table td.col-company-code {
    order: 2;
    z-index: 10;
  }

  .products-table td.col-product-code {
    order: 3;
    z-index: 10;
  }

  /* Qty, Unit, Unit Price */
  .products-table td.col-qty {
    order: 4;
    z-index: 5;
  }

  .products-table td.col-unit {
    order: 5;
    z-index: 4;
  }

  .products-table td.col-unit-price {
    order: 6;
    z-index: 5;
  }

  .products-table td.col-discount {
    order: 7;
    z-index: 4;
  }

  .products-table td.col-kdv {
    order: 8;
    z-index: 4;
  }

  /* Depo (yalnız ERP formları) — KDV'den sonra, toplamdan önce */
  .products-table td.col-depo {
    order: 9;
    z-index: 4;
  }

  /* Total - Clean Row */
  .products-table td.col-total {
    grid-column: 1 / -1;
    order: 10;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px dashed var(--color-border);
    width: 100%;
    border-radius: 0;
  }

  .products-table td.col-total::before {
    width: auto;
    margin: 0;
    content: "SATIR TOPLAMI";
    font-size: 11px;
    color: var(--color-gray-500);
    font-weight: 700;
  }

  .products-table td.col-total {
    font-size: 18px;
    font-weight: 800;
    /* Extra bold for numbers */
    color: var(--color-primary);
    font-family: 'SF Mono', 'Consolas', monospace;
    /* Technical look for numbers */
  }

  /* Manual Labels — data-label taşıyan hücrede attr kazanır (:not guard):
     ERP'nin özel başlıkları ("Fark Tutarı", "Giriş Deposu") mobilde de doğru
     görünsün. Quote'un data-label'lı hücrelerinde attr değeri buradaki sabit
     metinle ZATEN aynı — quote görünümü değişmez. KDV ve İskonto sabit
     (guard'sız): iki sistemde de aynı etiket ("KDV Oranı", "İskonto %"). */
  .products-table td.col-company-code:not([data-label])::before {
    content: "Firma Kodu";
  }

  .products-table td.col-product-code:not([data-label])::before {
    content: "Ürün Kodu";
  }

  .products-table td.col-product-name:not([data-label])::before {
    content: "Ürün Adı";
  }

  .products-table td.col-unit:not([data-label])::before {
    content: "Birim";
  }

  .products-table td.col-unit-price:not([data-label])::before {
    content: "Birim Fiyat";
  }

  .products-table td.col-qty:not([data-label])::before {
    content: "Miktar";
  }

  .products-table td.col-kdv::before {
    content: "KDV Oranı";
  }

  .products-table td.col-discount::before {
    content: "İskonto %";
  }

  /* Collapsed mobile card: show compact summary, hide edit fields except image/total */
  .products-table tr:not(.is-collapsed) td.col-mobile-brief {
    display: none;
  }

  .products-table tr.is-collapsed td.col-mobile-brief {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    grid-column: 2 / -1;
    grid-row: 1;
    min-width: 0;
  }

  .products-table tr.is-collapsed td.col-product-name,
  .products-table tr.is-collapsed td.col-company-code,
  .products-table tr.is-collapsed td.col-product-code,
  .products-table tr.is-collapsed td.col-qty,
  .products-table tr.is-collapsed td.col-unit,
  .products-table tr.is-collapsed td.col-unit-price,
  .products-table tr.is-collapsed td.col-discount,
  .products-table tr.is-collapsed td.col-kdv {
    display: none;
  }

  .mobile-brief-name {
    width: 100%;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-brief-meta {
    width: 100%;
    min-width: 0;
    font-size: 12px;
    color: var(--color-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .products-table .action-buttons-group {
    gap: 6px;
  }

  /* 44px min tap target (iOS HIG). The cramped 34px cluster made it easy to
     hit the wrong button — especially delete. */
  .products-table .btn-toggle-row-collapse,
  .products-table .btn-insert-product,
  .products-table .btn-remove-product {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  /* Set delete apart visually and by distance so it is not tapped by mistake. */
  .products-table .btn-remove-product {
    margin-left: 4px;
    color: var(--color-danger);
    background: rgba(255, 59, 48, 0.1);
    border-radius: 50%;
  }

  .products-table .btn-remove-product:active {
    background: var(--color-danger);
    color: var(--color-white);
  }

  .products-table .btn-toggle-row-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-gray-500);
    cursor: pointer;
  }

  .products-table .btn-toggle-row-collapse:active {
    background: var(--color-gray-100);
  }

  .row-toggle-icon {
    display: inline-block;
    font-size: 16px;
    line-height: 1;
    transition: transform 0.15s ease;
  }

  .product-row:not(.is-collapsed) .row-toggle-icon {
    transform: rotate(180deg);
  }

  /* "⋯" secondary-actions menu — mobile popover. Only Sil stays visible on
     the card; collapse + insert move into this menu to cut the clutter. */
  .products-table .product-row-more {
    display: block;
    position: relative;
  }

  .products-table .btn-row-more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--color-gray-500);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .products-table .product-row-more.is-open .btn-row-more {
    background: var(--color-gray-100);
  }

  .products-table .product-row-more-menu {
    display: none;
    position: absolute;
    z-index: 60;
    top: calc(100% + 6px);
    right: 0;
    flex-direction: column;
    gap: 2px;
    min-width: 210px;
    padding: 6px;
    border-radius: 14px;
    background: #fff;
    border: 0.5px solid var(--color-border);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
  }

  .products-table .product-row-more.is-open .product-row-more-menu {
    display: flex;
  }

  /* Lift the whole card (and its z-index:60 menu) above the fixed wizard
     footer (z-index 2001) while the ⋯ menu is open, so a last-row menu is not
     occluded by the footer. */
  .products-table tr:has(.product-row-more.is-open) {
    z-index: 2100;
  }

  .products-table .product-row-more-menu .btn-toggle-row-collapse,
  .products-table .product-row-more-menu .btn-insert-product {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 46px;
    padding: 8px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #2b3648;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
  }

  .products-table .product-row-more-menu .btn-toggle-row-collapse:active,
  .products-table .product-row-more-menu .btn-insert-product:active {
    background: var(--color-gray-100);
  }

  .products-table .product-row-more-menu .row-more-label {
    display: inline;
  }

  .products-table .product-row-more-menu .row-toggle-icon,
  .products-table .product-row-more-menu .row-more-glyph {
    width: 20px;
    font-size: 16px;
    text-align: center;
  }

  /* KDV/Unit Select Tweaks */
  .products-table select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

  .products-table .input-kdv {
    padding: 12px !important;
    min-width: 0 !important;
  }

  .products-table td:has(.input-kdv)::after {
    display: none;
    /* Hide custom arrow if we use native select styling */
  }

  .products-table .input-unit-select {
    padding: 12px !important;
    min-width: 0 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
  }

  .products-table td:has(.input-unit-select)::after {
    display: none;
  }

  /* Add Product Button - Premium Dashed */
  .btn-add-product {
    padding: 16px;
    font-size: 16px;
    min-height: 56px;
    font-weight: 600;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(var(--color-primary-rgb), 0.03);
    color: var(--color-primary);
    border: 2px dashed rgba(var(--color-primary-rgb), 0.3);
    transition: all 0.2s;
    margin-top: 8px;
  }

  .btn-add-product:active {
    background: rgba(var(--color-primary-rgb), 0.08);
    border-color: var(--color-primary);
    transform: scale(0.98);
  }
}
