/* 统一多内容单元格（参照 ResAsst/notes.html）
   主类名：.iar-content-cell*
   兼容旧类名：.note-cell* / .cell-actions / .project-note-cell*
*/

.iar-content-cells,
#noteContentCells {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.iar-content-cell,
.note-cell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.iar-content-cell-body,
.note-cell .note-cell-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.iar-content-cell-format-badge,
.note-cell .note-cell-format-badge {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.25rem;
  padding: 0.1rem 0.4rem;
  line-height: 1.4;
}

.iar-content-cell-content,
.note-cell .note-cell-content {
  flex: none;
  width: 100%;
  min-height: 72px;
  max-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  resize: none;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.875rem;
  box-sizing: border-box;
}

.iar-content-cell-preview,
.note-cell .note-cell-preview {
  width: 100%;
  min-height: 72px;
  max-height: 360px;
  overflow: auto;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  background: #fff;
  white-space: normal;
  word-break: break-word;
  box-sizing: border-box;
}

.iar-content-cell.is-editing .iar-content-cell-preview,
.note-cell.is-editing .note-cell-preview {
  background: #f8fafc;
  border-style: dashed;
}

.iar-content-cell.is-editing .iar-content-cell-content,
.note-cell.is-editing .note-cell-content {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.12);
}

.iar-content-cell-preview img,
.note-cell .note-cell-preview img,
.iar-content-cell-view-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.35rem 0;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  cursor: zoom-in;
}

.iar-content-cell-preview img.is-selected,
.note-cell .note-cell-preview img.handwrite-selected {
  outline: 3px solid rgba(59, 130, 246, 0.9);
  outline-offset: 2px;
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 0 0.75rem rgba(59, 130, 246, 0.25);
}

.iar-content-cell-remark,
.note-cell .note-cell-remark {
  flex: none;
  width: 100%;
  min-height: 48px;
  max-height: 180px;
  white-space: pre-wrap;
  word-break: break-word;
  resize: none;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 0.5rem;
  border: 1px solid #dc3545;
  border-radius: 0.25rem;
  font-family: inherit;
  box-sizing: border-box;
}

.iar-content-cell-actions,
.note-cell .cell-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  align-items: stretch;
  width: 6.25rem;
  min-width: 6.25rem;
}

.iar-content-cell-actions button,
.note-cell .cell-actions button {
  width: 100%;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 0.25rem 0.35rem;
  font-size: 0.875rem;
  line-height: 1.25;
  border-radius: 0.25rem;
  cursor: pointer;
  background: #fff;
}

.iar-content-cell-actions .iar-cc-btn-image { border: 1px solid #6ee7b7; color: #059669; }
.iar-content-cell-actions .iar-cc-btn-image:hover { background: #ecfdf5; }
.iar-content-cell-actions .iar-cc-btn-handwrite { border: 1px solid #cbd5e1; color: #334155; }
.iar-content-cell-actions .iar-cc-btn-handwrite:hover { background: #f8fafc; }
.iar-content-cell-actions .iar-cc-btn-view { border: 1px solid #93c5fd; color: #2563eb; }
.iar-content-cell-actions .iar-cc-btn-view:hover { background: #eff6ff; }
.iar-content-cell-actions .iar-cc-btn-delete { border: 1px solid #fca5a5; color: #dc2626; }
.iar-content-cell-actions .iar-cc-btn-delete:hover { background: #fef2f2; }
.iar-content-cell-actions .iar-cc-btn-copy,
.iar-content-cell-actions .iar-cc-btn-up,
.iar-content-cell-actions .iar-cc-btn-down { border: 1px solid #d1d5db; color: #374151; }
.iar-content-cell-actions .iar-cc-btn-copy:hover,
.iar-content-cell-actions .iar-cc-btn-up:hover,
.iar-content-cell-actions .iar-cc-btn-down:hover { background: #f3f4f6; }

.iar-content-cell.selected,
.note-cell.selected {
  outline: 4px solid rgba(13, 110, 253, 0.45);
  outline-offset: 3px;
  border-radius: 0.5rem;
}

.iar-content-cell.selected .iar-content-cell-content,
.iar-content-cell.selected .iar-content-cell-preview,
.note-cell.selected .note-cell-content,
.note-cell.selected .note-cell-preview {
  border: 1px solid rgba(13, 110, 253, 1);
  background-color: rgba(13, 110, 253, 0.07);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.14);
}

.iar-content-cell.selected .iar-content-cell-remark,
.note-cell.selected .note-cell-remark {
  border: 1px solid rgba(220, 53, 69, 0.95);
  background-color: rgba(220, 53, 69, 0.05);
  box-shadow: 0 0 0.25rem rgba(220, 53, 69, 0.14);
}

/* 面板（不依赖 Tailwind；Bootstrap 页亦可直接用） */
[data-iar-content-cells-panel] {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}
[data-iar-content-cells-panel] > .iar-content-cells-panel-header,
[data-iar-content-cells-panel] > .flex:first-child,
[data-iar-content-cells-panel] > div:first-child {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* 搜索框 */
.iar-content-cells-search {
  margin-bottom: 0.5rem;
}
.iar-content-cells-search-inner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.35rem;
  background: #fff;
}
.iar-content-cells-search-icon {
  color: #6c757d;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.iar-content-cells-search-input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  box-shadow: none !important;
  outline: none;
  background: transparent;
  padding: 0.2rem 0;
  font-size: 0.875rem;
}
.iar-content-cells-search-clear {
  border: 0;
  background: transparent;
  color: #adb5bd;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  border-radius: 0.25rem;
  line-height: 1;
  display: none;
}
.iar-content-cells-search-clear:hover { color: #6c757d; background: #f1f3f5; }
.iar-content-cells-search.is-active .iar-content-cells-search-clear { display: inline-flex; }
.iar-content-cells-search-count {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.75rem;
}
.iar-content-cell.iar-content-cell--search-hidden,
.note-cell.iar-content-cell--search-hidden {
  display: none !important;
}

/* 工具栏 */
.iar-content-cells-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.iar-content-cells-toolbar .iar-cc-tb-btn {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.25rem;
  color: #fff;
  border: none;
  cursor: pointer;
}
.iar-content-cells-toolbar .iar-cc-tb-btn-primary { background: #3b82f6; }
.iar-content-cells-toolbar .iar-cc-tb-btn-primary:hover { background: #2563eb; }
.iar-content-cells-toolbar .iar-cc-tb-btn-indigo { background: #6366f1; }
.iar-content-cells-toolbar .iar-cc-tb-btn-indigo:hover { background: #4f46e5; }
.iar-content-cells-toolbar .iar-cc-tb-btn-slate { background: #475569; }
.iar-content-cells-toolbar .iar-cc-tb-btn-slate:hover { background: #334155; }

/* 页面底部快速操作栏 */
.iar-content-cells-floating {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  padding: 0.5rem 1rem;
}

.iar-content-cells-floating.is-hidden,
.iar-content-cells-floating.hidden {
  display: none !important;
}

.iar-content-cells-floating-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.iar-content-cells-floating .iar-cc-fab-label {
  font-size: 0.875rem;
  color: #4b5563;
  white-space: nowrap;
  margin-right: 0.5rem;
}

.iar-content-cells-floating .iar-cc-fab-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 0.25rem;
  background: #fff;
  cursor: pointer;
}

.iar-content-cells-floating .iar-cc-fab-btn-blue {
  border: 1px solid #93c5fd;
  color: #2563eb;
}
.iar-content-cells-floating .iar-cc-fab-btn-blue:hover { background: #eff6ff; }
.iar-content-cells-floating .iar-cc-fab-btn-slate {
  border: 1px solid #cbd5e1;
  color: #334155;
}
.iar-content-cells-floating .iar-cc-fab-btn-slate:hover { background: #f8fafc; }
.iar-content-cells-floating .iar-cc-fab-btn-yellow {
  border: 1px solid #eab308;
  color: #854d0e;
}
.iar-content-cells-floating .iar-cc-fab-btn-yellow:hover { background: #fefce8; }
.iar-content-cells-floating .iar-cc-fab-btn-green {
  border: 1px solid #16a34a;
  color: #166534;
}
.iar-content-cells-floating .iar-cc-fab-btn-green:hover { background: #f0fdf4; }

/* 只读展示单元格（关联笔记 / 模板预览等） */
.iar-content-cells.project-note-cells,
.iar-content-cells.iar-linked-note-cells,
.project-note-cells,
.iar-linked-note-cells {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.iar-content-cell--readonly,
.iar-linked-note-cell,
.project-note-cell {
  flex-direction: column;
  gap: 0.5rem;
}

.iar-content-cell--readonly .iar-content-cell-main,
.iar-linked-note-cell-main,
.project-note-cell-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.iar-content-cell--readonly .iar-content-cell-content-plain,
.iar-linked-note-cell-content,
.project-note-cell-content {
  flex: 1;
  min-width: 0;
  min-height: 60px;
  margin: 0;
  padding: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

.iar-content-cell--readonly .iar-content-cell-content-plain img,
.iar-linked-note-cell-content img,
.project-note-cell-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 6px 0;
}

.iar-content-cell--readonly .iar-content-cell-actions,
.iar-linked-note-cell-actions,
.project-note-cell-actions {
  width: auto;
  min-width: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}

/* ---- 预览图片：右上角 OCR / 区域选择工具条 ---- */
.iar-cc-img-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  margin: 0.35rem 0;
}

.iar-cc-img-wrap > img {
  margin: 0 !important;
  max-width: 100%;
  height: auto;
  display: block;
}

.iar-cc-img-toolbar {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
  max-width: calc(100% - 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.iar-cc-img-wrap:hover .iar-cc-img-toolbar,
.iar-cc-img-wrap.is-region-selecting .iar-cc-img-toolbar,
.iar-cc-img-wrap.is-ocr-busy .iar-cc-img-toolbar,
.iar-cc-img-wrap.is-lightbox .iar-cc-img-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.iar-cc-img-wrap.is-lightbox {
  max-width: none;
  margin: 0;
}

.iar-cc-img-wrap.is-lightbox > img {
  max-width: none;
}

.iar-cc-img-toolbar [data-iar-img-act="zoom"] {
  color: #1d4ed8;
  border-color: #93c5fd;
}

.iar-cc-img-toolbar button {
  box-sizing: border-box;
  font-size: 11px;
  line-height: 1.25;
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.96);
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.iar-cc-img-toolbar button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.iar-cc-img-toolbar button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.iar-cc-img-toolbar button.is-active {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.iar-cc-img-region-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  cursor: crosshair;
  touch-action: none;
}

.iar-cc-img-wrap.is-region-selecting .iar-cc-img-region-layer {
  display: block;
}

.iar-cc-img-region-rect {
  position: absolute;
  border: 2px solid #3b82f6;
  background: rgba(59, 130, 246, 0.18);
  box-sizing: border-box;
  pointer-events: none;
}

.iar-cc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.8);
  box-sizing: border-box;
}

.iar-cc-lightbox.is-open {
  display: flex;
}

.iar-cc-lightbox-panel {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  width: min(96vw, 1280px);
  max-height: 94vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.iar-cc-lightbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.iar-cc-lightbox-toolbar .iar-cc-lightbox-scale-label {
  font-size: 0.875rem;
  color: #4b5563;
}

.iar-cc-lightbox-toolbar input[type="range"] {
  flex: 1;
  min-width: 120px;
  max-width: 28rem;
}

.iar-cc-lightbox-toolbar .iar-cc-lightbox-scale-value {
  font-size: 0.875rem;
  color: #1f2937;
  width: 3rem;
  flex-shrink: 0;
}

.iar-cc-lightbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.iar-cc-lightbox-actions button,
.iar-cc-lightbox-close {
  font-size: 12px;
  line-height: 1.25;
  padding: 0.35rem 0.65rem;
  border-radius: 0.375rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
}

.iar-cc-lightbox-actions button.is-active {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.iar-cc-lightbox-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.iar-cc-lightbox-close {
  background: #374151;
  border-color: #374151;
  color: #fff;
}

.iar-cc-lightbox-close:hover {
  background: #1f2937;
}

.iar-cc-lightbox-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #171717;
  padding: 1rem;
}

.iar-cc-lightbox-stage {
  display: flex;
  min-width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
}

.iar-cc-lightbox-stage .iar-cc-img-wrap.is-lightbox .iar-cc-img-toolbar {
  /* 放大预览里工具条改由顶部栏承载，避免与图片重叠 */
  display: none;
}

.iar-cc-lightbox-img {
  border-radius: 0.375rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  display: block;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}

.iar-cc-lightbox-footer {
  font-size: 0.75rem;
  color: #6b7280;
  padding: 0.5rem 0.75rem;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.iar-cc-ocr-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(75, 85, 99, 0.5);
}

.iar-cc-ocr-modal.is-open {
  display: flex;
}

.iar-cc-ocr-modal-panel {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
  width: min(560px, calc(100vw - 2rem));
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.iar-cc-ocr-modal-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
}

.iar-cc-ocr-modal-panel textarea {
  width: 100%;
  min-height: 180px;
  flex: 1;
  resize: vertical;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  box-sizing: border-box;
}

.iar-cc-ocr-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.iar-cc-ocr-modal-actions button {
  padding: 0.4rem 0.85rem;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  cursor: pointer;
}

.iar-cc-ocr-btn-copy {
  background: #3b82f6;
  color: #fff;
}

.iar-cc-ocr-btn-copy:hover { background: #2563eb; }

.iar-cc-ocr-btn-insert {
  background: #10b981;
  color: #fff;
}

.iar-cc-ocr-btn-insert:hover { background: #059669; }

.iar-cc-ocr-btn-close {
  background: #e5e7eb;
  color: #374151;
}

.iar-cc-ocr-btn-close:hover { background: #d1d5db; }
