/* ════════════════════════════════════════
   Product Card Modal + Modals
   ── ВАЖНО: voltstock-design.css/components.css уже определяют .modal
   (как content-card), .modal-backdrop (display:none), .tabs-bar/.tab-panel,
   #photo-viewer (z-index:2000). product-card.css грузится последним и
   полностью перекрывает эти правила нейтрализующими свойствами.
   ════════════════════════════════════════ */

/* MODAL BASE */
.modal {
  position: fixed; inset: 0; z-index: 9000;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  /* нейтрализация shared .modal (там .modal = content-card) */
  background: transparent; border: 0; border-radius: 0;
  width: auto; max-height: none; overflow: visible;
  box-shadow: none; animation: none; margin: 0;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* нейтрализация shared .modal-backdrop (там display:none, position:fixed, z-index:modal) */
  display: block; z-index: 0; padding: 0; animation: none;
}
.modal-content {
  position: relative;
  background: var(--bg-elevated, #161C26);
  border: 1px solid var(--border-default, #2A3140);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  max-width: 1100px; width: 100%;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.small-modal .modal-content { max-width: 560px; }
.medium-modal .modal-content { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-default);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* PRODUCT MODAL */
.product-modal-content { max-width: 1100px; }
.pm-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}
.pmh-left { flex: 1; min-width: 0; }
.pmh-badges {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.pm-name {
  font-size: 16px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pmh-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.tag {
  display: inline-block;
  padding: 3px 8px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

/* TABS */
.tabs-bar {
  display: flex; gap: 4px;
  padding: 8px 20px 0;
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
  /* нейтрализация shared .tabs-bar (position:sticky;top:57px;background) */
  position: static; top: auto; background: transparent;
}
.tab-btn {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary, #8B98A8);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent, #10E089);
  border-bottom-color: var(--accent);
}
.tab-panels { flex: 1; overflow-y: auto; padding: 20px; }
.tab-panel { display: none; padding: 0; }
.tab-panel.active { display: block; }

/* PM FIELDS */
.pm-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 700px) {
  .pm-info-grid { grid-template-columns: 1fr; gap: 16px; }
}
.pm-col { display: flex; flex-direction: column; gap: 14px; }
.pm-field { display: flex; flex-direction: column; gap: 5px; }
.pm-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #6B7280);
  font-weight: 600;
}
.pm-field label .hint {
  font-weight: 400; text-transform: none; letter-spacing: 0;
  color: var(--text-muted); font-size: 11px;
}
.pm-input {
  padding: 8px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}
.pm-input:focus { outline: none; border-color: var(--accent); }
.pm-input.mono { font-family: 'JetBrains Mono', monospace; }
.pm-value { color: var(--text-primary); font-size: 13px; padding: 4px 0; }
.pm-row { display: flex; gap: 6px; align-items: center; }
.pm-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.pm-checkbox {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; cursor: pointer; font-size: 12px;
}

.pm-cost-block {
  display: flex; align-items: center; gap: 4px;
}
.pm-cost-block .unit { color: var(--text-muted); font-size: 13px; }

.btn-block { width: 100%; }

/* LOC SUGGESTIONS */
.loc-suggestions { margin-top: 6px; }
.loc-chips-label { font-size: 10px; color: var(--text-muted); margin-top: 6px; margin-bottom: 4px; }
.loc-chips-row { display: flex; flex-wrap: wrap; gap: 4px; }
.loc-chip {
  background: var(--bg-base); border: 1px solid var(--border-default);
  padding: 3px 8px; border-radius: 12px;
  font-size: 11px; font-family: 'JetBrains Mono', monospace;
  cursor: pointer; transition: background 0.1s;
}
.loc-chip:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.chip-count { color: var(--text-muted); font-size: 9px; }

/* FRESHNESS */
.freshness-fresh { color: #22C55E; }
.freshness-warm { color: #F59E0B; }
.freshness-stale { color: #EF4444; }
.freshness-never { color: #6B7280; }

/* PHOTOS TAB */
.pm-main-photo {
  margin-bottom: 16px; text-align: center;
}
.pm-main-photo img {
  max-width: 100%; max-height: 400px;
  border-radius: 10px; cursor: zoom-in;
}
.pm-section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 8px; font-weight: 600;
}
.pm-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.pm-photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-base);
}
.pm-photo-item img {
  width: 100%; height: 100%; object-fit: cover;
  cursor: zoom-in;
}
.pm-photo-item.stock { opacity: 0.7; }
.pm-photo-delete {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.7); color: white;
  border: none; border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer; font-size: 12px;
}
.pm-photo-add {
  border: 2px dashed var(--border-default);
  border-radius: 8px;
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.pm-photo-add:hover { border-color: var(--accent); color: var(--accent); }
.pm-photo-add .add-icon { font-size: 30px; line-height: 1; }
.pm-photo-add .add-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* PRICES TAB */
.pm-prices-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.pm-price-row {
  background: var(--bg-base);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: 100px 200px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 700px) {
  .pm-price-row { grid-template-columns: 1fr; }
}
.pm-price-label { font-weight: 700; font-size: 14px; }
.pm-price-input-wrap {
  display: flex; align-items: center; gap: 4px;
}
.pm-price-input-wrap .unit { color: var(--text-muted); }
.pm-price-calc {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px;
}
.pm-price-calc .profit { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border-default); }
.profit.positive { color: var(--gr, #22C55E); }
.profit.negative { color: var(--rd, #EF4444); }
.pm-prices-actions, .pm-dims-actions, .pm-desc-actions {
  margin-top: 16px; text-align: right;
}

/* DIMS TAB */
.pm-dims-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.pm-volume-card {
  background: var(--accent-dim, rgba(16, 224, 137, 0.15));
  border: 1px solid var(--accent, #10E089);
  border-radius: 10px;
  padding: 16px; text-align: center;
}
.pm-volume-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.pm-volume-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.pm-volume-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* HISTORY TAB */
.pm-history-section { margin-bottom: 16px; }
.pm-history-item { padding: 8px 12px; background: var(--bg-base); border-radius: 6px; font-size: 13px; }
.muted { color: var(--text-muted); }

/* DESC TAB */
.pm-desc-tabs {
  display: flex; gap: 4px; margin-bottom: 10px;
}
.desc-lang-btn {
  padding: 6px 12px; background: var(--bg-base); border: 1px solid var(--border-default);
  border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text-secondary);
}
.desc-lang-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.pm-desc-panel { position: relative; }
.pm-desc-textarea {
  width: 100%; display: none; padding: 10px;
  background: var(--bg-base); border: 1px solid var(--border-default);
  border-radius: 8px; color: var(--text-primary);
  font-family: 'Geist Mono', 'JetBrains Mono', monospace;
  font-size: 12px; resize: vertical;
}
.pm-desc-textarea.active { display: block; }

/* SELL MODAL preview */
.sell-article-info {
  padding: 10px; background: var(--bg-base); border-radius: 6px;
  margin-bottom: 16px; font-size: 13px;
}
.form-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-field.full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 10px; background: var(--bg-base); border: 1px solid var(--border-default);
  border-radius: 6px; color: var(--text-primary); font-size: 13px;
}

.sell-preview {
  margin-top: 16px; padding: 12px;
  background: var(--bg-base); border-radius: 10px;
  border: 1px solid var(--border-default);
}
.preview-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 13px;
}
.preview-row.negative { color: var(--text-secondary); }
.preview-row.total {
  border-top: 1px solid var(--border-default);
  margin-top: 6px; padding-top: 8px; font-size: 14px;
}

/* STATUS MODAL */
.status-buttons-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.status-btn {
  padding: 10px; background: var(--bg-base); border: 1px solid;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background 0.15s;
}
.status-btn:hover { background: var(--bg-hover, #1B2230); }

/* DUPLICATES MODAL */
.dup-source {
  padding: 10px; background: var(--bg-base); border-radius: 6px;
  margin-bottom: 16px; font-size: 13px;
}
.dup-section-title {
  font-size: 12px; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 6px; margin-top: 12px; font-weight: 600;
}
.dup-item {
  display: flex; gap: 12px; padding: 10px;
  background: var(--bg-base); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; transition: background 0.1s;
}
.dup-item:hover { background: var(--bg-hover); }
.dup-photo {
  width: 56px; height: 56px;
  border-radius: 6px; background-size: cover; background-position: center;
  background-color: var(--bg-elevated);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.dup-info { flex: 1; min-width: 0; }
.dup-name {
  font-size: 12px; color: var(--text-secondary);
  margin: 4px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dup-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.dup-match {
  padding: 1px 6px; background: var(--accent-dim); color: var(--accent);
  border-radius: 3px;
}
.dup-similarity {
  padding: 1px 6px; background: rgba(245, 158, 11, 0.2); color: #F59E0B;
  border-radius: 3px;
}
.dup-empty { padding: 20px; text-align: center; color: var(--text-muted); }

/* ADD PRODUCT MODAL */
.ap-article-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 10px; background: var(--bg-base); border-radius: 6px;
  font-size: 13px;
}

/* PHOTO VIEWER — селектор по #id чтобы перекрыть shared #photo-viewer (z-index:2000) */
#photo-viewer.photo-viewer {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.9);
}
#photo-viewer.photo-viewer.open { display: flex; }
.photo-viewer-img {
  max-width: 95vw; max-height: 95vh;
  object-fit: contain;
}
.photo-viewer-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.1); color: white;
  border: none; border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 18px; cursor: pointer;
  z-index: 1;
}
.photo-viewer-close:hover { background: rgba(255,255,255,0.2); }

/* RESPONSIVE */
@media (max-width: 600px) {
  .modal { padding: 0; }
  .modal-content {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }
  .tabs-bar { padding: 4px 8px 0; }
  .tab-btn { padding: 8px 10px; font-size: 12px; }
  .tab-panels { padding: 12px; }
  .pm-header { padding: 12px; }
  .pmh-actions { width: 100%; justify-content: stretch; }
  .pmh-actions .btn { flex: 1; }
}

/* ═════════════════════════════════════════
   FIX 7D-FIX.3: Specificity override для voltstock-design.css коллизий
   ═════════════════════════════════════════ */

/* Modal inputs — поля видны и стилизованы */
.modal .form-field input,
.modal .form-field select,
.modal .form-field textarea,
.modal .pm-input,
.modal input[type="text"],
.modal input[type="number"],
.modal input[type="email"],
.modal input[type="tel"],
.modal input[type="url"],
.modal input[type="password"],
.modal select,
.modal textarea {
  background: var(--bg-base, #07090C) !important;
  border: 1px solid var(--border-default, #2A3140) !important;
  color: var(--text-primary, #F2F4F7) !important;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.modal .form-field input:focus,
.modal .form-field select:focus,
.modal .form-field textarea:focus,
.modal .pm-input:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  border-color: var(--accent, #10E089) !important;
}

.modal .form-field input::placeholder,
.modal .pm-input::placeholder,
.modal input::placeholder,
.modal textarea::placeholder {
  color: var(--text-muted, #6B7280);
  opacity: 0.6;
}

/* Checkbox остаётся стандартного вида */
.modal input[type="checkbox"] {
  width: auto !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
}

/* Mono (артикулы, цены, EAN) */
.modal .pm-input.mono,
.modal .mono {
  font-family: 'JetBrains Mono', 'Geist Mono', monospace !important;
}

/* Гарантия что modal-content видимый над backdrop */
.modal.open .modal-content,
.modal.open .product-modal-content {
  position: relative;
  z-index: 1;
}
.modal-backdrop {
  z-index: 0;
}
