:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --danger-color: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --bg-main: #f9fafb;
  --bg-panel: #ffffff;
  --border-color: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-main);
}

/* Layout Containers */
#root {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.ab-app-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  width: 100%;
  position: relative;
}

.ab-workspace {
  display: flex;
  flex-grow: 1;
  overflow: hidden;
  position: relative;
}

/* Toolbar */
.ab-toolbar {
  height: 64px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}

.ab-toolbar-group {
  display: flex;
  gap: 8px;
  padding-right: 16px;
  border-right: 1px solid var(--border-color);
  align-items: center;
}

.ab-toolbar-group:last-child {
  border-right: none;
}

/* Buttons */
.ab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.ab-btn:hover:not(:disabled) {
  background-color: var(--bg-main);
  border-color: var(--border-color);
}

.ab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ab-btn.active {
  background-color: #eff6ff;
  color: var(--primary-color);
  border-color: #bfdbfe;
}

.ab-btn-primary {
  background-color: var(--primary-color);
  color: white;
  flex-direction: row;
  gap: 6px;
}

.ab-btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.ab-btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger-color);
  border-color: var(--danger-border);
}

.ab-btn-danger:hover:not(:disabled) {
  background-color: #fee2e2;
}

.ab-btn-icon {
  padding: 6px;
  flex-direction: row;
}

/* Viewport & Canvas */
.ab-viewport {
  flex-grow: 1;
  background-color: #f3f4f6;
  overflow: auto;
  position: relative;
  user-select: none;
}

.ab-canvas-container {
  position: absolute;
  background-color: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transform-origin: top left;
}

.ab-image {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.ab-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9ca3af;
}

/* Annotations & Overlays */
.ab-overlay-mask {
  position: absolute;
  background-color: rgba(239, 68, 68, 0.2);
  border: 1px solid #b91c1c;
  pointer-events: auto;
}

.ab-annotation-box {
  position: absolute;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.2s;
  z-index: 10;
  background-color: rgba(121, 191, 247,0.2);
}

.ab-annotation-box:hover {
  border-color: #93c5fd;
}

.ab-annotation-box.selected {
  border-color: var(--primary-color);
  z-index: 20;
}

.ab-annotation-bg {
  width: 100%;
  height: 100%;
}

.ab-annotation-box.selected .ab-annotation-bg {
  background-color: rgba(59, 130, 246, 0.1);
}

.ab-balloon-badge {
  position: absolute;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  font-weight: bold;
  cursor: move;
  color: var(--primary-color);
  border:1px solid var(--primary-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  transition: transform 0.2s;
  container-type: size;
}
.ab-balloon-badge span {
  font-size: 50cqh;
  line-height: 1;
}
.ab-annotation-box.selected .ab-balloon-badge {
  background-color: var(--primary-color);
  transform: scale(1.1);
}

.ab-drawing-preview {
  position: absolute;
  border: 2px solid var(--primary-color);
  background-color: rgba(59, 130, 246, 0.1);
}

.ab-drawing-preview.mask-mode {
  border-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.2);
}

/* Property Editor */
.ab-property-editor {
  width: 320px;
  background-color: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 500px;
  flex-shrink: 0;
  z-index: 20;
  box-shadow: -4px 0 15px -3px rgba(0, 0, 0, 0.1);
}

.ab-panel-header {
  padding: 16px;
  background-color: #f9fafb;
  border-bottom: 1px solid var(--border-color);
}

.ab-panel-title {
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  font-size: 1rem;
}

.ab-panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0 0;
}

.ab-form-group {
  margin-bottom: 12px;
}

.ab-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ab-input, .ab-select, .ab-textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  outline: none;
}

.ab-input:focus, .ab-select:focus, .ab-textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

.ab-textarea {
  resize: none;
  height: 80px;
  font-family: monospace;
}

.ab-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Table */
.ab-table-container {
  height: 250px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-panel);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width:100%;
  min-width: 40%;
}

.ab-table-header {
  padding: 8px 16px;
  background-color: #f3f4f6;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ab-table-wrapper {
  overflow: auto;
  flex-grow: 1;
}

.ab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.ab-table th {
  background-color: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 8px 16px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.ab-table td {
  padding: 8px 16px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-main);
}

.ab-table tr:hover {
  background-color: #eff6ff;
  cursor: pointer;
}

.ab-table tr.selected {
  background-color: #dbeafe;
}

/* Badges */
.ab-badge {
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ab-badge-pending { background-color: #f3f4f6; color: #4b5563; }
.ab-badge-review { background-color: #ffedd5; color: #c2410c; }
.ab-badge-approved { background-color: #dcfce7; color: #15803d; }

/* Modal */
.ab-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  pointer-events: auto;
  z-index: 40;
}

.ab-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 600px;
  max-width: 90%;
  z-index: 50;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.ab-modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f9fafb;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.ab-modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: 70vh;
}

.ab-modal-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background-color: #f9fafb;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.ab-tol-table {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  font-size: 14px;
}

.ab-tol-table th {
  background-color: #f3f4f6;
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
}

.ab-tol-table td {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
}

.ab-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ab-input-mini {
  width: 80px;
  text-align: center;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.hidden { display: none !important; }
.pointer-events-none { pointer-events: none; }

/* Container Overlay */
.progress-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  background-color: rgba(0, 0, 0, 0.5); /* bg-black/50 */
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px); /* backdrop-blur-sm */
}

/* Helper to hide the element (standard Tailwind utility replacement) */
.progress-overlay.hidden {
  display: none;
}

/* Modal Box */
.progress-modal {
  background-color: #ffffff;
  padding: 1.5rem; /* p-6 */
  border-radius: 0.5rem; /* rounded-lg */
  width: 20rem; /* w-80 */
  text-align: center;
  /* shadow-xl approximation */
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
  0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Title */
.progress-title {
  font-weight: 600; /* font-semibold */
  color: #1f2937; /* text-gray-800 */
  margin-bottom: 1rem; /* mb-4 */
  margin-top: 0;
}

/* Progress Bar Background (Track) */
.progress-track {
  width: 100%;
  background-color: #e5e7eb; /* bg-gray-200 */
  border-radius: 9999px; /* rounded-full */
  height: 0.625rem; /* h-2.5 */
  margin-bottom: 0.5rem; /* mb-2 */
  overflow: hidden;
}

/* Progress Bar Foreground (Fill) */
.progress-fill {
  background-color: #2563eb; /* bg-blue-600 */
  height: 0.625rem; /* h-2.5 */
  border-radius: 9999px; /* rounded-full */
  transition: all 300ms ease; /* transition-all duration-300 */
}

/* Helper Text */
.progress-text {
  font-size: 0.75rem; /* text-xs */
  color: #6b7280; /* text-gray-500 */
  font-weight: 500; /* font-medium */
  margin: 0;
}
.ab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Icon sizing */
.btn-icon {
  width: 14px;   /* w-3.5 */
  height: 14px;  /* h-3.5 */
  margin-bottom: 2px;
}

/* Saving animation */
.ab-btn.is-saving .btn-icon {
  animation: bounce 1s infinite;
}

/* Bounce keyframes (Tailwind animate-bounce equivalent) */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-25%);
  }
}

/* Property Editor (PE) Styles */
.pe-header {
  padding: 1rem;
  background-color: #f9fafb; /* gray-50 */
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
}

.pe-title {
  font-weight: 600;
  color: #374151; /* gray-700 */
  margin: 0;
  font-size: 1rem;
}

.pe-subtitle {
  font-size: 0.75rem; /* text-xs */
  color: #6b7280; /* gray-500 */
  margin: 0;
}

.pe-body {
  padding: 1rem;
}

.pe-warning {
  background-color: #fefce8; /* yellow-50 */
  border: 1px solid #fef08a; /* yellow-200 */
  border-radius: 0.25rem;
  padding: 0.75rem;
  font-size: 0.875rem; /* text-sm */
  color: #854d0e; /* yellow-800 */
  margin-bottom: 1rem;
}

.pe-label {
  font-size: 0.75rem; /* text-xs */
  font-weight: 500;
  color: #6b7280; /* gray-500 */
  margin-bottom: 0.5rem;
}

.pe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  font-size: 0.75rem; /* text-xs */
  color: #4b5563; /* gray-600 */
}

.pe-footer {
  padding: 1rem;
  border-top: 1px solid #e5e7eb; /* gray-200 */
  background-color: #f9fafb; /* gray-50 */
}

.pe-btn-delete {
  width: 100%;
  background-color: white;
  border: 1px solid #d1d5db; /* gray-300 */
  color: #374151; /* gray-700 */
  padding: 0.375rem 0;
  border-radius: 0.25rem;
  font-size: 0.875rem; /* text-sm */
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pe-btn-delete:hover {
  background-color: #fef2f2; /* red-50 */
  color: #dc2626; /* red-600 */
  border-color: #fecaca; /* red-200 */
}

.pe-icon {
  width: 0.875rem;
  height: 0.875rem;
}
.pe-empty-state {
  width: 100%;
  height: 100%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #9ca3af; /* gray-400 */
  font-size: 0.875rem; /* text-sm */
}

.pe-empty-subtext {
  font-size: 0.75rem; /* text-xs */
  margin-top: 0.25rem; /* mt-1 */
  margin-bottom: 0;
}
/* Container for the whole widget */
.bst-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--s-input-outline);; /* gray-200 */
  border-radius: 0.5rem;
  overflow: hidden;
  height: 100%; /* Adjust as needed */
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header Section */
.bst-header {
  background-color: #f3f4f6; /* gray-100 */
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bst-title {
  font-weight: 600;
  font-size: 0.875rem; /* text-sm */
  margin: 0;
}

/* Button Base Styles */
.bst-btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

/* Add Button Specifics */
.bst-btn-add {
  color: #2563eb; /* blue-600 */
}

.bst-btn-add:hover {
  background-color: #dbeafe; /* blue-100 */
}

/* Table Layout */
.bst-table-wrapper {
  overflow: auto;
  flex-grow: 1;
}

.bst-table {
  width: 100%;
  text-align: left;
  font-size: 0.875rem; /* text-sm */
  border-collapse: collapse;
}

.bst-thead {
  background-color: #f9fafb; /* gray-50 */
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.bst-th {
  padding: 0.5rem 1rem;
  font-weight: 500;
  color: #4b5563; /* gray-600 */
  border-bottom: 1px solid #e5e7eb;
}

/* Table Rows and Cells */
.bst-row {
  border-bottom: 1px solid var(--s-input-outline);
}

.bst-row:hover {
  background-color: #f9fafb; /* gray-50 */
}

.bst-td {
  padding: 0.375rem 1rem;
  vertical-align: middle;
}

/* Input Fields */
.bst-input {
  width: 100%;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  padding: 0.25rem;
  outline: none;
  font-size: inherit;
  box-sizing: border-box; /* Ensures padding doesn't break width */
}

.bst-input:focus {
  background-color: #fff;
  border-color: #93c5fd; /* blue-300 */
  box-shadow: 0 0 0 1px #93c5fd;
}

/* Delete Button Specifics */
.bst-btn-delete {
  color: #9ca3af; /* gray-400 */
  opacity: 0; /* Hidden by default */
}

.bst-btn-delete:hover {
  color: #ef4444; /* red-500 */
}

/* Show delete button only when row is hovered */
.bst-row:hover .bst-btn-delete {
  opacity: 1;
}

/* Column Widths */
.col-description { width: 40%; }
.col-action { width: 2.5rem; }

/* --- Ballooning Widget Shared Styles (bw-) --- */

/* Container */
.bw-container {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* Header */
.bw-header {
  background-color: #f3f4f6;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bw-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
  margin: 0;
}

/* Buttons */
.bw-btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.bw-btn-add {
  color: #2563eb; /* blue-600 */
}

.bw-btn-add:hover {
  background-color: #dbeafe; /* blue-100 */
}

.bw-btn-delete {
  color: #9ca3af; /* gray-400 */
  opacity: 0;
}

.bw-btn-delete:hover {
  color: #ef4444; /* red-500 */
}

/* Table Structure */
.bw-table-wrapper {
  overflow: auto;
  flex-grow: 1;
}

.bw-table {
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  border-collapse: collapse;
}

.bw-thead {
  background-color: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.bw-th {
  padding: 0.5rem 1rem;
  font-weight: 500;
  color: #4b5563;
  border-bottom: 1px solid #e5e7eb;
}

.bw-row {
  border-bottom: 1px solid #f3f4f6;
}

.bw-row:hover {
  background-color: #f9fafb;
}

/* Show delete button on row hover */
.bw-row:hover .bw-btn-delete {
  opacity: 1;
}

.bw-td {
  padding: 0.375rem 1rem;
  vertical-align: middle;
}

/* Inputs */
.bw-input {
  width: 100%;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  padding: 0.25rem;
  outline: none;
  font-size: inherit;
  box-sizing: border-box;
}

.bw-input:focus {
  background-color: #fff;
  border-color: #93c5fd; /* blue-300 */
  box-shadow: 0 0 0 1px #93c5fd;
}

.col-w24 { width: 6rem; }
.col-w10 { width: 2.5rem; }
.bw-panel-col {
  flex: 1 1 0%;        /* flex-1 */
  display: flex;       /* flex */
  flex-direction: column; /* flex-col */
  min-width: 0;        /* min-w-0 */
  background-color: #ffffff; /* bg-white */
  border-left: 1px solid #e5e7eb; /* border-l (gray-200) */
}
.bw-bottom-panel {
  height: 20rem; /* h-48 (192px) */
  border-top: 1px solid #e5e7eb; /* border-t */
  background-color: #ffffff; /* bg-white */
  display: flex; /* flex */
  flex-direction: row; /* flex-row */
  flex-shrink: 0; /* flex-shrink-0 */
  overflow: hidden; /* overflow-hidden */
}

/* Replicate 'divide-x': Add left border to every child except the first one */
.bw-bottom-panel > * + * {
  border-left: 1px solid #e5e7eb;
}

/* --- Ballooning Summary Specifics --- */

/* Content Area */
.bw-summary-content {
  overflow-y: auto;
  overflow-x: hidden;
  flex-grow: 1;
  padding: 0.5rem;
}

/* Summary Row */
.bw-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem; /* py-2 px-2 */
  border-bottom: 1px solid #f9fafb; /* border-gray-50 */
  transition: background-color 0.2s;
}

.bw-summary-row:last-child {
  border-bottom: none;
}

.bw-summary-row:hover {
  background-color: #f9fafb; /* gray-50 */
}

/* Left Group (Dot + Text) */
.bw-summary-group {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* gap-2 */
}

/* Color Dot */
.bw-dot {
  width: 0.75rem; /* w-3 */
  height: 0.75rem; /* h-3 */
  border-radius: 9999px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

/* Text Truncation */
.bw-label-truncate {
  font-size: 0.875rem; /* text-sm */
  color: #374151; /* gray-700 */
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  display: block;
}

/* Count Badge */
.bw-badge {
  font-size: 0.875rem; /* text-sm */
  font-weight: 600;
  color: #4b5563; /* gray-600 */
  background-color: #f3f4f6; /* gray-100 */
  padding: 0.125rem 0.5rem; /* px-2 py-0.5 */
  border-radius: 9999px;
}

/* Meta Text (Total Count) */
.bw-meta-text {
  font-size: 0.75rem; /* text-xs */
  color: #6b7280; /* gray-500 */
  font-weight: 500;
}

/* Empty State */
.bw-empty-state {
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem; /* text-xs */
  color: #9ca3af; /* gray-400 */
}
.bw-sidebar-fixed {
  width: 320px; /* w-64 */
  max-height: 200px;
  
  min-width: 16rem; /* min-w-[16rem] */
  display: flex; /* flex */
  flex-direction: column; /* flex-col */
  background-color: #ffffff; /* bg-white */
  border-left: 1px solid #e5e7eb; /* border-l */
}