/* Inspire App - 样式文件 */

/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-secondary: #64748b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  /* iOS安全区适配 */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* 容器 */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 头部 */
.header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-primary);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-secondary);
  color: white;
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
}

/* 主内容区 */
.main {
  padding: 24px 0;
  min-height: calc(100vh - 64px);
}

/* 编辑器区域 */
.editor-section {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.editor-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-size: 16px; /* iOS要求>=16px避免自动缩放 */
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.editor-toolbar {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: all 0.2s;
  border: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}

.file-input-label:hover {
  background: var(--color-border);
}

.file-input {
  display: none;
}

/* 时间线 */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 条目卡片 */
.entry-card {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.entry-card:hover {
  box-shadow: var(--shadow-md);
}

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

.entry-date {
  font-size: 14px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.entry-actions {
  display: flex;
  gap: 8px;
}

.entry-content {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 标签 */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--color-primary);
  color: white;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

/* 媒体预览 */
.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.media-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-bg-secondary);
}

.media-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.media-item audio {
  width: 100%;
}

/* Loading状态 */
.loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 1000;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast通知 */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Modal对话框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

.modal-content {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 16px;
}

/* Markdown高亮 */
.entry-content code {
  background: var(--color-bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.entry-content pre {
  background: var(--color-bg-secondary);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.entry-content strong {
  font-weight: 600;
}

.entry-content em {
  font-style: italic;
}

.entry-content mark {
  background: #fef08a;
  padding: 2px 4px;
  border-radius: 2px;
}

/* 响应式设计 */
@media (max-width: 640px) {
  .container {
    padding: 0 12px;
  }

  .app-title {
    font-size: 18px;
  }

  .header-content {
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-tab {
    padding: 5px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .editor-section {
    padding: 12px;
  }

  .entry-card {
    padding: 12px;
  }

  .entry-actions {
    gap: 2px;
  }

  .icon-btn {
    padding: 4px;
    font-size: 14px;
  }

  .media-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .search-filters {
    flex-direction: column;
  }

  .filter-select, .filter-date {
    width: 100%;
  }
}

/* 工具提示 */
.tooltip {
  position: relative;
}

.tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--color-text);
  color: white;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  margin-bottom: 6px;
}

/* 视图切换 */
.view { display: none; }
.view.active { display: block; }

/* 导航标签 */
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}
.nav-tab:hover { background: var(--color-bg-secondary); }
.nav-tab.active { background: var(--color-primary); color: white; }

/* 搜索筛选 */
.search-section { margin-bottom: 16px; }
.search-filters {
  display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
}
.filter-select, .filter-date {
  padding: 8px 12px; border: 2px solid var(--color-border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
}
.filter-select:focus, .filter-date:focus {
  outline: none; border-color: var(--color-primary);
}

/* 日历 */
.calendar-section { background: var(--color-bg); border-radius: 12px; padding: 20px; box-shadow: var(--shadow-sm); }
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-title { font-size: 18px; font-weight: 600; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 8px; }
.calendar-weekday { font-size: 12px; color: var(--color-text-secondary); padding: 4px; }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; border-radius: 8px; cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.calendar-day:hover { background: var(--color-bg-secondary); }
.calendar-day.empty { cursor: default; }
.calendar-day.today { background: var(--color-primary); color: white; font-weight: 700; }
.calendar-day.has-entries { font-weight: 600; }
.calendar-day.has-entries:not(.today) { background: #dbeafe; color: var(--color-primary); }
.day-number { font-size: 14px; }
.day-count { font-size: 10px; opacity: 0.7; }

/* 评论弹窗 */
.modal-large { max-width: 600px; width: 95%; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; }
.comments-list { margin-bottom: 16px; }
.comment-item {
  padding: 12px; border-left: 3px solid var(--color-primary);
  margin-bottom: 8px; background: var(--color-bg-secondary); border-radius: 0 8px 8px 0; position: relative;
}
.comment-time { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 4px; }
.comment-content { font-size: 14px; line-height: 1.6; }
.comment-delete { position: absolute; top: 8px; right: 8px; font-size: 12px; }
.comment-input-area { border-top: 1px solid var(--color-border); padding-top: 12px; }

/* 收藏/置顶 */
.starred { color: #f59e0b !important; }
.edited-badge { font-size: 11px; color: var(--color-text-secondary); margin-left: 6px; background: var(--color-bg-secondary); padding: 2px 6px; border-radius: 4px; }
.pin-badge { font-size: 11px; color: var(--color-primary); margin-left: 6px; }
.entry-card.pinned { border-left: 3px solid var(--color-primary); }

/* 标签云 */
.tag-cloud { margin-bottom: 16px; }
.section-title { font-size: 16px; color: var(--color-text-secondary); margin-bottom: 8px; }

/* 回顾 */
.flashback-section {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
.flashback-section .section-title { color: #92400e; }

/* 关联 */
.linked-entries { margin-top: 8px; }
.link-label { font-size: 12px; color: var(--color-primary); }

/* 导出 */
.export-section { background: var(--color-bg); border-radius: 12px; padding: 20px; box-shadow: var(--shadow-sm); }

/* Markdown工具栏 */
.md-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.md-btn {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0 6px;
}

.md-btn:hover, .md-btn:active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* 写作分区列表 */
.writer-list-section {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* 内联搜索 */
.search-inline {
  margin-bottom: 16px;
  position: relative;
}

.search-inline-row {
  display: flex;
  gap: 8px;
}

.search-inline-input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--color-bg);
}

.search-inline-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.search-inline-select {
  padding: 8px 12px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-bg);
  max-width: 120px;
}

#search-results-inline {
  background: var(--color-bg);
  border-radius: 12px;
  margin-top: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 60vh;
  overflow-y: auto;
}

.search-results-header {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.search-group-title {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-bg-secondary);
}

.search-result-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.15s;
}

.search-result-item:hover {
  background: var(--color-bg-secondary);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.search-result-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.search-result-snippet {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.tag-mini {
  font-size: 11px;
  color: var(--color-primary);
  background: #dbeafe;
  padding: 1px 6px;
  border-radius: 4px;
}

/* 内联关联灵感 */
.inline-comments {
  margin-top: 4px;
}

.inline-comment {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-top: 6px;
}

.inline-comment-line {
  width: 2px;
  min-height: 100%;
  background: var(--color-primary);
  border-radius: 1px;
  margin-right: 10px;
  flex-shrink: 0;
  align-self: stretch;
}

.inline-comment-body {
  flex: 1;
  padding: 6px 10px;
  background: var(--color-bg-secondary);
  border-radius: 8px;
  position: relative;
  min-width: 0;
}

.inline-comment-time {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-right: 8px;
}

.inline-comment-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
}

.inline-comment-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.inline-comment-body:hover .inline-comment-delete {
  opacity: 1;
}

/* 添加关联灵感输入 */
.add-comment-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.add-comment-input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.add-comment-input:focus {
  border-color: var(--color-primary);
}

.add-comment-input::placeholder {
  color: #c0c0c0;
}

.add-comment-btn {
  padding: 6px 14px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.add-comment-btn:hover {
  background: var(--color-primary-dark);
}

/* 日期旁的内联标签 */
.tag-inline {
  font-size: 12px;
  color: var(--color-primary);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  margin-left: 4px;
  transition: background 0.15s;
}

.tag-inline:hover {
  background: #dbeafe;
}

/* 收藏筛选按钮 */
.star-filter-btn {
  padding: 8px 12px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.star-filter-btn:hover, .star-filter-btn.active {
  border-color: #f59e0b;
  background: #fef3c7;
}

/* 类型筛选栏 */
.category-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.cat-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-bg);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cat-btn:hover { border-color: var(--cat-color, var(--color-primary)); }
.cat-btn.active {
  background: var(--cat-color, var(--color-primary));
  color: white;
  border-color: var(--cat-color, var(--color-primary));
}

.cat-add-btn { border-style: dashed; color: var(--color-text-secondary); }
.cat-add-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* 类型徽章 */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

/* 编辑器顶部行 */
.editor-top-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.editor-category-select {
  padding: 6px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-bg);
  flex-shrink: 0;
}

.editor-title-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  background: transparent;
  min-width: 0;
}

.editor-title-input::placeholder {
  color: #c0c0c0;
  font-weight: 400;
}

/* 条目标题 */
.entry-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.4;
}

/* RGB颜色选择器 */
.color-custom-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.color-custom-label input[type="color"] {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

/* 条目元信息行 */
.entry-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* 内联编辑 */
.inline-edit-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

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

.inline-edit-actions .btn {
  padding: 6px 16px;
  font-size: 13px;
}

/* 颜色选择器 */
.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s;
}

.color-dot.selected, .color-dot:hover {
  border-color: var(--color-text);
}

/* 日历日期详情头部 */
.day-view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.day-view-header .btn {
  font-size: 13px;
  padding: 6px 14px;
}

/* 隐藏类 */
.hidden {
  display: none !important;
}

/* 图标按钮 */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  color: var(--color-text-secondary);
  transition: all 0.2s;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover, .icon-btn:active {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

/* 搜索栏 */
.search-bar {
  width: 100%;
  padding: 10px 16px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.search-bar:focus {
  outline: none;
  border-color: var(--color-primary);
}
