/* Kaluo 增强功能样式 */

/* ========== 收藏按钮 ========== */
.k-favorite-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 1px solid #d9e4ee;
  background: #fff;
  color: #fbbf24;
  font-size: 18px;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.k-favorite-btn:hover {
  background: #fffbeb;
  border-color: #fbbf24;
  transform: translateY(-50%) scale(1.1);
}

.k-favorite-btn:active {
  transform: translateY(-50%) scale(0.95);
}

/* ========== 加载动画 ========== */
.k-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.k-loading-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

.k-loading-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 24px 32px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  text-align: center;
  min-width: 120px;
}

.k-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e7edf3;
  border-top-color: #10b7d6;
  border-radius: 50%;
  animation: k-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

.k-loading-content p {
  margin: 0;
  color: #394a5f;
  font-size: 14px;
}

/* ========== Toast 提示 ========== */
.k-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #fff;
  color: #394a5f;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  font-size: 14px;
  z-index: 9998;
  opacity: 0;
  transition: all 0.3s ease;
  border: 1px solid #e7edf3;
  pointer-events: none;
}

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

.k-toast-success {
  background: #f0fdf4;
  color: #16a66a;
  border-color: #86efac;
}

.k-toast-error {
  background: #fef2f2;
  color: #d84040;
  border-color: #fca5a5;
}

.k-toast-warning {
  background: #fffbeb;
  color: #d97706;
  border-color: #fde68a;
}

.k-toast-info {
  background: #f0f9ff;
  color: #0284c7;
  border-color: #7dd3fc;
}

/* ========== 历史记录样式优化 ========== */
.history-item {
  display: flex !important;
  justify-content: space-between !important;
  gap: 10px !important;
  border: 1px solid #eef3f7 !important;
  padding: 10px 12px !important;
  border-radius: 6px !important;
  color: #4d6074 !important;
  transition: all 0.2s ease !important;
  background: #fff !important;
}

.history-item:hover {
  border-color: #bfeaf2 !important;
  background: #fbfeff !important;
  transform: translateX(2px);
}

.history-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small {
  color: #8795a5 !important;
  white-space: nowrap;
  font-size: 12px;
}

/* ========== 图片懒加载占位 ========== */
img.lazy {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img.lazy.loaded {
  opacity: 1;
}

/* ========== 收藏工具面板 ========== */
.k-favorites-panel {
  border: 1px solid #d9e4ee;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 14px;
}

.k-favorites-header {
  height: 39px;
  padding: 0 12px;
  border-bottom: 1px solid #e7edf3;
  background: #fbfdff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  color: #25455f;
  font-size: 14px;
}

.k-favorites-header small {
  font-weight: 400;
  color: #8392a3;
  font-size: 12px;
}

.k-favorites-body {
  padding: 12px;
}

.k-favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.k-favorite-item {
  border: 1px solid #eef3f7;
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  position: relative;
  transition: all 0.2s ease;
  display: block;
  text-decoration: none;
  color: #4d6074;
}

.k-favorite-item:hover {
  border-color: #bfeaf2;
  background: #fbfeff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 183, 214, 0.08);
}

.k-favorite-item b {
  display: block;
  color: #263d52;
  margin-bottom: 4px;
  font-size: 13px;
}

.k-favorite-item small {
  color: #8795a5;
  font-size: 11px;
}

.k-favorite-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  color: #8795a5;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.k-favorite-item:hover .k-favorite-remove {
  display: flex;
}

.k-favorite-remove:hover {
  background: #fee2e2;
  color: #dc2626;
}

.k-favorites-empty {
  text-align: center;
  padding: 40px 20px;
  color: #8795a5;
  font-size: 13px;
}

/* ========== 响应式优化 ========== */
@media (max-width: 760px) {
  .k-favorite-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .k-toast {
    top: 60px;
    left: 12px;
    right: 12px;
    transform: translateY(-20px);
    max-width: calc(100% - 24px);
  }

  .k-toast.show {
    transform: translateY(0);
  }

  .k-favorites-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .k-favorite-item {
    padding: 10px;
  }

  .k-loading-content {
    padding: 20px 24px;
    min-width: 100px;
  }

  .k-spinner {
    width: 32px;
    height: 32px;
  }
}

/* ========== 性能优化样式 ========== */
.k-optimized {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .k-favorite-btn,
  .history-item,
  .k-toast,
  .k-spinner,
  img.lazy {
    animation: none !important;
    transition: none !important;
  }
}
