/* Telegram 云图床 - 优化精简版样式表 v3.0 (修复图片加载) */

/* ========== CSS 变量定义 ========== */
:root {
  /* 核心颜色 */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  /* 背景色 */
  --bg-main: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  
  /* 文字色 */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  
  /* 边框与阴影 */
  --border: #e5e7eb;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* 其他 */
  --radius: 0.5rem;
  --transition: 200ms ease;
}

/* 暗色模式 */
[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f9fafb;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
}

/* ========== 基础样式 ========== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  background: var(--bg-main);
  color: var(--text-primary);
  transition: background-color var(--transition), color var(--transition);
}

img {
  max-width: 100%;
  height: auto;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ========== 布局 ========== */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

/* ========== 导航栏 ========== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .navbar {
  background: rgba(15, 23, 42, 0.8);
}

.navbar-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}

.navbar-logo {
  font-size: 1.5rem;
}

.cdn-badge {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, #f48120, #f97316);
  color: white;
  border-radius: var(--radius);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ========== 主题切换 ========== */
.theme-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--primary-light);
  transform: scale(1.05);
}

.theme-icon {
  position: absolute;
  font-size: 1.25rem;
  transition: all var(--transition);
}

.theme-icon.sun {
  opacity: 1;
  transform: scale(1);
}

.theme-icon.moon {
  opacity: 0;
  transform: scale(0);
}

[data-theme="dark"] .theme-icon.sun {
  opacity: 0;
  transform: scale(0);
}

[data-theme="dark"] .theme-icon.moon {
  opacity: 1;
  transform: scale(1);
}

/* ========== Hero 区域 ========== */
.hero-section {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--bg-secondary);
  border-radius: calc(var(--radius) * 2);
  margin-bottom: 3rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  margin: 0 0 1rem;
  color: var(--primary-dark);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin: 0 0 1.5rem;
}

.hero-badges {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.badge {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

/* ========== 上传区域 ========== */
.upload-container {
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  border-radius: calc(var(--radius) * 2);
  padding: 3rem 2rem;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2rem;
}

.upload-container:hover,
.upload-container.dragover {
  border-color: var(--primary);
  background: var(--bg-tertiary);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.upload-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.upload-subtitle {
  color: var(--text-secondary);
  margin: 0 0 1.5rem;
}

.upload-note {
  font-size: 0.875rem;
  color: var(--primary);
  margin: 0.5rem 0 0;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

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

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

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

/* ========== 进度条 ========== */
.progress-container {
  margin-top: 1.5rem;
  display: none;
}

.progress-bar {
  height: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 0.25rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width var(--transition);
}

/* ========== 图片加载状态 ========== */
.result-preview-container {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.image-loading,
.image-error {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.5rem;
}

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

.image-error span:first-child {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.retry-btn {
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

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

/* ========== 结果展示 ========== */
.results-container {
  display: none;
  margin-top: 2rem;
}

.result-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  padding: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 1.5rem;
  transition: all var(--transition);
}

.result-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.result-preview {
  width: 100px;
  height: 100px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-tertiary);
  display: none; /* 默认隐藏，加载成功后显示 */
}

.result-details {
  flex: 1;
}

.result-filename {
  font-weight: 600;
  margin: 0 0 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* 复制格式 */
.copy-formats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.copy-format {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.format-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 70px;
}

.format-value-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.format-value {
  flex: 1;
  font-family: monospace;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

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

/* ========== Toast 通知 ========== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  pointer-events: none;
}

.toast {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 250px;
  pointer-events: auto;
  transform: translateX(400px);
  opacity: 0;
  transition: all var(--transition);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.info {
  border-left: 3px solid var(--primary);
}

/* ========== 页脚 ========== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 1rem;
  margin-top: 3rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 700;
  color: var(--primary);
}

.stat-divider {
  color: var(--border);
  user-select: none;
}

.footer-info {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ========== 工具类 ========== */
.file-input {
  display: none;
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 0.25rem;
  background: var(--success);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== 管理员状态 ========== */
.admin-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-user {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
  .hero-section {
    padding: 2rem 1rem;
  }
  
  .upload-container {
    padding: 2rem 1rem;
  }
  
  .result-item {
    flex-direction: column;
  }
  
  .result-preview-container {
    width: 100%;
    height: 150px;
  }
  
  .result-preview {
    width: 100%;
    height: 150px;
  }
  
  .copy-format {
    flex-direction: column;
    align-items: stretch;
  }
  
  .format-label {
    min-width: unset;
  }
  
  .footer-stats {
    gap: 1rem;
  }
  
  .admin-user {
    display: none;
  }
  
  .navbar-brand span:not(.navbar-logo) {
    display: none;
  }
  
  .stat-divider {
    display: none;
  }
}

@media (max-width: 480px) {
  .hero-badges {
    flex-direction: column;
  }
  
  .toast-container {
    left: 1rem;
    right: 1rem;
  }
  
  .toast {
    min-width: auto;
  }
  
  .footer-stats {
    flex-direction: column;
    gap: 0.5rem;
  }
}