/* ============================================================
 * 灵音托管引擎自动化工作台 - 便签组件样式 (comp-quick-note.css)
 * 功能升级版：搜索 + 彩色卡片 + 置顶 + 标签 + FAB + 编辑弹窗
 * 适配 PC 端 + 手机端双端
 * ============================================================ */

/* ===== 变量覆盖（可选，供外部覆盖） ===== */
:root {
  --qn-fab-size: 52px;
  --qn-fab-bottom: 24px;
  --qn-fab-right: 24px;
  --qn-card-max-width: 560px;
}

/* ===== 便签容器 ===== */
.quick-note-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary, #0f1d36);
  overflow: visible;
}

/* ===== 顶部标题栏 ===== */
.qn-header {
  display: flex;
  align-items: center;
  padding: 10px 14px 8px;
  background: var(--bg-secondary, #0f1d36);
  border-bottom: 1px solid var(--border-color, #1e3a5f);
  flex-shrink: 0;
  gap: 8px;
}

.qn-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #e0e8f5);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== 搜索框 ===== */
.qn-search-wrap {
  flex: 1;
  position: relative;
}

.qn-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px 6px 30px;
  border: 1px solid var(--border-color, #1e3a5f);
  border-radius: 8px;
  background: var(--bg-card, #152244);
  color: var(--text-primary, #e0e8f5);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.qn-search-input:focus {
  border-color: var(--color-primary, #3b82f6);
}

.qn-search-input::placeholder {
  color: var(--text-muted, #5a7a9e);
}

.qn-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted, #5a7a9e);
  font-size: 12px;
  pointer-events: none;
}

.qn-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted, #5a7a9e);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.2s;
}

.qn-search-clear:hover {
  color: var(--text-primary, #e0e8f5);
}

/* ===== 便签列表 ===== */
.qn-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 80px; /* 底部留 FAB 空间 */
}

.qn-list::-webkit-scrollbar {
  width: 3px;
}

.qn-list::-webkit-scrollbar-thumb {
  background: var(--bg-hover, #1a2d52);
  border-radius: 3px;
}

/* ===== 便签卡片 ===== */
.qn-card {
  position: relative;
  background: var(--bg-card, #152244);
  border-radius: 10px;
  border: 1px solid var(--border-color, #1e3a5f);
  padding: 10px 12px 10px 16px; /* 左侧给颜色条留空 */
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  overflow: visible;
  min-height: 60px;
}

.qn-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 10px 0 0 10px;
  background: var(--card-accent, #4ecdc4);
  transition: width 0.2s;
}

.qn-card:hover {
  background: var(--bg-hover, #1a2d52);
  border-color: var(--card-accent, #4ecdc4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.qn-card:hover::before {
  width: 5px;
}

/* 置顶卡片 */
.qn-card.is-pinned {
  border-color: rgba(245, 158, 11, 0.3);
  background: var(--bg-card, #152244);
}

.qn-card.is-pinned::before {
  background: #f59e0b;
}

/* 卡片顶部行：置顶标签 + 标题 + 删除 */
.qn-card-top {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 4px;
}

.qn-pin-badge {
  font-size: 10px;
  color: #f59e0b;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}

.qn-card-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #e0e8f5);
  line-height: 1.4;
  word-break: break-word;
  overflow: visible;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.qn-card-title.no-title {
  color: var(--text-muted, #5a7a9e);
  font-weight: 400;
}

.qn-card-delete {
  background: none;
  border: none;
  color: var(--text-muted, #5a7a9e);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  flex-shrink: 0;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}

.qn-card-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* 卡片内容 */
.qn-card-content {
  font-size: 12px;
  color: var(--text-secondary, #a8bdd8);
  line-height: 1.5;
  word-break: break-word;
  overflow: visible;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
}

.qn-card-content.no-content {
  color: var(--text-muted, #5a7a9e);
  font-style: italic;
}

/* 卡片底部：标签 + 时间 */
.qn-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

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

.qn-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  color: var(--text-muted, #5a7a9e);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  white-space: nowrap;
  max-width: 80px;
  overflow: visible;
  text-overflow: ellipsis;
}

.qn-card-time {
  font-size: 10px;
  color: var(--text-muted, #5a7a9e);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== 空状态 ===== */
.qn-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted, #5a7a9e);
}

.qn-empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.qn-empty-text {
  font-size: 13px;
  line-height: 1.6;
}

.qn-empty-text strong {
  color: var(--text-secondary, #a8bdd8);
  font-weight: 500;
}

/* ===== FAB 新建按钮 ===== */
.qn-fab {
  z-index: 999;
  position: absolute;
  bottom: var(--qn-fab-bottom, 24px);
  right: var(--qn-fab-right, 24px);
  width: var(--qn-fab-size, 52px);
  height: var(--qn-fab-size, 52px);
  border-radius: 50%;
  background: var(--color-primary, #3b82f6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.45);
  transition: all 0.2s;
  z-index: 50;
  line-height: 1;
}

.qn-fab:hover {
  background: #2563eb;
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.qn-fab:active {
  transform: scale(0.95);
}

/* ===== 编辑弹窗 ===== */
.qn-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
  animation: qn-fade-in 0.2s ease;
}

@keyframes qn-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qn-modal {
  background: var(--bg-secondary, #0f1d36);
  border: 1px solid var(--border-color, #1e3a5f);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: qn-slide-up 0.25s ease;
  overflow: visible;
}

@keyframes qn-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 弹窗头部 */
.qn-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color, #1e3a5f);
  flex-shrink: 0;
}

.qn-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #e0e8f5);
}

.qn-modal-close {
  background: none;
  border: none;
  color: var(--text-muted, #5a7a9e);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
  line-height: 1;
}

.qn-modal-close:hover {
  color: var(--text-primary, #e0e8f5);
  background: var(--bg-hover, #1a2d52);
}

/* 弹窗内容 */
.qn-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qn-modal-body::-webkit-scrollbar {
  width: 3px;
}

.qn-modal-body::-webkit-scrollbar-thumb {
  background: var(--bg-hover, #1a2d52);
  border-radius: 3px;
}

/* 表单字段 */
.qn-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qn-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #a8bdd8);
  letter-spacing: 0.5px;
}

/* 标题输入 */
.qn-title-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #1e3a5f);
  border-radius: 8px;
  background: var(--bg-card, #152244);
  color: var(--text-primary, #e0e8f5);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.qn-title-input:focus {
  border-color: var(--color-primary, #3b82f6);
}

.qn-title-input::placeholder {
  color: var(--text-muted, #5a7a9e);
}

/* 内容输入 */
.qn-content-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #1e3a5f);
  border-radius: 8px;
  background: var(--bg-card, #152244);
  color: var(--text-primary, #e0e8f5);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: border-color 0.2s;
}

.qn-content-textarea:focus {
  border-color: var(--color-primary, #3b82f6);
}

.qn-content-textarea::placeholder {
  color: var(--text-muted, #5a7a9e);
}

/* 标签输入 */
.qn-tag-input-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border-color, #1e3a5f);
  border-radius: 8px;
  background: var(--bg-card, #152244);
  min-height: 38px;
  cursor: text;
  transition: border-color 0.2s;
}

.qn-tag-input-wrap:focus-within {
  border-color: var(--color-primary, #3b82f6);
}

.qn-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--color-primary, #3b82f6);
  white-space: nowrap;
}

.qn-tag-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.qn-tag-chip-remove:hover {
  opacity: 1;
}

.qn-tag-input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary, #e0e8f5);
  font-size: 12px;
  font-family: inherit;
  min-width: 80px;
  flex: 1;
}

.qn-tag-input::placeholder {
  color: var(--text-muted, #5a7a9e);
}

/* 颜色选择器 */
.qn-color-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.qn-color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  flex-shrink: 0;
}

.qn-color-dot:hover {
  transform: scale(1.2);
}

.qn-color-dot.active {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

/* 置顶开关行 */
.qn-pin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.qn-pin-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.qn-pin-toggle input {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.qn-pin-slider {
  position: absolute;
  inset: 0;
  background: var(--border-color, #1e3a5f);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.3s;
}

.qn-pin-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}

.qn-pin-toggle input:checked + .qn-pin-slider {
  background: #f59e0b;
}

.qn-pin-toggle input:checked + .qn-pin-slider::before {
  transform: translateX(16px);
}

.qn-pin-label {
  font-size: 13px;
  color: var(--text-secondary, #a8bdd8);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 弹窗底部按钮 */
.qn-modal-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border-color, #1e3a5f);
  flex-shrink: 0;
}

.qn-btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1;
}

.qn-btn-cancel {
  background: transparent;
  border: 1px solid var(--border-color, #1e3a5f);
  color: var(--text-secondary, #a8bdd8);
}

.qn-btn-cancel:hover {
  color: var(--text-primary, #e0e8f5);
  border-color: var(--text-muted, #5a7a9e);
}

.qn-btn-save {
  background: var(--color-primary, #3b82f6);
  border: 1px solid var(--color-primary, #3b82f6);
  color: #fff;
}

.qn-btn-save:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.qn-btn-save:active {
  transform: scale(0.97);
}

/* ===== PC 端：居中限制宽度 ===== */
@media (min-width: 769px) {
  .quick-note-container {
    max-width: var(--qn-card-max-width, 560px);
    margin: 0 auto;
  }

  .qn-fab {
  z-index: 999;
    right: var(--qn-fab-right, 24px);
  }
}

/* ===== 手机端适配 ===== */
@media (max-width: 768px) {
  .qn-header {
    padding: 8px 10px 6px;
  }

  .qn-header-title {
    font-size: 14px;
  }

  .qn-search-input {
    font-size: 13px;
    padding: 6px 30px 6px 28px;
  }

  .qn-list {
    padding: 8px 8px 90px;
  }

  .qn-card {
    padding: 9px 10px 9px 14px;
    margin-bottom: 7px;
    border-radius: 8px;
  }

  .qn-card::before {
    width: 3px;
    border-radius: 8px 0 0 8px;
  }

  .qn-card-title {
    font-size: 13px;
  }

  .qn-card-content {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .qn-card-footer {
    flex-wrap: wrap;
  }

  /* 手机端 FAB 更大更好点 */
  .qn-fab {
  z-index: 999;
    --qn-fab-size: 56px;
    --qn-fab-bottom: 20px;
    --qn-fab-right: 20px;
    bottom: var(--qn-fab-bottom, 20px);
    right: var(--qn-fab-right, 20px);
    font-size: 24px;
  }

  /* 手机端弹窗占满宽 */
  .qn-modal {
    border-radius: 14px 14px 0 0;
    max-height: 90vh;
    max-width: 100%;
    margin-top: auto;
  }

  .qn-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .qn-modal-body {
    padding: 14px 14px 10px;
    gap: 12px;
  }

  .qn-modal-foot {
    padding: 10px 14px 14px;
  }

  .qn-btn {
    padding: 11px 0;
    font-size: 14px;
  }
}

/* ===== 搜索高亮（动态class） ===== */
.qn-highlight {
  background: rgba(245, 158, 11, 0.25);
  border-radius: 2px;
  color: #f59e0b;
}
