/**
 * 3D Packaging Studio & CAD Viewport Styles
 * @package BuddyPackaging
 */

.bp-studio-wrapper {
  background: #f8fafc;
  min-height: calc(100vh - 120px);
  padding: 30px 0 70px 0;
}

/* ==========================================================================
   1. TOP CARD: Live Pricing & Active Specifications Bar (Full Width)
   ========================================================================== */
.bp-top-pricing-bar {
  background: #ffffff;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 10px 25px -8px rgba(79, 1, 107, 0.07);
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.bp-pricing-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bp-pricing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b21a8;
}

.bp-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
  animation: bpPulse 2s infinite;
}

@keyframes bpPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.bp-summary-specs {
  font-size: 0.88rem;
  color: #334155;
  font-weight: 600;
}

.bp-pricing-center {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #faf5ff;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid #f3e8ff;
}

.bp-pricing-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bp-qty-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bp-qty-pill strong {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary, #4F016B);
}

.bp-unit-rate {
  font-size: 0.85rem;
  font-weight: 700;
  color: #16a34a;
}

.bp-pricing-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bp-total-box {
  text-align: right;
}

.bp-total-lbl {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bp-total-val {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--primary, #4F016B);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   2. MAIN 2-COLUMN GRID (Viewport Left + Configurator Right)
   ========================================================================== */
.bp-studio-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
  transition: all 0.3s ease;
}

.bp-studio-grid.highlight-pulse {
  animation: studioPulse 1.2s ease;
}

@keyframes studioPulse {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.01); filter: brightness(1.05); box-shadow: 0 0 25px rgba(79, 1, 107, 0.2); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Left: Viewport Workspace */
.bp-studio-viewport-card {
  background: #ffffff;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 10px 30px -10px rgba(79, 1, 107, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bp-studio-viewport-header {
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  gap: 10px;
}

.bp-view-mode-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
}

.bp-view-mode-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.bp-view-mode-btn:hover {
  color: var(--primary, #4F016B);
}

.bp-view-mode-btn.active {
  background: #ffffff;
  color: var(--primary, #4F016B);
  box-shadow: 0 2px 8px rgba(79, 1, 107, 0.12);
}

.bp-viewport-wrap {
  position: relative;
  min-height: 520px;
  height: 520px;
  background: #ffffff;
  display: flex;
  overflow: hidden;
  flex: 1;
}

.bp-cad-canvas-box,
.bp-three-canvas-box {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  transition: opacity 0.2s ease;
}

.bp-three-canvas-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: grab;
}

.bp-three-canvas-box canvas:active {
  cursor: grabbing;
}

.bp-cad-canvas-box {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #ffffff;
}

.bp-cad-canvas-box svg {
  width: 100%;
  height: 100%;
  max-height: 490px;
  display: block;
}

.bp-viewport-wrap.mode-cad .bp-three-canvas-box { display: none; }
.bp-viewport-wrap.mode-cad .bp-cad-canvas-box { display: flex; }
.bp-viewport-wrap.mode-3d .bp-cad-canvas-box { display: none; }
.bp-viewport-wrap.mode-3d .bp-three-canvas-box { display: block; }
.bp-viewport-wrap.mode-split .bp-cad-canvas-box {
  position: relative;
  width: 50%;
  border-right: 1px solid #e2e8f0;
}
.bp-viewport-wrap.mode-split .bp-three-canvas-box {
  position: relative;
  width: 50%;
}

.bp-studio-viewport-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.bp-folding-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary, #4F016B);
}

.bp-folding-control input[type="range"] {
  width: 130px;
  accent-color: var(--primary, #4F016B);
  cursor: pointer;
}

.bp-sheet-size-callout {
  font-size: 0.82rem;
  color: #475569;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bp-sheet-size-callout strong {
  color: var(--primary, #4F016B);
  font-size: 0.9rem;
}

/* Right: Control Panel */
.bp-studio-panel-card {
  background: #ffffff;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 10px 30px -10px rgba(79, 1, 107, 0.08);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.bp-panel-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.bp-panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.bp-panel-desc {
  font-size: 0.82rem;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

.bp-form-section {
  margin-bottom: 16px;
}

.bp-form-section .form-field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.form-select,
.form-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  font-size: 0.85rem;
  color: #1e293b;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
}

.form-select:focus,
.form-input:focus {
  border-color: var(--primary, #4F016B);
  box-shadow: 0 0 0 3px rgba(79, 1, 107, 0.12);
}

/* 3-Column Equal Dimensions Grid */
.bp-dim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.bp-dim-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bp-dim-item label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
}

.bp-dim-item input {
  font-weight: 600;
  text-align: center;
  font-size: 0.9rem;
}

.bp-unit-select {
  width: auto;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  border-color: #cbd5e1;
  cursor: pointer;
}

.bp-caliper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  background: #f8fafc;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.bp-caliper-input {
  width: 70px;
  padding: 4px 6px;
  font-size: 0.82rem;
  height: 30px;
  text-align: center;
  font-weight: 600;
}

/* Folding + Flat Sheet Size sit in the configurator panel, under the caliper
   row, so they inherit that row's styling rather than the old footer bar's. */
.bp-caliper-row.bp-folding-control,
.bp-caliper-row.bp-sheet-size-callout {
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}

.bp-caliper-row.bp-folding-control input[type="range"] {
  width: 110px;
  margin: 0;
}

.bp-caliper-row.bp-folding-control #bp-fold-val {
  min-width: 40px;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary, #4F016B);
}

.bp-caliper-row.bp-sheet-size-callout strong {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary, #4F016B);
}

.bp-material-grid {
  gap: 12px;
  margin-bottom: 16px;
}

/* Quantity Volume Tiers Grid (Balanced 3-column rows) */
.bp-studio-tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.bp-studio-tier {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 8px 4px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bp-studio-tier:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.bp-studio-tier.active {
  border-color: var(--primary, #4F016B);
  background: #faf5ff;
  box-shadow: 0 0 0 2px rgba(79, 1, 107, 0.2);
}

.bp-tier-qty {
  display: block;
  font-weight: 800;
  font-size: 0.82rem;
  color: #0f172a;
}

.bp-tier-price {
  display: block;
  font-size: 0.74rem;
  color: #16a34a;
  font-weight: 700;
  margin-top: 1px;
}

.bp-file-upload-wrap input[type="file"] {
  background: #f8fafc;
  cursor: pointer;
}

/* ==========================================================================
   3. BOTTOM CARD: Client Details & Instant Order Request (Full Width)
   ========================================================================== */
.bp-client-request-card {
  background: #ffffff;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 10px 30px -10px rgba(79, 1, 107, 0.08);
  padding: 28px 32px;
  margin-bottom: 36px;
}

.bp-request-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.bp-request-icon {
  font-size: 2.2rem;
  width: 54px;
  height: 54px;
  background: #faf5ff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #f3e8ff;
}

.bp-request-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.bp-request-subtitle {
  font-size: 0.88rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
  max-width: 900px;
}

.bp-request-fields-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.bp-req-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.bp-request-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.bp-studio-submit-btn {
  font-weight: 800;
  padding: 14px 32px;
  font-size: 1rem;
  box-shadow: 0 6px 18px rgba(79, 1, 107, 0.25);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.bp-studio-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(79, 1, 107, 0.35);
}

.bp-trust-pill-list {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.bp-trust-pill-list span {
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
}

/* ==========================================================================
   4. TEMPLATE LIBRARY CATALOG (PackMage Standard)
   ========================================================================== */
.bp-catalog-section {
  background: #ffffff;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 10px 30px -10px rgba(79, 1, 107, 0.08);
  padding: 32px;
}

.bp-catalog-header {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.bp-catalog-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.bp-catalog-desc {
  font-size: 0.92rem;
  color: #64748b;
  margin: 0;
  max-width: 850px;
  line-height: 1.5;
}

.bp-catalog-search-wrap {
  width: 100%;
}

.bp-catalog-search-input {
  font-size: 0.95rem;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  background-color: #f8fafc;
  transition: all 0.2s ease;
}

.bp-catalog-search-input:focus {
  background-color: #ffffff;
  border-color: var(--primary, #4F016B);
  box-shadow: 0 0 0 4px rgba(79, 1, 107, 0.1);
}

.bp-catalog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
}

.bp-filter-btn {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.bp-filter-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--primary, #4F016B);
}

.bp-filter-btn.active {
  background: var(--primary, #4F016B);
  color: #ffffff;
  border-color: var(--primary, #4F016B);
  box-shadow: 0 2px 8px rgba(79, 1, 107, 0.2);
}

.bp-catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.bp-template-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bp-template-card:hover {
  transform: translateY(-4px);
  border-color: #c084fc;
  box-shadow: 0 12px 24px -6px rgba(79, 1, 107, 0.15);
}

.bp-card-preview {
  background: #f8fafc;
  padding: 16px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  border-bottom: 1px solid #f1f5f9;
}

.bp-preview-dieline {
  width: 55%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-preview-svg {
  width: 100%;
  height: 100%;
  max-height: 120px;
}

.bp-preview-3d {
  width: 40%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-3d-box-icon {
  width: 60px;
  height: 60px;
  background: #ffffff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
}

.bp-badge-live {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bp-badge-standard {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bp-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.bp-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.bp-template-id {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary, #4F016B);
}

.bp-cat-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 6px;
}

.bp-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  line-height: 1.3;
}

.bp-card-desc {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 12px;
  flex: 1;
}

.bp-card-products-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4F016B;
  margin-bottom: 6px;
}

.bp-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}

.bp-tag-list span {
  font-size: 0.68rem;
  font-weight: 600;
  color: #475569;
  background: #faf5ff;
  border: 1px solid #f3e8ff;
  padding: 2px 6px;
  border-radius: 4px;
}

.bp-product-tag-list span {
  color: #0f172a;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.7rem;
}

.bp-load-template-btn {
  width: 100%;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 8px 12px;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1280px) {
  .bp-catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1100px) {
  .bp-request-fields-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .bp-studio-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .bp-viewport-wrap {
    height: 460px;
    min-height: 460px;
  }
  .bp-top-pricing-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .bp-pricing-right {
    justify-content: space-between;
  }
  .bp-catalog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .bp-studio-viewport-header {
    flex-direction: column;
    align-items: stretch;
  }
  .bp-view-mode-tabs {
    justify-content: center;
  }
  .bp-dim-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .bp-studio-tiers {
    grid-template-columns: repeat(2, 1fr);
  }
  .bp-material-grid {
    grid-template-columns: 1fr !important;
  }
  .bp-request-fields-grid {
    grid-template-columns: 1fr;
  }
  .bp-request-action-row {
    flex-direction: column;
    align-items: stretch;
  }
  .bp-studio-submit-btn {
    width: 100%;
    text-align: center;
  }
  .bp-catalog-grid {
    grid-template-columns: 1fr;
  }
}
