/* ============================================================
   style_addon.css — 팝업 편집기 + 인라인 멘션 추가 스타일
   기존 style.css 맨 아래에 붙여넣기
   v2.0 2024-03
   ============================================================ */

/* ── 확장 가능한 textarea 래퍼 ──────────────────────────── */
.expandable-textarea-wrap {
  position: relative;
}

.expandable-textarea-wrap textarea {
  width: 100%;
  resize: none;
  cursor: pointer !important;
  transition: border-color 0.2s;
  padding-right: 32px;
}

.expandable-textarea-wrap textarea.agenda-content-preview {
  min-height: 140px;
}

.expandable-textarea-wrap textarea:hover {
  border-color: var(--accent);
}

.btn-expand {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--accent-dim);
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.expandable-textarea-wrap:hover .btn-expand {
  opacity: 1;
}

/* ── 확장 힌트 텍스트 ────────────────────────────────────── */
.expand-hint {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 4px;
}

/* ── 인라인 멘션 드롭다운 ────────────────────────────────── */
.mention-editor-wrap {
  position: relative;
  overflow: visible;
}

#mentionResultsPanel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: block;
  max-height: 200px;
  margin-top: 4px;
  z-index: 10001;
  background: #ffffff;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  overflow-y: auto;
}

#textEditModal .modal-content,
#textEditModal .modal-body {
  overflow: visible;
}

#mentionResultsPanel.hidden {
  display: none !important;
}

#mentionResultsPanel .dropdown-item {
  display: block;
  min-height: 44px;
  padding: 10px 12px;
  background: #ffffff;
  color: #111827;
  border-bottom: 1px solid #f3f4f6;
}

#mentionResultsPanel .dropdown-item:last-child {
  border-bottom: none;
}

#mentionResultsPanel .dropdown-item:hover {
  background: #fff7ed;
}

#mentionResultsPanel .dropdown-name {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
}

#mentionResultsPanel .dropdown-meta {
  display: block;
  margin-top: 2px;
  color: #6b7280;
  font-size: 11px;
}

/* ── 팝업 텍스트 에디터 textarea ────────────────────────── */
#textEditArea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  line-height: 1.8;
  resize: vertical;
  min-height: 200px;
  transition: border-color 0.2s;
}

#textEditArea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── readonly textarea 스타일 (클릭 유도) ───────────────── */
.expandable-textarea-wrap textarea[readonly] {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.expandable-textarea-wrap textarea[readonly]:empty::before {
  content: attr(placeholder);
  color: var(--text-secondary);
}

.mention-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

#textEditModal .text-edit-modal-content {
  width: min(1600px, 96vw);
  max-width: min(1600px, 96vw);
  max-height: 92vh;
}

.mention-editor-main {
  min-width: 0;
}

.mention-side-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffaf0;
  padding: 12px;
  transition: max-height 0.2s ease, opacity 0.2s ease;
}

.mention-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.mention-side-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mention-toggle-btn {
  display: none;
  border: 1px solid #fdba74;
  background: #fff;
  color: #9a3412;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.mention-query-label {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.mention-results-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
}

#mentionResultsPanel.mention-results-panel {
  position: static;
  left: auto;
  right: auto;
  top: auto;
  margin-top: 0;
  display: flex;
  max-height: 320px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  overflow-y: auto;
}

.mention-empty {
  padding: 14px 12px;
  border: 1px dashed #fdba74;
  border-radius: 12px;
  background: #fff;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.6;
}

.mention-result-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  background: #fff !important;
  color: #111827 !important;
  cursor: pointer;
}

.mention-result-item:hover,
.mention-result-item.is-active {
  background: #fff7ed;
  border-color: #fb923c;
}

.mention-result-name {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
}

.mention-result-meta {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 11px;
}

.mention-rich-editor {
  min-height: 420px;
  max-height: 68vh;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.mention-rich-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.agenda-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface);
  margin-top: 12px;
}

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

.agenda-card-title,
.agenda-card-header strong {
  font-size: 14px;
}

.mention-chip {
  display: inline !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  color: #1d4ed8 !important;
  font-weight: inherit !important;
  font-size: inherit !important;
  font-family: inherit !important;
  line-height: inherit !important;
  vertical-align: baseline !important;
  text-decoration: underline !important;
  text-underline-offset: 2px;
}

@media (max-width: 900px) {
  #textEditModal {
    padding: 0;
    align-items: stretch;
  }

  #textEditModal .modal-content {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
  }

  #textEditModal .modal-header {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-card);
  }

  #textEditModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 96px;
  }

  #textEditModal .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--bg-card);
    padding-top: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
  }

  .mention-editor-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mention-side-panel {
    order: 2;
    max-height: none;
    overflow: hidden;
  }

  .mention-side-panel.is-collapsed .mention-results-panel {
    display: none !important;
  }

  .mention-side-panel.is-collapsed {
    padding-bottom: 10px;
  }

  .mention-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mention-rich-editor {
    min-height: 240px;
    max-height: none;
  }

  .mention-results-panel {
    min-height: 0;
    max-height: min(220px, 28dvh);
  }

  .mention-empty {
    padding: 10px 12px;
  }

  .agenda-card {
    padding: 14px;
  }

  .agenda-card-header {
    align-items: flex-start;
  }

  .agenda-card-header .btn-secondary {
    flex: 0 0 auto;
  }
}
