/* ===== LabAI floating trigger button ===== */
#labai-trigger {
  position: fixed;
  bottom: 24px;
  right: 100px; /* offset from the existing LabConnect assistant button */
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488, #0369a1);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 99998;
  touch-action: none;
  user-select: none;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: box-shadow 0.2s ease;
}
#labai-trigger:hover {
  box-shadow: 0 6px 20px rgba(13, 148, 136, 0.5);
}
#labai-trigger.labai-dragging {
  cursor: grabbing;
}

/* ===== Window shell ===== */
#labai-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 900px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#labai-window.labai-open {
  display: flex;
}

#labai-header {
  background: linear-gradient(135deg, #0d9488, #0369a1);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  flex-shrink: 0;
}
#labai-header.labai-dragging {
  cursor: grabbing;
}
#labai-header .labai-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}
#labai-header .labai-controls button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  margin-left: 6px;
}
#labai-header .labai-controls button:hover {
  background: rgba(255,255,255,0.28);
}

/* ===== Whole-window resize grip (desktop only) ===== */
#labai-window-resize-grip {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  z-index: 3;
}
#labai-window-resize-grip::after {
  content: "";
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #cbd5e0;
  border-bottom: 2px solid #cbd5e0;
  border-radius: 0 0 2px 0;
}
#labai-window-resize-grip:hover::after,
#labai-window-resize-grip.labai-resizing::after {
  border-color: #0d9488;
}

/* ===== Pane container (desktop: side by side) ===== */
#labai-panes {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.labai-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid #eef0f3;
  transition: flex-basis 0.25s ease, min-width 0.25s ease;
}
.labai-pane:last-child { border-right: none; }

.labai-pane[data-pane="user"]      { flex: 0 0 22%; background: #fafbfc; }
.labai-pane[data-pane="assistant"] { flex: 1 1 46%; background: #fff; }
.labai-pane[data-pane="workspace"] { flex: 0 0 32%; background: #fafbfc; }

.labai-pane.labai-collapsed {
  flex: 0 0 44px !important;
  min-width: 44px;
}
.labai-pane.labai-collapsed .labai-pane-body { display: none; }
.labai-pane.labai-collapsed .labai-pane-title { writing-mode: vertical-rl; text-orientation: mixed; }
.labai-pane.labai-collapsed .labai-pane-header { flex-direction: column; height: 100%; padding: 12px 0; }

.labai-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f3;
  flex-shrink: 0;
}
.labai-pane-grip {
  cursor: grab;
  color: #cbd5e0;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px 2px 0;
  touch-action: none;
  user-select: none;
}
.labai-pane-grip:hover { color: #718096; }
.labai-pane-grip:active { cursor: grabbing; }
.labai-pane-title { flex: 1; }
.labai-pane.labai-pane-dragging {
  opacity: 0.4;
}
.labai-pane-placeholder {
  border: 2px dashed #0d9488;
  border-radius: 10px;
  background: rgba(13, 148, 136, 0.06);
  flex-shrink: 0;
}
.labai-pane-title {
  font-size: 13px;
  font-weight: 700;
  color: #0d141a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.labai-collapse-btn {
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
}
.labai-collapse-btn:hover { background: #eef0f3; color: #0d141a; }

.labai-clear-btn {
  background: none;
  border: 1px solid #eef0f3;
  color: #718096;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 6px;
  margin-right: 6px;
}
.labai-clear-btn:hover { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.labai-pane.labai-collapsed .labai-clear-btn { display: none; }

.labai-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 14px;
  color: #4a5568;
}

/* ===== Resize handles between panes (desktop only) ===== */
.labai-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.labai-resize-handle:hover,
.labai-resize-handle.labai-resizing {
  background: #0d9488;
}

/* ===== Shared utility classes (used by more than one pane) ===== */
.labai-placeholder {
  color: #a0aec0;
  font-size: 13px;
  text-align: center;
  padding: 24px 8px;
  border: 1px dashed #eef0f3;
  border-radius: 10px;
}

/* ===== Mobile: stack panes, collapse becomes accordion, no resize/drag ===== */
@media (max-width: 782px) {
  #labai-trigger {
    right: 24px;
    bottom: 90px; /* stack above the existing assistant button on mobile */
  }
  #labai-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    right: 12px;
    bottom: 84px;
  }
  #labai-header {
    cursor: default; /* dragging a full-screen mobile window doesn't make sense */
  }
  #labai-panes {
    flex-direction: column;
    overflow-y: auto;
  }
  .labai-pane {
    border-right: none;
    border-bottom: 1px solid #eef0f3;
    flex: 0 0 auto !important;
  }
  .labai-pane .labai-pane-body {
    max-height: 260px;
  }
  .labai-pane.labai-collapsed {
    flex: 0 0 auto !important;
    min-width: 0;
  }
  .labai-pane.labai-collapsed .labai-pane-header {
    flex-direction: row;
    height: auto;
    padding: 10px 12px;
  }
  .labai-pane.labai-collapsed .labai-pane-title {
    writing-mode: horizontal-tb;
  }
  .labai-resize-handle { display: none; }
}
