/* ══════════════════════════════════════════════════
   ThermalStudio Pro — style.css
   Dark glassmorphism theme
══════════════════════════════════════════════════ */

:root {
  --bg:          #0f172a;
  --surface:     rgba(30, 41, 59, 0.75);
  --surface2:    rgba(30, 41, 59, 0.95);
  --border:      rgba(99, 130, 255, 0.18);
  --border2:     rgba(148, 163, 184, 0.12);
  --accent-a:    #3b82f6;
  --accent-b:    #8b5cf6;
  --accent-grad: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --danger:      #ef4444;
  --success:     #22c55e;
  --handle-size: 14px;
  --shadow:      0 8px 32px rgba(0,0,0,0.45);
  --radius:      12px;
  --radius-sm:   7px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ── HEADER ───────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 60px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  z-index: 100;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-icon { font-size: 22px; }
.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-name em { font-style: normal; font-weight: 400; }

/* TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
}

.tb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  font-family: inherit;
  font-size: 10px;
}
.tb-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.tb-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.tb-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-a);
  color: var(--accent-a);
}
.tb-btn.accent {
  background: var(--accent-grad);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.tb-btn.accent:hover { opacity: 0.88; }

.tb-divider {
  width: 1px;
  height: 30px;
  background: var(--border2);
  margin: 0 4px;
  flex-shrink: 0;
}

.header-actions { flex-shrink: 0; }
.label-info {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border2);
  border-radius: 20px;
}

/* ── WORKSPACE ────────────────────────────────── */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.canvas-outer {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 32px;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(59,130,246,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 70%, rgba(139,92,246,0.06) 0%, transparent 60%),
    var(--bg);
  position: relative;
}

/* dot grid */
.canvas-outer::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(148,163,184,0.1) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.canvas-wrapper {
  position: relative;
  transform-origin: center center;
  transition: transform .2s ease;
}

#design-canvas {
  display: block;
  background: #fff;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.1),
    0 20px 60px rgba(0,0,0,0.5),
    0 0 80px rgba(59,130,246,0.08);
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: all;
}

/* ZOOM CONTROLS */
.zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 5px 12px;
  backdrop-filter: blur(20px);
}
.zoom-controls button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.zoom-controls button:hover { background: var(--surface); }
#zoom-level { font-size: 12px; color: var(--text-muted); min-width: 42px; text-align: center; }

/* ── SIDE PANEL ───────────────────────────────── */
.side-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(20px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  position: relative;
  z-index: 50;
}
.side-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border2);
  position: sticky;
  top: 0;
  background: var(--surface2);
  backdrop-filter: blur(20px);
  z-index: 2;
}
.panel-header span { font-weight: 600; font-size: 13px; }
#panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
#panel-close:hover { background: var(--surface); color: var(--text); }

/* PROP SECTIONS */
.prop-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border2);
}

.prop-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.prop-select, .prop-input, .modal-input {
  width: 100%;
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color .15s;
  margin-bottom: 10px;
}
.prop-select:focus, .prop-input:focus, .modal-input:focus {
  border-color: var(--accent-a);
}
.prop-select option { background: #1e293b; }

.prop-row {
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
}
.prop-field { flex: 1; }
.prop-field .prop-input { margin-bottom: 0; }

.prop-color {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 2px;
  margin-bottom: 10px;
}

.prop-range {
  width: 100%;
  margin: 4px 0 10px;
  accent-color: var(--accent-a);
}

.style-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.style-btn {
  flex: 1;
  padding: 6px;
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all .15s;
  text-align: center;
}
.style-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.style-btn.active {
  background: rgba(59,130,246,0.2);
  border-color: var(--accent-a);
  color: var(--accent-a);
}

.prop-btn {
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-grad);
  color: #fff;
  transition: opacity .15s;
  margin-bottom: 6px;
}
.prop-btn:hover { opacity: 0.85; }
.prop-btn.secondary {
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--border2);
  color: var(--text-muted);
}
.prop-btn.secondary:hover { color: var(--text); border-color: var(--border); }
.prop-btn.danger {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
}
.prop-btn.danger:hover { background: rgba(239,68,68,0.25); }

/* LAYER LIST */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(15,23,42,0.5);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  transition: all .15s;
}
.layer-item:hover { background: var(--surface); border-color: var(--border); }
.layer-item.selected { background: rgba(59,130,246,0.15); border-color: var(--accent-a); }
.layer-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.layer-name { flex: 1; truncate: true; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── CANVAS SELECTION HANDLES ─────────────────── */
.el-container {
  position: absolute;
  cursor: move;
  pointer-events: all;
  box-sizing: border-box;
}
.el-container.selected > .el-selection {
  display: block;
}
.el-selection {
  display: none;
  position: absolute;
  inset: -2px;
  border: 2px solid var(--accent-a);
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.3);
}
.resize-handle {
  position: absolute;
  width: var(--handle-size);
  height: var(--handle-size);
  background: #fff;
  border: 2px solid var(--accent-a);
  border-radius: 2px;
  pointer-events: all;
  z-index: 10;
}
.resize-handle.nw { top: calc(var(--handle-size) / -2); left: calc(var(--handle-size) / -2); cursor: nw-resize; }
.resize-handle.ne { top: calc(var(--handle-size) / -2); right: calc(var(--handle-size) / -2); cursor: ne-resize; }
.resize-handle.sw { bottom: calc(var(--handle-size) / -2); left: calc(var(--handle-size) / -2); cursor: sw-resize; }
.resize-handle.se { bottom: calc(var(--handle-size) / -2); right: calc(var(--handle-size) / -2); cursor: se-resize; }

.rotate-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-a);
  border-radius: 50%;
  pointer-events: all;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #fff;
  z-index: 10;
}
.rotate-handle:active { cursor: grabbing; }

/* TEXT ELEMENT */
.el-text {
  width: 100%;
  height: 100%;
  overflow: hidden;
  line-height: inherit;
  word-break: break-word;
  cursor: text;
  padding: 2px 4px;
}

/* IMAGE ELEMENT */
.el-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* ── MODALS ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 340px;
  max-width: 480px;
  box-shadow: var(--shadow);
}
.modal h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.modal label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.modal-btns {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.modal-btns .prop-btn { margin-bottom: 0; }

.modal-input.small {
  margin-bottom: 8px;
}

/* THERMAL MODAL */
.thermal-modal {
  min-width: 520px;
  max-width: 90vw;
}
.thermal-preview-canvas {
  display: block;
  max-width: 100%;
  border-radius: 4px;
  margin: 16px 0;
  border: 1px solid var(--border2);
  background: #fff;
}
.thermal-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.thermal-controls label {
  text-transform: none;
  font-size: 12px;
  color: var(--text-muted);
}
.thermal-controls select,
.thermal-controls input[type=range] {
  margin-left: 6px;
}

/* ── TOAST ────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: #1e293b;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  opacity: 0;
  transition: all .3s ease;
  pointer-events: none;
  z-index: 2000;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── SCROLLBARS ───────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

/* ── PRINT STYLES ─────────────────────────────── */
@media print {
  body { background: white; margin: 0; padding: 0; }
  .app-header, .side-panel, .zoom-controls { display: none !important; }
  .workspace { overflow: visible; }
  .canvas-outer { padding: 0; background: white; display: block; }
  .canvas-wrapper { position: static; transform: none !important; }
  #design-canvas {
    border-radius: 0;
    box-shadow: none;
    display: block;
    width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
  }
  .overlay { display: none !important; }
  @page { margin: 0; size: 200mm 100mm landscape; }
}
