/* ===============================
   SCREENPLAY NOTES — PANEL & POPOVER
   Dual-layer notes system for the screenplay section.
   =============================== */

/* ===============================
   NOTES PANEL (Right-side slide panel)
   =============================== */

.screenplay-notes-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.screenplay-notes-wrapper .screenplay-canvas {
  flex: 1;
  min-width: 0;
  min-height: 0;
  transition: flex 0.25s ease;
}

.notes-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, min-width 0.25s ease;
  opacity: 0;
}

.notes-panel.notes-panel-open {
  width: 320px;
  min-width: 320px;
  opacity: 1;
  transition: width 0.25s ease, min-width 0.25s ease, opacity 0.15s ease 0.1s;
}

/* Panel Header */
.notes-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notes-panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.notes-panel-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 6px;
}

.notes-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.notes-panel-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.notes-panel-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Panel Filter Bar */
.notes-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.notes-filter-select {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 24px 4px 8px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23b5b5b5' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.notes-filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.notes-filter-tag-active {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.notes-filter-tag-active:hover {
  opacity: 0.8;
}

.notes-filter-clear {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s ease;
}

.notes-filter-clear:hover {
  color: var(--text-primary);
}

/* Panel Content */
.notes-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.notes-panel-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.notes-panel-empty svg {
  display: block;
  margin: 0 auto 12px;
  opacity: 0.3;
}

/* New Note Compose Area */
.notes-compose {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
}

.notes-compose-excerpt {
  font-size: 11px;
  color: var(--accent);
  background: rgba(209, 139, 60, 0.08);
  border-left: 2px solid var(--accent);
  padding: 4px 8px;
  margin-bottom: 8px;
  border-radius: 0 3px 3px 0;
  max-height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-family: "Courier Prime", "Courier New", Courier, monospace;
}

.notes-compose-textarea {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-ui);
  line-height: 1.45;
  resize: vertical;
}

.notes-compose-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.notes-compose-textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.notes-compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.notes-compose-tags {
  flex: 1;
  min-width: 0;
}

/* Compact tag input for compose area */
.notes-compose .tag-input-container {
  min-height: 28px;
  padding: 3px 6px;
  font-size: 11px;
}

.notes-compose .tag-text-input {
  font-size: 11px !important;
  min-width: 60px !important;
}

.notes-compose .tag-pill {
  font-size: 10px;
  padding: 1px 5px;
}

.notes-compose-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.notes-compose-actions .btn {
  font-size: 11px;
  padding: 4px 10px;
}

/* ===============================
   NOTE CARD (Used in both panel and popover)
   =============================== */

.note-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px;
  margin-bottom: 8px;
  transition: border-color 0.15s ease;
}

.note-card:hover {
  border-color: var(--accent-muted);
}

.note-card-resolved {
  opacity: 0.5;
}

.note-card-resolved:hover {
  opacity: 0.75;
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.note-card-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.note-card-time {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.note-card-excerpt {
  font-size: 11px;
  color: var(--accent);
  background: rgba(209, 139, 60, 0.06);
  border-left: 2px solid var(--accent-muted);
  padding: 2px 6px;
  margin-bottom: 6px;
  border-radius: 0 2px 2px 0;
  font-family: "Courier Prime", "Courier New", Courier, monospace;
  max-height: 32px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.note-card-body {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 6px;
}

.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.note-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.note-tag:hover {
  opacity: 0.8;
}

.note-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.note-card:hover .note-card-actions {
  opacity: 1;
}

.note-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  border-radius: 3px;
  transition: color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.note-action-btn.note-resolve-btn:hover {
  color: #2ecc71;
}

.note-action-btn.note-delete-btn:hover {
  color: #e74c3c;
}

.note-action-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Scene group headers */
.notes-scene-group {
  margin-bottom: 4px;
}

.notes-scene-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  padding: 6px 4px 4px;
  opacity: 0.7;
}

/* Resolved fold (matches task completed fold) */
.notes-resolved-fold {
  margin-top: 4px;
}

.notes-resolved-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.notes-resolved-toggle:hover {
  color: var(--text-primary);
}

.notes-resolved-arrow {
  font-size: 10px;
}

/* ===============================
   SELECTION TOOLBAR
   Compact floating toolbar on text highlight, future-proofed for formatting tools
   =============================== */

.sp-selection-toolbar {
  position: fixed;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-panel, #242428);
  border: 1px solid var(--border, #4b4b50);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.sp-toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.sp-toolbar-btn svg {
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

.sp-toolbar-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

/* Separator for future toolbar items */
.sp-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border, #4b4b50);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ===============================
   NOTE POPOVER (Marker click — shows note details)
   Mirrors .ls-shot-popover styling
   =============================== */

.sp-note-popover {
  position: fixed;
  z-index: 20;
  width: 260px;
  background: var(--bg-panel, #242428);
  border: 1px solid var(--border, #4b4b50);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.sp-note-popover-body {
  padding: 10px;
}

.sp-note-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 7px;
  margin-bottom: 7px;
  border-bottom: 1px solid var(--border, #4b4b50);
}

.sp-note-popover-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent, #d18b3c);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sp-note-popover-count {
  font-size: 10px;
  color: var(--text-secondary);
}

/* Compact note preview in popover */
.sp-note-popover-item {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sp-note-popover-item:last-child {
  border-bottom: none;
}

.sp-note-popover-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.sp-note-popover-item-author {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
}

.sp-note-popover-item-time {
  font-size: 9px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.sp-note-popover-item-body {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-secondary, #aaa);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sp-note-popover-item-excerpt {
  font-size: 10px;
  color: var(--accent);
  font-family: "Courier Prime", "Courier New", Courier, monospace;
  margin-bottom: 3px;
  opacity: 0.7;
  max-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-note-popover-item-resolved {
  opacity: 0.45;
}

.sp-note-popover-item-tags {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.sp-note-popover-more {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  padding: 4px 0 2px;
  opacity: 0.6;
}

/* Popover actions */
.sp-note-popover-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border, #4b4b50);
}

.sp-note-popover-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.sp-note-popover-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-muted);
}

.sp-note-popover-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===============================
   NOTE INDICATOR MARKERS
   Small dots in the screenplay margin to show where notes exist
   =============================== */

.sp-note-marker {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
  pointer-events: auto;
}

.sp-note-marker:hover {
  opacity: 1;
  transform: scale(1.3);
}

.sp-note-marker-multiple {
  box-shadow: 2px 2px 0 0 var(--accent-muted);
}

/* Toggle button active state */
.notes-toggle-btn.notes-active {
  color: var(--accent) !important;
  background: rgba(209, 139, 60, 0.12) !important;
}

/* Note count badge on toggle button */
.notes-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* Inline note edit within card */
.note-edit-textarea {
  width: 100%;
  min-height: 48px;
  max-height: 100px;
  padding: 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-ui);
  line-height: 1.45;
  resize: vertical;
}

.note-edit-textarea:focus {
  outline: none;
}

.note-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.note-edit-actions .btn {
  font-size: 11px;
  padding: 3px 10px;
}

/* Visibility icon */
.note-visibility-icon {
  display: inline-flex;
  margin-left: 4px;
  opacity: 0.5;
}

.note-visibility-icon svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ===============================
   PRINT — hide notes UI
   =============================== */

@media print {
  .notes-panel,
  .sp-note-popover,
  .sp-selection-toolbar,
  .sp-note-marker,
  .notes-toggle-btn,
  .notes-badge {
    display: none !important;
  }
}
