/* ==========================================================================
   DANVEX COMMERCIAL PROPOSAL (КП В PDF) MODULE
   ========================================================================== */

/* 1. Product Detail B2B Actions Row (Сформировать КП в PDF + Отправить реквизиты) */
body #content .catalog_detail .element_detail_text.requisites .dvx_b2b_actions_row {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body #content .catalog_detail .element_detail_text.requisites .dvx_btn_kp_pdf {
  width: 100% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  box-sizing: border-box !important;
  text-align: center !important;
  background: #3B82A6 !important;
  border: 1px solid #2F6E8E !important;
  border-radius: 0 !important;
  color: #FFFFFF !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em !important;
  padding: 11px 14px !important;
  text-transform: uppercase !important;
  transition: all 0.18s ease !important;
  cursor: pointer !important;
  line-height: 1.2 !important;
  outline: none !important;
  margin: 0 !important;
}

body #content .catalog_detail .element_detail_text.requisites .dvx_btn_kp_pdf:hover {
  background: #2C6785 !important;
  border-color: #245670 !important;
  color: #FFFFFF !important;
}

body #content .catalog_detail .element_detail_text.requisites .dvx_btn_kp_pdf svg {
  flex-shrink: 0 !important;
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor !important;
}

@media screen and (max-width: 600px) {
  body #content .catalog_detail .element_detail_text.requisites .dvx_b2b_actions_row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
}

/* 2. Floating Bottom KP Widget (.dvx-kp-fab-wrap) — Strictly centered */
.dvx-kp-fab-wrap {
  position: fixed !important;
  bottom: 24px !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  z-index: 9990;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.dvx-kp-fab-wrap.is-visible {
  display: flex;
}

.dvx-kp-fab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 54px;
  padding: 0 22px;
  border-radius: 999px;
  background: #0284c7;
  color: #ffffff !important;
  border: 3px solid #ffffff;
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.42), 0 2px 8px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  animation: dvxKpPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dvx-kp-fab-btn:hover {
  background: #0369a1;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(2, 132, 199, 0.5), 0 4px 10px rgba(15, 23, 42, 0.18);
}

.dvx-kp-fab-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.dvx-kp-fab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  border: 2px solid #ffffff;
  box-sizing: border-box;
  line-height: 1;
}

/* 3. Modal Overlay & Dialogs (.dvx-kp-overlay, .dvx-kp-modal) */
.dvx-kp-overlay {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.dvx-kp-overlay.is-open {
  display: flex;
}

.dvx-kp-modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
  color: #0f172a;
  animation: dvxKpPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.dvx-kp-modal--ready {
  max-width: 620px;
  padding: 32px;
}

@keyframes dvxKpPopIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dvx-kp-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dvx-kp-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.dvx-kp-title {
  margin: 0 0 20px 0 !important;
  padding: 0 28px 0 0 !important;
  font-size: 21px !important;
  line-height: 1.3 !important;
  font-weight: 700 !important;
  color: #0f172a !important;
}

/* Product Card inside Modal 1 */
.dvx-kp-prod-box {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.dvx-kp-prod-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 8px;
  padding: 4px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
  box-sizing: border-box;
}

.dvx-kp-prod-info {
  flex: 1;
  min-width: 0;
}

.dvx-kp-prod-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: #1e293b;
  margin-bottom: 6px;
}

.dvx-kp-prod-price {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  color: #0284c7;
}

/* Quantity Stepper inside Modal 1 */
.dvx-kp-qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.dvx-kp-qty-label {
  font-weight: 600;
  font-size: 15px;
  color: #334155;
}

.dvx-kp-qty-ctrl {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.dvx-kp-qty-btn {
  width: 40px;
  height: 40px;
  background: #f1f5f9;
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
  padding: 0;
}

.dvx-kp-qty-btn:hover {
  background: #e2e8f0;
}

.dvx-kp-qty-input {
  width: 60px !important;
  height: 40px !important;
  text-align: center !important;
  border: none !important;
  border-left: 1px solid #cbd5e1 !important;
  border-right: 1px solid #cbd5e1 !important;
  border-radius: 0 !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  background: #ffffff !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  -moz-appearance: textfield;
}

.dvx-kp-qty-input::-webkit-outer-spin-button,
.dvx-kp-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Customer Input Block */
.dvx-kp-field {
  margin-bottom: 24px;
}

.dvx-kp-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: #334155;
  margin-bottom: 8px;
}

.dvx-kp-label span {
  color: #ef4444;
}

.dvx-kp-input {
  width: 100% !important;
  height: 44px !important;
  padding: 10px 14px !important;
  border-radius: 8px !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  font-size: 14px !important;
  color: #0f172a !important;
  box-sizing: border-box !important;
  outline: none !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.dvx-kp-input:focus {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14) !important;
}

.dvx-kp-input.is-error {
  border: 2px solid #ef4444 !important;
}

.dvx-kp-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 6px;
  font-weight: 500;
  display: none;
}

.dvx-kp-error.is-visible {
  display: block;
}

/* Modal Action Buttons */
.dvx-kp-actions {
  display: flex;
  gap: 12px;
}

.dvx-kp-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
  text-align: center;
  line-height: 1.25;
  box-sizing: border-box;
  outline: none;
}

.dvx-kp-btn--outline-blue {
  border: 2px solid #0284c7;
  background: transparent;
  color: #0284c7;
}

.dvx-kp-btn--outline-blue:hover {
  background: #f0f9ff;
}

.dvx-kp-btn--outline-slate {
  border: 2px solid #cbd5e1;
  background: transparent;
  color: #475569;
}

.dvx-kp-btn--outline-slate:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.dvx-kp-btn--primary {
  border: none;
  background: #0284c7;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.28);
}

.dvx-kp-btn--primary:hover {
  background: #0369a1;
}

.dvx-kp-btn--primary:disabled {
  background: #94a3b8;
  box-shadow: none;
  cursor: wait;
}

.dvx-kp-btn--wide {
  flex: 2;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
}

.dvx-kp-btn--full {
  width: 100%;
  flex: 1 1 100%;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 20px;
}

/* Modal 2 (Ready Modal) Elements */
.dvx-kp-ready-head {
  text-align: center;
  margin-bottom: 22px;
}

.dvx-kp-ready-title {
  margin: 0 0 8px 0 !important;
  font-size: 23px !important;
  line-height: 1.25 !important;
  font-weight: 800 !important;
  color: #0f172a !important;
}

.dvx-kp-ready-sub {
  font-size: 14px;
  color: #64748b;
}

.dvx-kp-ready-sub strong {
  color: #0f172a;
}

.dvx-kp-items-box {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 22px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  background: #f8fafc;
}

.dvx-kp-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
}

.dvx-kp-item-row:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.dvx-kp-item-title {
  flex: 1;
  font-weight: 600;
  color: #1e293b;
  padding-right: 8px;
  line-height: 1.35;
}

.dvx-kp-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dvx-kp-item-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.dvx-kp-item-step-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #f1f5f9;
  color: #334155;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dvx-kp-item-step-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.dvx-kp-item-qty {
  color: #1e293b;
  background: #ffffff;
  padding: 0 8px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 50px;
  box-sizing: border-box;
}

.dvx-kp-item-sum {
  font-weight: 700;
  color: #0284c7;
  min-width: 96px;
  text-align: right;
  white-space: nowrap;
}

.dvx-kp-item-del {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 15px;
  line-height: 1;
  border-radius: 4px;
  opacity: 0.75;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.dvx-kp-item-del:hover {
  opacity: 1;
  background: #fee2e2;
}

.dvx-kp-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 2px solid #cbd5e1;
  font-weight: 800;
  font-size: 16px;
  color: #0f172a;
}

.dvx-kp-total-val {
  color: #0f172a;
  font-size: 18px;
}

.dvx-kp-clear-wrap {
  text-align: center;
  margin-top: 16px;
}

.dvx-kp-clear-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.dvx-kp-clear-btn:hover {
  color: #ef4444;
}

/* Offscreen PDF Render Host */
.dvx-kp-pdf-host {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 800px;
  background: #ffffff;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  z-index: -1;
  pointer-events: none;
}

.dvx-kp-pdf-host * {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

@media screen and (max-width: 540px) {
  .dvx-kp-modal,
  .dvx-kp-modal--ready {
    padding: 22px 18px;
    border-radius: 14px;
  }

  .dvx-kp-title,
  .dvx-kp-ready-title {
    font-size: 18px !important;
  }

  .dvx-kp-actions {
    flex-direction: column;
  }

  .dvx-kp-btn,
  .dvx-kp-btn--wide,
  .dvx-kp-btn--full {
    width: 100%;
    flex: none;
  }

  .dvx-kp-item-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .dvx-kp-item-meta {
    width: 100%;
    justify-content: space-between;
  }
}
