/**
 * 文章外链库 - Notion 风格极简设计
 */

/* ===== 变量 ===== */
:root {
  --bg: #FFFFFF;
  --bg-secondary: #F7F7F5;
  --text: #37352F;
  --text-secondary: #787774;
  --text-placeholder: #BABAB8;
  --border: #E9E9E7;
  --border-light: #F0F0EE;
  --hover: #F7F7F5;
  --selected: #E7EFFB;
  --blue: #2383E2;
  --blue-light: #E7EFFB;
  --red: #EB5757;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

input, select, textarea {
  font-size: 16px !important;
}

/* ===== 头部 ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.tool-btn:hover {
  background: var(--hover);
}

.tool-btn:active {
  transform: scale(0.95);
}

.btn-add {
  padding: 6px 14px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add:hover {
  opacity: 0.85;
}

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

/* ===== 分类 Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab:hover {
  background: var(--bg-secondary);
}

.tab.active {
  background: var(--text);
  color: var(--bg);
}

/* ===== 搜索栏 ===== */
.search-bar {
  padding: 10px 20px;
  background: var(--bg);
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg-secondary);
  transition: all 0.15s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--bg);
}

/* ===== 已选择操作栏 ===== */
.selection-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--blue-light);
  border-bottom: 1px solid rgba(35, 131, 226, 0.2);
}

.selection-bar span {
  font-size: 13px;
  color: var(--blue);
}

.selection-bar span strong {
  font-weight: 600;
}

.selection-actions {
  display: flex;
  gap: 6px;
}

.selection-actions .action-btn {
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.selection-actions .action-btn:active {
  transform: scale(0.97);
}

.selection-actions .action-btn:hover {
  background: var(--hover);
}

.selection-actions .btn-del {
  color: var(--red);
}

.selection-actions .btn-del:active {
  background: #FEE;
}

/* ===== 文章列表 ===== */
.article-list {
  padding: 0 0 100px 0;
}

.article-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
  overflow: hidden;
}

.article-item:active {
  background: var(--hover);
}

.article-item.selected {
  background: var(--blue-light);
}

.article-checkbox {
  width: 18px;
  height: 18px;
  margin-right: 12px;
  accent-color: var(--blue);
  flex-shrink: 0;
}

.article-main {
  flex: 1;
  min-width: 0;
}

.article-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.article-title a {
  color: var(--text);
  text-decoration: none;
}

.article-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.article-category {
  color: var(--blue);
}

.article-actions {
  display: none;
  gap: 4px;
  margin-left: 12px;
}

.article-actions button {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.article-actions button:hover {
  background: var(--hover);
}

.article-actions .btn-del:hover {
  background: #FEE;
  border-color: var(--red);
  color: var(--red);
}

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

.empty-state p:first-child {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p:last-child {
  font-size: 14px;
}


/* ===== 底部抽屉 ===== */
.bottom-sheet {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}

.bottom-sheet.active {
  display: block;
}

.sheet-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
}

.sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.btn-save {
  padding: 6px 16px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-close {
  padding: 6px 12px;
  background: transparent;
  color: var(--blue);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== 表单 ===== */
#articleForm {
  padding: 20px;
}

.form-field {
  margin-bottom: 20px;
}

.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg);
  transition: all 0.15s;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--blue);
}

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

.url-row input {
  flex: 1;
}

.btn-fetch {
  padding: 0 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-fetch:hover {
  background: var(--hover);
  color: var(--text);
}

.form-actions {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-delete {
  width: 100%;
  padding: 12px;
  background: #FEE;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete:hover {
  background: #FDD;
}

/* ===== 分类管理抽屉 ===== */
.category-add {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.category-add input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.category-add button {
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}

.category-list {
  padding: 8px 16px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.category-info {
  flex: 1;
  min-width: 0;
}

.category-name {
  font-size: 14px;
  font-weight: 500;
}

.category-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.category-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}

.category-btns .move-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.category-btns .move-btn:active {
  transform: scale(0.95);
  background: var(--hover);
}

.category-btns .edit-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
}

.category-btns .edit-btn:active {
  background: var(--hover);
}

.category-btns .del-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  color: var(--red);
}

.category-btns .del-btn:active {
  background: #FEE;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--text);
  color: var(--bg);
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: #2EAADC;
}

.toast.error {
  background: var(--red);
}

/* ===== Modal (导入) ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 360px;
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-sm {
  max-width: 320px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 20px;
}

.import-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.radio-card {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.radio-card:hover {
  background: var(--hover);
}

.radio-card input {
  margin-right: 12px;
  accent-color: var(--blue);
}

.radio-title {
  font-size: 14px;
  font-weight: 500;
}

.radio-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-upload {
  margin-bottom: 16px;
}

.file-upload input {
  width: 100%;
  padding: 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-outline {
  background: var(--bg-secondary);
  color: var(--text);
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== 加载动画 ===== */
.fetching {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, #E8E8E6 50%, var(--bg-secondary) 75%) !important;
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  #app {
    max-width: 600px;
    margin: 0 auto;
  }

  .article-item:hover .article-actions {
    display: flex;
  }
}
