/* ============================================================
   QSCad Mini — components.css
   UI components: buttons, inputs, tool buttons, panel elements
   ============================================================ */

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  padding:       7px 14px;
  border-radius: 6px;
  border:        1px solid var(--border);
  background:    var(--card);
  color:         var(--text);
  font-family:   var(--mono);
  font-size:     11px;
  cursor:        pointer;
  transition:    all .15s;
  white-space:   nowrap;
}

.btn:hover { background: var(--border); }

.btn-primary {
  background:   rgba(56, 189, 248, .15);
  border-color: var(--accent);
  color:        var(--accent);
}
.btn-primary:hover { background: rgba(56, 189, 248, .25); }

.btn-ghost {
  background:  none;
  border-style: dashed;
  color:       var(--muted);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text); }

.btn-danger {
  background:   rgba(248, 113, 113, .12);
  border-color: var(--red);
  color:        var(--red);
}

.btn-row {
  display: flex;
  gap:     6px;
}

/* ── Inputs ─────────────────────────────────────────────────── */
.setting-input {
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: 5px;
  color:         var(--text);
  font-family:   var(--mono);
  font-size:     11px;
  padding:       5px 8px;
  width:         100%;
  outline:       none;
  transition:    border-color .15s;
}

.setting-input:focus { border-color: var(--accent); }

/* Select-all on click — JS ใน index.html จัดการ onfocus */
input[type="number"]:focus,
input[type="text"]:focus { border-color: var(--accent); }

select.setting-input { cursor: pointer; }

.setting-row {
  display:     flex;
  align-items: center;
  gap:         8px;
  margin-bottom: 8px;
}

.setting-row label {
  font-size:   11px;
  color:       var(--muted);
  white-space: nowrap;
  min-width:   80px;
}

.setting-val {
  font-family: var(--mono);
  font-size:   11px;
  color:       var(--accent);
}

/* ── Tool Buttons (left toolbar) ─────────────────────────────── */
.tool-btn {
  width:         36px;
  height:        36px;
  border-radius: 7px;
  border:        1px solid transparent;
  background:    none;
  color:         var(--muted);
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     18px;
  transition:    all .15s;
  position:      relative;
  flex-shrink:   0;
}

.tool-btn:hover {
  background: var(--card);
  color:      var(--text);
}

.tool-btn.active {
  background:   rgba(56, 189, 248, .15);
  border-color: var(--accent);
  color:        var(--accent);
}

.tool-btn.green.active {
  background:   rgba(74, 222, 128, .15);
  border-color: var(--green);
  color:        var(--green);
}

.tool-btn.orange.active {
  background:   rgba(251, 146, 60, .15);
  border-color: var(--orange);
  color:        var(--orange);
}

.tool-btn.purple.active {
  background:   rgba(167, 139, 250, .15);
  border-color: var(--purple);
  color:        var(--purple);
}

.tool-tip {
  position:      absolute;
  left:          52px;
  top:           50%;
  transform:     translateY(-50%);
  background:    var(--card);
  border:        1px solid var(--border);
  border-radius: 4px;
  padding:       4px 10px;
  font-size:     11px;
  font-family:   var(--mono);
  white-space:   nowrap;
  pointer-events: none;
  opacity:        0;
  transition:    opacity .15s;
  z-index:       100;
}

.tool-btn:hover .tool-tip { opacity: 1; }

.tool-sep {
  width:      28px;
  height:     1px;
  background: var(--border);
  margin:     2px 0;
}

/* ── Panel Tabs ─────────────────────────────────────────────── */
.ptab {
  flex:        1;
  height:      36px;
  display:     flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size:   10px;
  color:       var(--muted);
  cursor:      pointer;
  border-bottom: 2px solid transparent;
  transition:  all .15s;
  white-space: nowrap;
  padding:     0 4px;
}

.ptab:hover { color: var(--text); }

.ptab.active {
  color:        var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Panel Components ────────────────────────────────────────── */
.sec-header {
  font-family:   var(--mono);
  font-size:     10px;
  font-weight:   600;
  color:         var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin:        14px 0 6px;
}

.sec-header:first-child { margin-top: 0; }

.nbadge {
  background:    var(--border);
  border-radius: 3px;
  padding:       1px 5px;
  font-family:   var(--mono);
  font-size:     9px;
  color:         var(--muted);
}

/* ── Layer Rows ─────────────────────────────────────────────── */
.layer-row {
  display:       flex;
  align-items:   center;
  gap:           7px;
  padding:       6px 8px;
  border-radius: 5px;
  border:        1px solid transparent;
  cursor:        pointer;
  margin-bottom: 2px;
  transition:    all .12s;
}

.layer-row:hover { background: var(--card); }

.layer-row.active {
  background:   rgba(56, 189, 248, .08);
  border-color: rgba(56, 189, 248, .3);
}

.layer-swatch {
  width:         10px;
  height:        10px;
  border-radius: 2px;
  flex-shrink:   0;
}

.layer-name {
  flex:        1;
  font-family: var(--mono);
  font-size:   11px;
}

.color-picker {
  width:         20px;
  height:        20px;
  border:        none;
  background:    none;
  cursor:        pointer;
  padding:       0;
  border-radius: 3px;
  opacity:       0.6;
}

.color-picker:hover { opacity: 1; }

/* ── Object Rows ─────────────────────────────────────────────── */
.obj-row {
  display:       flex;
  align-items:   center;
  gap:           6px;
  padding:       5px 8px;
  border-radius: 5px;
  border:        1px solid transparent;
  cursor:        pointer;
  margin-bottom: 2px;
  font-family:   var(--mono);
  font-size:     11px;
  transition:    all .12s;
}

.obj-row:hover { background: var(--card); }

.obj-row.selected {
  background:   rgba(56, 189, 248, .1);
  border-color: rgba(56, 189, 248, .4);
}

.del-btn {
  background:  none;
  border:      none;
  color:       var(--muted);
  cursor:      pointer;
  font-size:   11px;
  padding:     0 3px;
  opacity:     0;
}

.obj-row:hover .del-btn { opacity: 1; }
.del-btn:hover { color: var(--red); }

/* ── Empty Message ───────────────────────────────────────────── */
.empty-msg {
  text-align:  center;
  font-family: var(--mono);
  font-size:   12px;
  color:       var(--muted);
  margin-top:  40px;
  line-height: 1.8;
}

/* ── BOQ Table ───────────────────────────────────────────────── */
.boq-table {
  width:           100%;
  border-collapse: collapse;
  font-family:     var(--mono);
  font-size:       10px;
  margin-bottom:   8px;
}

.boq-table th {
  text-align:   left;
  color:        var(--muted);
  border-bottom: 1px solid var(--border);
  padding:      3px 6px;
  font-weight:  400;
}

.boq-table td {
  padding:      3px 6px;
  border-bottom: 1px solid rgba(38, 48, 71, 0.5);
}

.boq-table td.val { text-align: right; color: var(--text); }

.boq-total td {
  color:        var(--accent);
  font-weight:  600;
  border-top:   1px solid var(--border);
  border-bottom: none;
}

/* ── Sheet Tabs ──────────────────────────────────────────────── */
.sheet-tab {
  padding:       4px 12px;
  border-radius: 4px;
  border:        1px solid var(--border);
  background:    var(--card);
  color:         var(--muted);
  font-family:   var(--mono);
  font-size:     10px;
  cursor:        pointer;
  white-space:   nowrap;
  transition:    all .12s;
}

.sheet-tab:hover { color: var(--text); }

.sheet-tab.active {
  background:   rgba(56, 189, 248, .15);
  border-color: var(--accent);
  color:        var(--accent);
}

.sheet-tab.add-tab {
  border-style: dashed;
  background:   none;
}

/* ── Floor Rows (in setup modal) ─────────────────────────────── */
.floor-row {
  display:     flex;
  align-items: center;
  gap:         8px;
  margin-bottom: 6px;
}

.floor-name {
  font-family: var(--mono);
  font-size:   12px;
  min-width:   50px;
}

/* ── Setup Modal specific ────────────────────────────────────── */
.setup-grid {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   16px;
  margin-bottom:         20px;
}

.setup-col { display: flex; flex-direction: column; gap: 10px; }

.setup-label {
  font-family: var(--mono);
  font-size:   11px;
  color:       var(--muted);
  margin-bottom: 4px;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Color Dot (layer panel) ────────────────────────────────── */
.color-dot-wrap {
  position:  relative;
  cursor:    pointer;
  flex-shrink: 0;
}

.color-dot {
  display:       block;
  width:         16px;
  height:        16px;
  border-radius: 4px;
  border:        2px solid rgba(255,255,255,0.15);
  transition:    border-color .15s;
}

.color-dot-wrap:hover .color-dot { border-color: rgba(255,255,255,0.5); }

.color-hidden {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Layer qty display */
.layer-qty {
  font-family: var(--mono);
  font-size:   10px;
  color:       var(--accent);
  margin-left: auto;
  margin-right: 4px;
  white-space: nowrap;
}

/* Delete layer button */
.del-layer-btn {
  background:  none;
  border:      none;
  color:       var(--muted);
  cursor:      pointer;
  font-size:   10px;
  padding:     0 2px;
  opacity:     0;
  flex-shrink: 0;
  line-height: 1;
}

.layer-row:hover .del-layer-btn { opacity: 1; }
.del-layer-btn:hover { color: var(--red); }

/* ── Grid Dialog ────────────────────────────────────────────── */
.grid-check-row {
  display:     flex;
  align-items: center;
  gap:         6px;
  padding:     6px 8px;
  background:  var(--bg);
  border:      1px solid var(--border);
  border-radius: 5px;
  cursor:      pointer;
  font-family: var(--mono);
  font-size:   11px;
  transition:  border-color .15s;
}
.grid-check-row:hover { border-color: var(--muted); }
.grid-check-row input[type="checkbox"] { flex-shrink:0; cursor:pointer; }
