/* 3DHM · 3D print upload + price  (resources/views/components/calculators/print-upload.blade.php)
   Palette: 3dhm-tool-styles FINAL 22.10.2026. Everything is scoped to #p3d, prefix p3-. */

#p3d {
  --c-primary: #617A35;
  --c-primary-hover: #3F5022;
  --c-highlight: #F7C948;
  --c-dark: #3E5C76;
  --c-steel: #4A7192;
  --c-ok: #2E7D4F;
  --c-ok-bg: #E3F1E8;
  --c-ok-text: #1F5C39;
  --c-warn: #F2765E;
  --c-warn-bg: #FDE7E2;
  --c-warn-text: #7A2A1F;
  --c-info-bg: #FDF4DA;
  --c-info-border: #E2AE2C;
  --c-info-text: #5C4710;
  --c-page: #F6F7F3;
  --c-card: #FFFFFF;
  --c-line: #E7EBE1;
  --c-border: #C0CAAE;
  --c-input: #8295A6;
  --c-selected: #EEF1E4;
  --c-price-bg: #FDF4DA;
  --c-text: #23241F;
  --c-muted: #3E5C76;
  --f-sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --r: 12px;

  font-family: var(--f-sans);
  color: var(--c-text);
  background: var(--c-page);
  border-radius: 16px;
  padding: 20px;
  box-sizing: border-box;
  text-align: left;
  line-height: 1.45;
}
#p3d *, #p3d *::before, #p3d *::after { box-sizing: border-box; }
#p3d [hidden] { display: none !important; }
#p3d .p3-mono { font-family: var(--f-mono); }
#p3d .p3-hint { font-size: 13px; color: var(--c-muted); }
#p3d .p3-small { font-size: 12px; color: var(--c-muted); margin: 0; line-height: 1.5; }
#p3d .p3-kicker { font-family: var(--f-mono); font-size: 12px; letter-spacing: .08em; color: var(--c-muted); text-transform: uppercase; }
#p3d .p3-h { font-size: 17px; font-weight: 600; }
#p3d .p3-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
#p3d .p3-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* focus always visible */
#p3d :is(button, a, input, select, textarea, label.p3-btn, summary):focus-visible {
  outline: 3px solid var(--c-highlight);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--c-text);
}
#p3d .p3-file-input:focus-visible + * , #p3d label.p3-btn:focus-within { outline: 3px solid var(--c-highlight); outline-offset: 2px; }

/* ---------- buttons ---------- */
#p3d .p3-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 0;
  font: 600 15px/1.2 var(--f-sans); cursor: pointer; text-decoration: none; white-space: nowrap;
}
#p3d .p3-btn-yellow { background: var(--c-highlight); color: var(--c-text); }
#p3d .p3-btn-yellow:hover { background: #EFBE3A; }
#p3d .p3-btn-olive { background: var(--c-primary); color: #fff; }
#p3d .p3-btn-olive:hover { background: var(--c-primary-hover); }
#p3d .p3-btn-line { background: var(--c-card); color: var(--c-text); border: 1px solid var(--c-input); font-weight: 500; }
#p3d .p3-btn-line:hover { background: var(--c-selected); }
#p3d .p3-btn-big { width: 100%; min-height: 52px; font-size: 17px; }
#p3d .p3-btn:disabled { opacity: .55; cursor: not-allowed; }
#p3d .p3-link { background: none; border: 0; padding: 0 2px; min-height: 36px; color: var(--c-primary); font: 600 13px var(--f-sans); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
#p3d .p3-link:hover { color: var(--c-primary-hover); }
#p3d .p3-icon-btn {
  width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--c-input); background: var(--c-card);
  display: inline-flex; align-items: center; justify-content: center; color: var(--c-dark); cursor: pointer; flex: 0 0 auto;
}
#p3d .p3-icon-btn:hover { background: var(--c-selected); }
#p3d .p3-icon-btn[aria-pressed="true"] { border-color: var(--c-primary); background: var(--c-selected); color: var(--c-primary); }

/* ---------- top ---------- */
#p3d .p3-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
#p3d .p3-seg { display: inline-flex; background: var(--c-line); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
#p3d .p3-seg-btn { min-height: 40px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--c-dark); font: 500 14px var(--f-sans); cursor: pointer; }
#p3d .p3-seg-btn[aria-pressed="true"] { background: var(--c-primary); color: #fff; font-weight: 600; }

#p3d .p3-assure { display: flex; align-items: flex-start; gap: 10px; background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px; padding: 12px 14px; font-size: 15px; margin-bottom: 16px; }
#p3d .p3-assure svg { color: var(--c-ok); flex: 0 0 auto; margin-top: 1px; }

/* steps bar */
#p3d .p3-steps { display: none; list-style: none; margin: 0 0 16px; padding: 0; gap: 6px; }
#p3d.p3-mode-steps .p3-steps { display: flex; }
#p3d .p3-steps li { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--c-muted); min-width: 0; }
#p3d .p3-steps .p3-bar { height: 4px; border-radius: 2px; background: var(--c-line); }
#p3d .p3-steps li.is-done .p3-bar, #p3d .p3-steps li.is-current .p3-bar { background: var(--c-primary); }
#p3d .p3-steps li.is-current { color: var(--c-text); font-weight: 700; }

/* ---------- layout ---------- */
#p3d .p3-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
#p3d .p3-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
#p3d .p3-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 1024px) {
  #p3d.p3-mode-one .p3-side { position: sticky; top: 16px; }
}

/* ---------- drop zone ---------- */
#p3d .p3-drop { background: var(--c-card); border: 2px dashed var(--c-input); border-radius: var(--r); padding: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; transition: background .15s, border-color .15s; }
#p3d .p3-drop > svg { color: var(--c-dark); flex: 0 0 auto; }
#p3d .p3-drop.is-over { border-color: var(--c-primary); background: var(--c-selected); }
#p3d .p3-drop-text { flex: 1 1 220px; display: flex; flex-direction: column; gap: 4px; }
#p3d .p3-drop-title { font-size: 17px; font-weight: 600; }

/* ---------- messages ---------- */
#p3d .p3-msgs:empty { display: none; }
#p3d .p3-msgs { display: flex; flex-direction: column; gap: 8px; }
#p3d .p3-msg { border-radius: 10px; padding: 10px 14px; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
#p3d .p3-msg ul { margin: 0; padding-left: 18px; }
#p3d .p3-msg-warn { background: var(--c-warn-bg); border: 1px solid var(--c-warn); color: var(--c-warn-text); }
#p3d .p3-msg-ok { background: var(--c-ok-bg); border: 1px solid var(--c-ok); color: var(--c-ok-text); margin-bottom: 12px; }
#p3d .p3-msg button { background: none; border: 0; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; min-width: 32px; min-height: 32px; }

#p3d .p3-list-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
#p3d .p3-count { font-size: 15px; font-weight: 600; }
#p3d .p3-list { display: flex; flex-direction: column; gap: 14px; }
#p3d .p3-empty { display: none; background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--r); padding: 16px; color: var(--c-muted); }

/* ---------- file card ---------- */
#p3d .p3-card { background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#p3d .p3-item { padding: 0; gap: 0; overflow: hidden; }
#p3d .p3-item-body { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; align-items: flex-start; }
#p3d .p3-item-main { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
#p3d .p3-item-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
#p3d .p3-item-name { font-size: 17px; font-weight: 600; word-break: break-all; }
#p3d .p3-item-meta { font-family: var(--f-mono); font-size: 13px; color: var(--c-muted); }
#p3d .p3-item-actions { display: flex; gap: 6px; }

#p3d .p3-view { width: 240px; height: 190px; background: var(--c-dark); border-radius: 8px; position: relative; overflow: hidden; flex: 0 0 auto; touch-action: none; cursor: grab; }
#p3d .p3-view canvas { display: block; width: 100%; height: 100%; }
#p3d .p3-view-hint { position: absolute; left: 8px; bottom: 6px; font-family: var(--f-mono); font-size: 11px; color: #fff; pointer-events: none; }
#p3d .p3-view-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; color: #fff; font-size: 13px; }

/* analysing: nozzle laying filament */
#p3d .p3-analysing { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#p3d .p3-nozzle { width: 200px; height: 56px; background: var(--c-selected); border-radius: 8px; flex: 0 0 auto; }
#p3d .p3-noz { animation: p3noz 1.4s ease-in-out infinite alternate; }
#p3d .p3-fil { transform-origin: 26px 48px; animation: p3fil 1.4s ease-in-out infinite alternate; }
@keyframes p3noz { from { transform: translateX(0); } to { transform: translateX(140px); } }
@keyframes p3fil { from { transform: scaleX(.02); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  #p3d .p3-noz, #p3d .p3-fil { animation: none; }
  #p3d .p3-fil { transform: scaleX(.6); }
}

/* chips */
#p3d .p3-checks { display: flex; flex-wrap: wrap; gap: 6px; }
#p3d .p3-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; line-height: 1.3; }
#p3d .p3-chip-ok { background: var(--c-ok-bg); color: var(--c-ok-text); }
#p3d .p3-chip-warn { background: var(--c-warn-bg); color: var(--c-warn-text); border: 1px solid var(--c-warn); }
#p3d .p3-chip-info { background: var(--c-info-bg); color: var(--c-info-text); border: 1px solid var(--c-info-border); }

/* fields */
#p3d .p3-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#p3d .p3-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--c-muted); margin: 0; }
#p3d .p3-details .p3-field { font-size: 13px; }
#p3d .p3-field select, #p3d .p3-field input, #p3d .p3-field textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--c-input); border-radius: 8px; padding: 0 10px;
  font: 400 15px var(--f-sans); color: var(--c-text); background: var(--c-card);
}
#p3d .p3-field textarea { padding: 10px 12px; resize: vertical; min-height: 80px; }
#p3d .p3-field input:invalid.is-touched { border-color: var(--c-warn); }
#p3d .p3-qty { display: flex; min-height: 44px; border: 1px solid var(--c-input); border-radius: 8px; overflow: hidden; background: var(--c-card); }
#p3d .p3-qty button { width: 44px; border: 0; background: var(--c-line); font-size: 18px; color: var(--c-text); cursor: pointer; flex: 0 0 auto; }
#p3d .p3-qty button:hover { background: var(--c-border); }
#p3d .p3-qty input { flex: 1; min-width: 0; border: 0 !important; text-align: center; font-family: var(--f-mono) !important; font-size: 15px; min-height: 42px !important; border-radius: 0 !important; }

#p3d .p3-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
#p3d .p3-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; cursor: pointer; color: var(--c-text); }
#p3d .p3-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
#p3d .p3-switch .p3-track { width: 42px; height: 24px; border-radius: 999px; background: var(--c-line); border: 1px solid var(--c-input); position: relative; flex: 0 0 auto; transition: background .15s; }
#p3d .p3-switch .p3-track::after { content: ''; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--c-dark); transition: transform .15s, background .15s; }
#p3d .p3-switch input:checked + .p3-track { background: var(--c-primary); border-color: var(--c-primary); }
#p3d .p3-switch input:checked + .p3-track::after { transform: translateX(18px); background: #fff; }
#p3d .p3-switch input:focus-visible + .p3-track { outline: 3px solid var(--c-highlight); outline-offset: 2px; }

#p3d .p3-attach { display: flex; flex-wrap: wrap; gap: 8px; }
#p3d .p3-attach-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 8px; background: var(--c-card); border: 1px dashed var(--c-input); font: 500 13px var(--f-sans); color: var(--c-dark); cursor: pointer; }
#p3d .p3-attach-btn:hover { background: var(--c-selected); }
#p3d .p3-attached { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 4px 0 12px; border-radius: 8px; background: #E9EFF4; border: 1px solid var(--c-steel); font-size: 13px; color: var(--c-text); max-width: 100%; }
#p3d .p3-attached span.p3-fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
#p3d .p3-attached button { min-width: 32px; min-height: 32px; border: 0; background: none; color: var(--c-dark); font-size: 16px; cursor: pointer; border-radius: 6px; }
#p3d .p3-attached svg, #p3d .p3-attach-btn svg { flex: 0 0 auto; color: var(--c-steel); }

#p3d details.p3-more { font-size: 13px; color: var(--c-muted); }
#p3d details.p3-more summary { cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; }
#p3d details.p3-more .p3-fields { margin-top: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

#p3d .p3-item-price { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; background: var(--c-price-bg); border-top: 1px solid var(--c-line); font-family: var(--f-mono); font-size: 14px; }
#p3d .p3-item-price .p3-line-price { font-size: 20px; font-weight: 600; white-space: nowrap; }
#p3d .p3-item-price .p3-per { color: var(--c-muted); }
#p3d .p3-item.is-error .p3-item-price { background: var(--c-warn-bg); }

/* ---------- price box ---------- */
#p3d .p3-pricebox { background: var(--c-price-bg); border: 2px solid var(--c-highlight); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
#p3d .p3-lines { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
#p3d .p3-lines div { display: flex; justify-content: space-between; gap: 12px; }
#p3d .p3-lines div span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#p3d .p3-lines div span:last-child { font-family: var(--f-mono); white-space: nowrap; }
#p3d .p3-lines .is-muted { color: var(--c-muted); }
#p3d .p3-total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-top: 1px solid var(--c-info-border); padding-top: 10px; }
#p3d .p3-total-label { font-size: 15px; font-weight: 600; }
#p3d .p3-total { font-family: var(--f-mono); font-size: 30px; font-weight: 600; white-space: nowrap; }

#p3d .p3-details { gap: 12px; }
#p3d .p3-details [role="note"] { margin-bottom: 0; }
#p3d .p3-send-count { font-weight: 500; }
#p3d .p3-progress-bar { height: 10px; border-radius: 999px; background: var(--c-line); overflow: hidden; }
#p3d .p3-progress-bar span { display: block; height: 100%; width: 0; background: var(--c-primary); transition: width .2s; }
#p3d .p3-done { align-items: flex-start; }
#p3d .p3-done svg { color: var(--c-ok); }

/* ---------- bottom bar ---------- */
#p3d .p3-bottom { display: none; align-items: center; gap: 10px; background: var(--c-price-bg); border-top: 2px solid var(--c-highlight); padding: 10px 16px; margin: 16px -20px -20px; border-radius: 0 0 16px 16px; }
#p3d .p3-bottom-total { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#p3d .p3-bottom-price { font-size: 22px; font-weight: 600; white-space: nowrap; }
#p3d.p3-mode-steps .p3-bottom { display: flex; position: sticky; bottom: 0; z-index: 20; }
#p3d .p3-only-steps { display: none; }
#p3d.p3-mode-steps .p3-only-steps { display: inline-flex; }

/* ---------- Step by step: show only what belongs to the current step ---------- */
#p3d.p3-mode-steps [data-s] { display: none !important; }
#p3d.p3-mode-steps.p3-step-1 [data-s~="1"]:not([hidden]),
#p3d.p3-mode-steps.p3-step-2 [data-s~="2"]:not([hidden]),
#p3d.p3-mode-steps.p3-step-3 [data-s~="3"]:not([hidden]),
#p3d.p3-mode-steps.p3-step-4 [data-s~="4"]:not([hidden]),
#p3d.p3-mode-steps.p3-step-5 [data-s~="5"]:not([hidden]) { display: flex !important; }
#p3d.p3-mode-steps.p3-step-2 .p3-fields[data-s~="2"]:not([hidden]),
#p3d.p3-mode-steps.p3-step-3 .p3-fields[data-s~="3"]:not([hidden]) { display: grid !important; }
#p3d.p3-mode-steps.p3-step-2 details[data-s~="2"]:not([hidden]) { display: block !important; }
#p3d.p3-mode-steps.p3-no-items.p3-step-2 .p3-empty,
#p3d.p3-mode-steps.p3-no-items.p3-step-3 .p3-empty,
#p3d.p3-mode-steps.p3-no-items.p3-step-4 .p3-empty { display: block !important; }
/* steps: one column, so the step's content is not squeezed */
#p3d.p3-mode-steps .p3-side { flex-basis: 100%; }
#p3d.p3-mode-steps .p3-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- phone ---------- */
@media (max-width: 767px) {
  #p3d { padding: 14px; border-radius: 12px; }
  #p3d .p3-bottom { display: flex; position: sticky; bottom: 0; z-index: 20; margin: 14px -14px -14px; border-radius: 0 0 12px 12px; }
  #p3d .p3-fields { grid-template-columns: 1fr 1fr; }
  #p3d .p3-fields .p3-field-qty { grid-column: 1 / -1; }
  #p3d .p3-view { width: 100%; height: 220px; }
  #p3d .p3-nozzle { width: 100%; max-width: 220px; }
  #p3d .p3-total { font-size: 26px; }
  #p3d .p3-seg-btn { padding: 0 10px; font-size: 13px; }
}
