/* ============================================================
   AI PDF Exporter - Content Script Styles
   平台无关，所有 UI 组件样式
   ============================================================ */

/* ---- PDF 导出按钮 ---- */
/* 与 ChatGPT 原生按钮 class 保持一致：text-token-text-secondary hover:bg-token-bg-secondary rounded-lg */
.pdf-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;        /* 与原生 w-8 = 2rem = 32px 一致 */
  height: 32px;       /* 与原生 h-8 一致 */
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px; /* rounded-lg */
  color: var(--token-text-secondary, #8e8ea0);
  transition: color 0.15s ease, background-color 0.15s ease;
  padding: 0;
  flex-shrink: 0;
  position: relative;
  /* 继承父级 pointer-events，不单独设置，避免被父级 mask 遮住 */
}

.pdf-export-btn:hover {
  background-color: var(--token-bg-secondary, rgba(0,0,0,0.06));
}

.pdf-export-btn svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* Tooltip: 改用原生 title 属性，无需自定义样式 */

/* ---- 遮罩层 ---- */
#pdf-panel-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999998;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#pdf-panel-overlay.visible {
  display: block;
  opacity: 1;
}

/* ---- 侧边抽屉面板 ---- */
#pdf-export-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
}

#pdf-export-panel.open {
  right: 0;
}

/* ---- 面板 Header ---- */
.pdf-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.pdf-panel-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.pdf-panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  color: #6b7280;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
  padding: 0;
}

.pdf-panel-close:hover {
  background-color: #f3f4f6;
  color: #111827;
}

/* ---- 全选控制栏 ---- */
.pdf-select-all-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.pdf-select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  user-select: none;
}

.pdf-select-all-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2563eb;
}

.pdf-select-count {
  font-size: 12px;
  color: #6b7280;
}

/* ---- 消息列表 ---- */
.pdf-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.pdf-message-list::-webkit-scrollbar {
  width: 4px;
}

.pdf-message-list::-webkit-scrollbar-track {
  background: transparent;
}

.pdf-message-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

/* ---- 消息卡片 ---- */
.pdf-msg-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  border-left: 3px solid transparent;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}

.pdf-msg-card.selected {
  border-left-color: #2563eb;
  background: #eff6ff;
}

.pdf-msg-card.unselected {
  opacity: 0.5;
  background: #f9fafb;
}

.pdf-msg-card:hover {
  border-color: #93c5fd;
}

/* 角色头像 */
.pdf-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
  margin-top: 1px;
}

.pdf-msg-avatar.user {
  background: #2563eb;
}

.pdf-msg-avatar.assistant {
  background: #16a34a;
}

/* 消息内容区 */
.pdf-msg-body {
  flex: 1;
  min-width: 0;
}

.pdf-msg-preview {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.pdf-msg-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.pdf-msg-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #e5e7eb;
  color: #6b7280;
  font-weight: 500;
}

.pdf-msg-tag.code {
  background: #fef3c7;
  color: #92400e;
}

/* 勾选框 */
.pdf-msg-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2563eb;
  flex-shrink: 0;
  margin-top: 4px;
}

/* ---- 底部操作栏 ---- */
.pdf-panel-footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #fff;
}

.pdf-export-hint {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
  text-align: center;
}

.pdf-btn-generate {
  width: 100%;
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pdf-btn-generate:hover:not(:disabled) {
  background: #1d4ed8;
}

.pdf-btn-generate:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.pdf-btn-cancel {
  width: 100%;
  padding: 8px 16px;
  background: transparent;
  color: #6b7280;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.pdf-btn-cancel:hover {
  color: #374151;
  background: #f3f4f6;
}

/* Loading spinner */
.pdf-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pdf-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* 错误提示 */
.pdf-error-msg {
  font-size: 12px;
  color: #dc2626;
  text-align: center;
  margin-top: 6px;
  padding: 6px 10px;
  background: #fef2f2;
  border-radius: 4px;
  display: none;
}

.pdf-error-msg.visible {
  display: block;
}

/* 空状态 */
.pdf-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 13px;
}

/* ---- Header 右侧操作区（齿轮 + 关闭） ---- */
.pdf-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 齿轮（Token 配置）按钮 */
.pdf-token-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
  padding: 0;
}

.pdf-token-btn:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.pdf-token-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- Token 配置区 ---- */
.pdf-token-section {
  padding: 12px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.pdf-token-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.pdf-token-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pdf-token-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: monospace;
}

.pdf-token-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.pdf-token-save-btn {
  padding: 7px 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.pdf-token-save-btn:hover {
  background: #1d4ed8;
}

.pdf-token-hint {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
}

.pdf-token-status {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}

.pdf-token-status.ok {
  color: #16a34a;
}

.pdf-token-status.empty {
  color: #dc2626;
}

/* ---- 按钮区（每个按钮独占一行） ---- */
.pdf-btn-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.pdf-btn-generate {
  width: 100%;
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pdf-btn-generate:hover:not(:disabled) {
  background: #1d4ed8;
}

.pdf-btn-generate:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* 在线分享按钮 */
.pdf-btn-share {
  width: 100%;
  padding: 10px 16px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pdf-btn-share:hover:not(:disabled) {
  background: #15803d;
}

.pdf-btn-share:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.pdf-btn-cancel {
  width: 100%;
  padding: 8px 16px;
  background: transparent;
  color: #6b7280;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
  text-align: center;
}

.pdf-btn-cancel:hover {
  color: #374151;
  background: #f3f4f6;
}

/* ---- 分享结果区 ---- */
.pdf-share-result {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.pdf-share-result-label {
  font-size: 12px;
  font-weight: 600;
  color: #15803d;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-share-result-label::before {
  content: '✓';
  display: inline-block;
  width: 16px;
  height: 16px;
  background: #16a34a;
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  text-align: center;
  line-height: 16px;
  flex-shrink: 0;
}

.pdf-share-link-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.pdf-share-link-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 12px;
  color: #166534;
  background: #fff;
  outline: none;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-share-copy-btn {
  padding: 6px 12px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.pdf-share-copy-btn:hover {
  background: #15803d;
}

.pdf-share-copy-btn.copied {
  background: #166534;
}

.pdf-share-open-link {
  font-size: 11px;
  color: #16a34a;
  text-decoration: none;
  display: block;
  text-align: right;
}

.pdf-share-open-link:hover {
  text-decoration: underline;
}

/* Loading spinner（分享按钮用白色） */
.pdf-btn-share .pdf-spinner {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}
