/**
 * Long Text / Expandable Textarea Styles
 * Airtable-style inline expandable text editor for table cells
 */

/* ========================================
   LONG TEXT CELL (Table View)
   ======================================== */

/* Cell display - shows preview */
.dv-longtext-cell {
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  min-height: 1.5em;
  max-width: 100%;
  line-height: 1.4;
}

.dv-longtext-cell:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.2);
}

.dv-longtext-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--content-text, #1f2937);
}

/* Placeholder when empty */
.dv-longtext-preview.dv-longtext-empty {
  color: var(--content-text-secondary, #9ca3af);
  font-style: italic;
}

/* ========================================
   INLINE EXPANDED EDITOR
   Grows in place like Airtable
   ======================================== */

/* Container for the expanded editor - positioned absolutely to overlay */
.dv-longtext-inline-wrapper {
  position: absolute;
  z-index: 100;
  min-width: 250px;
  max-width: 400px;
  background: var(--content-bg, white);
  border: 2px solid var(--primary-color, #667eea);
  border-radius: 6px;
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(102, 126, 234, 0.1);
  animation: dv-longtext-expand 0.15s ease-out;
}

@keyframes dv-longtext-expand {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* The textarea itself */
.dv-longtext-inline-textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  max-height: 300px;
  padding: 0.5rem 0.625rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--content-text, #1f2937);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  overflow-y: auto;
}

.dv-longtext-inline-textarea:focus {
  outline: none;
}

.dv-longtext-inline-textarea::placeholder {
  color: var(--content-text-secondary, #9ca3af);
}

/* Footer hint */
.dv-longtext-inline-hint {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.25rem 0.5rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: var(--hover-bg, #f9fafb);
  border-radius: 0 0 4px 4px;
  font-size: 0.6875rem;
  color: var(--content-text-secondary, #9ca3af);
  gap: 0.25rem;
}

.dv-longtext-inline-hint kbd {
  display: inline-block;
  padding: 0.0625rem 0.25rem;
  font-size: 0.625rem;
  font-family: inherit;
  background: var(--content-bg, white);
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--border-color, #d1d5db);
}

/* ========================================
   DARK MODE
   ======================================== */

[data-theme="dark"] .dv-longtext-cell:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .dv-longtext-inline-wrapper {
  background: var(--content-bg, #1f2937);
  border-color: var(--primary-color, #667eea);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .dv-longtext-inline-textarea {
  color: var(--content-text, #f9fafb);
}

[data-theme="dark"] .dv-longtext-inline-hint {
  background: var(--hover-bg, #252542);
  border-color: var(--border-color, #374151);
}

[data-theme="dark"] .dv-longtext-inline-hint kbd {
  background: var(--content-bg, #1f2937);
  border-color: var(--border-color, #4b5563);
  box-shadow: 0 1px 0 var(--border-color, #4b5563);
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 640px) {
  .dv-longtext-inline-wrapper {
    min-width: 200px;
    max-width: calc(100vw - 2rem);
  }

  .dv-longtext-inline-textarea {
    min-height: 80px;
  }
}

/* ========================================
   MENTIONS ENABLED LONGTEXT
   ======================================== */

/* Cell with mentions enabled */
.dv-longtext-cell.dv-longtext-mentions .dv-longtext-preview {
  /* Mentions parsed inline */
}

.dv-longtext-cell.dv-longtext-mentions .mention-tag {
  font-size: 12px;
  padding: 1px 4px;
}

/* Wrapper with mentions */
.dv-longtext-inline-wrapper.dv-longtext-with-mentions {
  min-width: 300px;
  max-width: 500px;
}

/* MentionInput inside longtext wrapper */
.dv-longtext-mention-input {
  width: 100%;
}

.dv-longtext-mention-input .mention-input-wrapper {
  width: 100%;
}

.dv-longtext-mention-input .mention-editor {
  min-height: 100px;
  max-height: 300px;
  padding: 0.5rem 0.625rem;
  border: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  font-size: 0.8125rem;
  line-height: 1.5;
  overflow-y: auto;
}

.dv-longtext-mention-input .mention-editor:focus {
  outline: none;
  box-shadow: none;
}

/* Dropdown positioning within longtext editor */
.dv-longtext-mention-input .mention-dropdown {
  position: fixed;
  max-height: 200px;
  z-index: 1001;
}

/* Adjust hint when mentions are enabled */
.dv-longtext-with-mentions .dv-longtext-inline-hint {
  justify-content: space-between;
}

.dv-longtext-with-mentions .dv-longtext-inline-hint::before {
  content: '@ to mention';
  font-size: 0.625rem;
  color: var(--text-muted, #9ca3af);
}
