/* Laminated Glasses — konstruktor 3D preview paneli (js/constructor-3d.js uchun).
   style.css, theme.css dagi o'zgaruvchilar (--ice, --navy, --sky ...) ishlatiladi,
   shuning uchun dark theme avtomatik moslashadi. */

.cv3 { position: relative; }

/* ---------- Sahna ---------- */
.cv3-stage {
  position: relative;
  height: clamp(300px, calc(100vh - 540px), 460px);
  min-height: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 50% 8%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, var(--ice) 0%, var(--ice-2) 100%);
}
html[data-theme="dark"] .cv3-stage {
  background:
    radial-gradient(120% 90% at 50% 8%, rgba(74, 168, 232, 0.16) 0%, rgba(74, 168, 232, 0) 62%),
    linear-gradient(180deg, #14283a 0%, #0b1823 100%);
}
@media (max-width: 860px) {
  .cv3-stage { height: clamp(300px, 86vw, 440px); }
}

.cv3-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; z-index: 1;
  cursor: grab;
  touch-action: none;           /* 360° erkin aylantirish: barmoq bilan har tomonga burash mumkin */
  outline: none;
}
.cv3-canvas.dragging { cursor: grabbing; }
.cv3-canvas.mode-move { cursor: move; touch-action: none; }

.cv3-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.cv3-chip, .cv3-layer {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font: 700 10px/1 var(--font-body);
  border-radius: 999px; padding: 4px 8px;
  transition: opacity .25s var(--ease);
  will-change: transform;
}
.cv3-chip { background: rgba(6, 38, 61, 0.72); color: #fff; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; }
.cv3-layer { background: var(--white); color: var(--navy); border: 1px solid var(--line-strong); box-shadow: 0 4px 12px rgba(6, 38, 61, .16); font-size: 10.5px; opacity: 0; }
html[data-theme="dark"] .cv3-chip { background: rgba(255, 255, 255, .14); }
@media (max-width: 520px) { .cv3-chip, .cv3-layer { font-size: 9px; padding: 3px 6px; } }

/* ---------- Placeholder ---------- */
.cv3-placeholder {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 28px);
  background: var(--white); color: var(--navy-soft);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 8px 14px; font-size: 0.78rem; font-weight: 600; text-align: center;
  box-shadow: 0 8px 20px rgba(6, 38, 61, .14); pointer-events: none;
}
.cv3-placeholder[hidden] { display: none; }
.cv3-placeholder svg { width: 16px; height: 16px; color: var(--sky); flex: none; }

/* ---------- Stage ustidagi tugmalar ---------- */
.cv3-top {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 4;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none;
}
.cv3-top > * { pointer-events: auto; }
.cv3-seg {
  display: inline-flex; background: var(--white); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 3px; box-shadow: 0 6px 16px rgba(6, 38, 61, .12);
}
.cv3-seg button {
  border: 0; background: transparent; color: var(--navy-soft); cursor: pointer;
  font: 700 0.74rem var(--font-body); padding: 7px 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: background .16s var(--ease), color .16s var(--ease);
}
.cv3-seg button svg { width: 14px; height: 14px; }
.cv3-seg button.active { background: var(--navy); color: #fff; }
html[data-theme="dark"] .cv3-seg button.active { background: var(--sky); color: #04131f; }
.cv3-seg button:disabled { opacity: .45; cursor: not-allowed; }

.cv3-tools { display: flex; flex-direction: column; gap: 6px; }
.cv3-icon-btn {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--white); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(6, 38, 61, .14); transition: transform .16s var(--ease), background .16s var(--ease);
}
.cv3-icon-btn svg { width: 17px; height: 17px; }
.cv3-icon-btn:hover { transform: translateY(-1px); background: var(--ice); }
.cv3-icon-btn[hidden] { display: none; }

.cv3-temp {
  position: absolute; left: 50%; top: 10px; transform: translate(-50%, -14px); z-index: 5;
  min-width: 190px; padding: 9px 14px 11px; border-radius: 16px;
  background: rgba(17, 24, 39, .88); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
  opacity: 0; pointer-events: none; transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.cv3-temp.on { opacity: 1; transform: translate(-50%, 44px); }
.cv3-temp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 0.72rem; font-weight: 700; letter-spacing: .02em; }
.cv3-temp-row b { font: 700 1.25rem var(--font-body); font-variant-numeric: tabular-nums; }
.cv3-temp-bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .18); overflow: hidden; margin-top: 7px; }
.cv3-temp-bar i { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, #f59e0b, #ef4444, #ec4899); }
@media (max-width: 520px) { .cv3-temp.on { transform: translate(-50%, 52px); } }

/* ---------- Pastdagi review tugmalari ---------- */
.cv3-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.cv3-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 50px; padding: 10px 14px; border-radius: var(--radius-md); cursor: pointer;
  font: 700 0.86rem/1.15 var(--font-body); text-align: left;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease), opacity .18s var(--ease);
}
.cv3-btn svg { width: 20px; height: 20px; flex: none; }
.cv3-btn small { display: block; font-weight: 600; font-size: 0.7rem; opacity: .75; margin-top: 2px; }
.cv3-btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.cv3-btn:not(:disabled):hover { transform: translateY(-2px); }
.cv3-btn-split { background: var(--ice); color: var(--navy); border: 1.5px solid var(--line-strong); }
.cv3-btn-split:not(:disabled):hover { border-color: var(--sky); }
.cv3-btn-split.active { background: var(--navy); border-color: var(--navy); color: #fff; }
html[data-theme="dark"] .cv3-btn-split.active { background: var(--sky); border-color: var(--sky); color: #04131f; }
.cv3-btn-heat {
  border: 0; color: #fff;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 55%, #ec4899 100%);
  box-shadow: 0 10px 22px -8px rgba(239, 68, 68, .6);
}
.cv3-btn-heat:not(:disabled):hover { box-shadow: 0 14px 28px -8px rgba(239, 68, 68, .75); }
.cv3-btn-heat.is-done { background: linear-gradient(135deg, #2f9e63, #1f7a4c); box-shadow: 0 10px 22px -8px rgba(31, 122, 76, .55); }
.cv3-btn-heat.is-busy { filter: saturate(1.2); animation: cv3pulse 1s ease-in-out infinite; }
@keyframes cv3pulse { 50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, .25); } }
@media (max-width: 420px) { .cv3-btn { font-size: 0.8rem; padding: 9px 10px; gap: 7px; } .cv3-btn svg { width: 18px; height: 18px; } }

/* ---------- Holat matni va o'lcham qulfi ---------- */
.cv3-status {
  display: flex; gap: 11px; align-items: flex-start; margin-top: 12px;
  padding: 11px 13px; border-radius: var(--radius-md); background: var(--ice); border: 1px solid var(--line);
}
.cv3-status-ico {
  width: 30px; height: 30px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--ice-2); color: var(--sky-deep);
}
html[data-theme="dark"] .cv3-status-ico { color: var(--sky-soft); }
.cv3-status-ico svg { width: 16px; height: 16px; }
.cv3-status strong { display: block; font: 700 0.82rem var(--font-body); color: var(--navy); }
.cv3-status span { display: block; font-size: 0.76rem; line-height: 1.45; color: var(--navy-soft); margin-top: 2px; }
.cv3-status.is-hot .cv3-status-ico { background: #fde7d3; color: #c2410c; }
.cv3-status.is-ok .cv3-status-ico { background: #dcf3e6; color: #1f7a4c; }
html[data-theme="dark"] .cv3-status.is-hot .cv3-status-ico { background: rgba(245, 158, 11, .2); color: #fbbf6a; }
html[data-theme="dark"] .cv3-status.is-ok .cv3-status-ico { background: rgba(86, 196, 134, .2); color: #7fd9a6; }

.cv3-lock { display: flex; align-items: center; gap: 7px; margin: 10px 2px 0; font-size: 0.74rem; color: var(--navy-soft); line-height: 1.4; }
.cv3-lock svg { width: 14px; height: 14px; flex: none; color: var(--sky); }

.cv3-fallback { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; padding: 18px; }
.cv3-fallback canvas { max-width: 100%; max-height: 100%; box-shadow: 0 16px 32px rgba(6, 38, 61, .22); }
.cv3-fallback[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .cv3-btn-heat.is-busy { animation: none; }
  .cv3-temp, .cv3-chip, .cv3-layer { transition: none; }
}

.cv3-actions[hidden], .cv3-status[hidden], .cv3-seg[hidden] { display: none; }
.cv3-canvas[hidden] { display: none; }
/* Past ekranli kompyuterlarda yopishqoq panel sig'maydi — oddiy aylantirishga o'tadi. */
@media (min-width: 861px) and (max-height: 880px) {
  .constructor-grid > .constructor-panel:nth-child(2) { position: static !important; }
}


/* ---------- Photoshop uslubidagi asboblar paneli (preview ichida) ---------- */
.cv3-icon-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
html[data-theme="dark"] .cv3-icon-btn.active { background: var(--sky); color: #04131f; border-color: var(--sky); }
.cv3-icon-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.ps {
  position: absolute; left: 10px; top: 58px; z-index: 6;
  width: 272px; max-height: calc(100% - 68px);
  display: flex; flex-direction: column;
  background: rgba(38, 38, 38, .97); color: #d6d6d6;
  border: 1px solid #1a1a1a; border-radius: 10px; overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  font-family: var(--font-body);
}
.ps[hidden] { display: none; }
.ps-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 8px 7px 12px; background: #2b2b2b; border-bottom: 1px solid #1a1a1a; flex: none;
}
.ps-title { display: inline-flex; align-items: center; gap: 7px; font: 700 0.72rem var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: #bdbdbd; }
.ps-title svg { width: 14px; height: 14px; }
.ps-head-btns { display: inline-flex; gap: 4px; }
.ps-hbtn { width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: #bdbdbd; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ps-hbtn:hover { background: #3d3d3d; color: #fff; }
.ps-hbtn svg { width: 14px; height: 14px; }
.ps.min .ps-body { display: none; }
.ps.min { max-height: none; }

.ps-body { display: flex; min-height: 0; flex: 1 1 auto; }
.ps-rail {
  flex: none; width: 56px; padding: 6px 4px; background: #333; border-right: 1px solid #1a1a1a;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.ps .ce-tool {
  width: 100%; padding: 7px 2px 5px; gap: 3px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: #cfcfcf; font: 600 0.58rem var(--font-body); transform: none;
}
.ps .ce-tool svg { width: 19px; height: 19px; }
.ps .ce-tool:hover { background: #454545; border-color: transparent; color: #fff; transform: none; }
.ps .ce-tool.active, .ps .ce-tool.primary { background: #31a8ff; color: #04131f; border-color: #31a8ff; }

.ps-props { flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: 8px 10px 10px; }
.ps .ce-quality { background: #2f2f2f; color: #e3e3e3; margin: 0 0 8px; padding: 7px 9px; font-size: 0.7rem; }
.ps .ce-quality small { color: #9a9a9a; }
.ps-sec { border-top: 1px solid #1f1f1f; padding: 2px 0 6px; }
.ps-sec:first-of-type { border-top: 0; }
.ps-sec > summary {
  list-style: none; cursor: pointer; padding: 7px 0 6px; font: 700 0.66rem var(--font-body);
  letter-spacing: .08em; text-transform: uppercase; color: #9d9d9d; display: flex; align-items: center; gap: 6px;
}
.ps-sec > summary::-webkit-details-marker { display: none; }
.ps-sec > summary::before { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid #9d9d9d; transition: transform .15s; }
.ps-sec:not([open]) > summary::before { transform: rotate(-90deg); }
.ps .ce-seg { background: #2a2a2a; margin-bottom: 10px; padding: 3px; }
.ps .ce-seg button { color: #aaa; font-size: 0.7rem; padding: 6px 6px; }
.ps .ce-seg button.active { background: #4a4a4a; color: #fff; box-shadow: none; }
.ps .ce-row { margin: 0 0 8px; }
.ps .ce-row label { color: #d0d0d0; font-size: 0.72rem; font-weight: 600; margin-bottom: 2px; }
.ps .ce-row output { color: #31a8ff; }
.ps .ce-row input[type=range] { height: 20px; accent-color: #31a8ff; }
.ps .ce-chips { gap: 6px; margin: 2px 0 6px; }
.ps .ce-chip { background: #2f2f2f; border-color: #4a4a4a; color: #d0d0d0; padding: 5px 10px; font-size: 0.7rem; }
.ps .ce-chip.active { background: #31a8ff; border-color: #31a8ff; color: #04131f; }
.ps .ce-hint { color: #8d8d8d; font-size: 0.66rem; line-height: 1.45; margin: 6px 0 0; }

@media (max-width: 860px) {
  /* Telefonda panel pastdan chiqadigan qatlam bo'lib ochiladi */
  .ps { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 64%; }
  .ps-body { flex-direction: column; }
  .ps-rail { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid #1a1a1a; }
  .ps .ce-tool { width: 54px; flex: none; }
}
