/* public/styles.css — sidebar + persistent viewer layout */

html, body { height: 100%; }
#of-root { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* --- App shell: sidebar + viewer --- */
.of-app {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* --- Sidebar: tree-nav column + content column, Ansys-Fluent-style --- */
.of-sidebar {
  width: 520px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

/* Tree navigation column (repurposed #of-tabbar element) */
.of-tabbar {
  width: 172px;
  flex-shrink: 0;
  overflow-y: auto;
  background: #fafafa;
  border-right: 1px solid #e8e8e8;
  padding: 14px 0 20px;
}
.of-tree-group { margin-bottom: 16px; }
.of-tree-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #999;
  padding: 0 14px 6px;
}
.of-tree-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1.3;
}
.of-tree-node:hover { background: #f0f0f0; color: #1a1a1a; }
.of-tree-node.active {
  background: #eef0ff;
  color: #1a1a1a;
  font-weight: 700;
  border-left-color: #3B4CCA;
}
.of-tree-icon {
  flex-shrink: 0;
  font-size: 12px;
  width: 16px;
  text-align: center;
  color: #999;
}
.of-tree-node.active .of-tree-icon { color: #3B4CCA; }

.of-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 40px;
  min-width: 0;
}

.of-tree-panel { display: none; }
.of-tree-panel.active { display: block; }

.of-nav-row-single { justify-content: flex-end; border-top: none; margin-top: 22px; padding-top: 0; }

.of-hint { font-size: 11.5px; color: #888; line-height: 1.5; margin-bottom: 10px; }

.of-btn-sm { padding: 8px 14px; font-size: 11.5px; width: 100%; }

.of-solver-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}
.of-solver-detail .of-solver-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #888;
  margin-bottom: 6px;
}
.of-solver-detail .of-solver-desc {
  font-size: 12px;
  color: #555;
  line-height: 1.55;
}

/* --- Patch table (in sidebar, single column now) --- */
.of-patch-table { margin-bottom: 8px; }
.of-patch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.of-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
}
.of-checkbox-row input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.of-value-inputs {
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #eee;
}
.of-value-inputs label {
  font-size: 10.5px;
  color: #777;
  display: block;
  margin-bottom: 4px;
}
.of-vector-inputs { display: flex; gap: 6px; }
.of-value-input {
  font-size: 11.5px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 5px;
  width: 100%;
}
.of-vector-inputs .of-value-input { width: 33%; }
.of-patch-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.of-patch-name { font-size: 12.5px; font-weight: 600; color: #1a1a1a; }
.of-patch-sub { font-size: 10.5px; color: #999; margin-top: 1px; }
.of-patch-row select { width: 140px; flex-shrink: 0; font-size: 11.5px; padding: 7px 8px; }

.of-template-hint {
  font-size: 11.5px;
  line-height: 1.55;
  color: #1a4d2e;
  background: #eafaf0;
  border: 1px solid #c8e6c9;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

/* --- Case template buttons --- */
.of-template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.of-template-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 3px;
  padding: 12px 14px;
  height: auto;
  white-space: normal;
}
.of-template-btn b { font-size: 12.5px; color: #1a1a1a; }
.of-template-btn span { font-size: 11px; color: #888; font-weight: 400; line-height: 1.4; }
.of-template-btn.active { border-color: #3B4CCA; background: #eef0ff; }

/* --- Uploaded file chips (wrap, name-only) --- */
.of-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.of-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 9px;
  background: #f4f4f4;
  border: 1px solid #e0e0e0;
  border-radius: 14px;
  font-size: 11.5px;
  color: #333;
  max-width: 100%;
}
.of-file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}
.of-file-remove {
  cursor: pointer;
  color: #999;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}
.of-file-remove:hover { color: #c0392b; }

.of-file-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

/* --- Mesh field grid --- */
.of-mesh-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.of-mesh-field { margin-bottom: 6px; }
.of-mesh-field label {
  display: block;
  font-size: 10.5px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
}

/* --- Location status --- */
.of-loc-status {
  font-size: 11px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  font-weight: 500;
}
.of-loc-status.inside { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.of-loc-status.outside { background: #fbe9e7; color: #c62828; border: 1px solid #ffccbc; }
.of-loc-status.unknown { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }

/* --- Viewer --- */
.of-viewer-wrap {
  flex: 1;
  position: relative;
  background: #f5f5f5;
  min-width: 0;
}
#of-viewer-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#of-viewer-canvas:active { cursor: grabbing; }

.of-viewer-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,26,0.85);
  color: #fff;
  font-size: 11.5px;
  padding: 8px 16px;
  border-radius: 20px;
  display: none;
  align-items: center;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s;
}

.of-viewer-legend {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.92);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.of-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: #333;
  font-weight: 500;
}
.of-legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

/* --- Toast notifications --- */
.of-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  border: 1px solid #333;
  padding: 12px 24px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  max-width: 90vw;
  background: #333;
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.of-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* --- Responsive: stack sidebar above viewer on narrow screens --- */
@media (max-width: 860px) {
  .of-app { flex-direction: column; }
  .of-sidebar { width: 100%; max-height: 60vh; flex-direction: column; border-right: none; border-bottom: 1px solid #e0e0e0; }
  .of-tabbar { width: 100%; max-height: 140px; border-right: none; border-bottom: 1px solid #e8e8e8; }
  .of-viewer-wrap { min-height: 300px; }
  .of-mesh-grid { grid-template-columns: 1fr 1fr; }
}

.of-viewer-wrap {
    position: relative;
}

.of-selected-patch {
    position: absolute;
    top: 12px;
    left: 12px;

    z-index: 1000;

    background: rgba(255, 255, 255, 0.95);
    color: #222;

    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;

    font-size: 13px;
    font-weight: 600;

    pointer-events: none;
}

/* --- Collapsible sections (Case tree / 0/ field preview) --- */
.of-collapsible-summary {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.of-collapsible-summary::before {
    content: '▸';
    font-size: 9px;
    display: inline-block;
    transition: transform 0.15s;
}
details[open] > .of-collapsible-summary::before {
    transform: rotate(90deg);
}
.of-collapsible-summary::-webkit-details-marker {
    display: none;
}