:root {
  --primary-color: #4F46E5;
  --primary-hover: #4338CA;
  --success-color: #10B981;
  --success-hover: #059669;
  --error-color: #EF4444;
  --error-hover: #DC2626;
  --secondary-color: #6B7280;
  --secondary-hover: #4B5563;
  --background-color: #FFFFFF;
  --text-color: #1F2937;
  --text-secondary: #6B7280;
  --border-color: #E5E7EB;
  --log-bg: #F9FAFB;
  --border-radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

.popup-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  width: 360px;
  max-height: 600px;
  padding: 20px;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.5;
  overflow-y: auto;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 40px 20px;
}

.loading span {
  font-size: 2em;
  display: block;
  margin-bottom: 10px;
}

.loading p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9em;
}

/* Progress Container */
.progress-container {
  text-align: center;
  padding: 60px 40px;
  background-color: var(--background-color);
}

.progress-icon {
  font-size: 3em;
  margin-bottom: 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

.progress-text {
  font-size: 1.1em;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 25px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  border-radius: 4px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background-image: linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.2) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.2) 75%,
    transparent 75%,
    transparent
  );
  background-size: 10px 10px;
  animation: move 1s linear infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes move {
  0% { background-position-x: 0; }
  100% { background-position-x: 10px; }
}

/* Platform Header */
.platform-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.platform-icon {
  font-size: 2em;
  line-height: 1;
}

.platform-info h2 {
  margin: 0 0 4px 0;
  font-size: 1.2em;
  font-weight: 600;
  color: var(--text-color);
}

.platform-info p {
  margin: 0;
  font-size: 0.85em;
  color: var(--text-secondary);
}

/* Main Action Button */
.main-action-btn {
  width: 100%;
  padding: 16px 20px;
  margin-bottom: 16px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow);
}

.main-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.main-action-btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* Button Variants */
.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-processing {
  background-color: var(--secondary-color);
  color: white;
  cursor: not-allowed;
}

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

.btn-success:hover:not(:disabled) {
  background-color: var(--success-hover);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.btn-error:hover:not(:disabled) {
  background-color: var(--error-hover);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Loading Spinner */
.loading-spinner {
  animation: spin 1s linear infinite;
}

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

/* Secondary Button */
.secondary-btn {
  width: 100%;
  padding: 10px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--background-color);
  color: var(--text-secondary);
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background-color: var(--log-bg);
  border-color: var(--secondary-color);
  color: var(--text-color);
}

/* Log Area */
.log-area {
  background-color: var(--log-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.log-entry {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8em;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-secondary);
  font-size: 0.75em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 60px;
}

.log-message {
  flex: 1;
  word-break: break-word;
  line-height: 1.4;
}

/* Scrollbar Styling */
.log-area::-webkit-scrollbar {
  width: 6px;
}

.log-area::-webkit-scrollbar-track {
  background: transparent;
}

.log-area::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.log-area::-webkit-scrollbar-thumb:hover {
  background-color: var(--secondary-color);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #6366F1;
    --primary-hover: #7C3AED;
    --success-color: #10B981;
    --success-hover: #059669;
    --error-color: #EF4444;
    --error-hover: #DC2626;
    --secondary-color: #9CA3AF;
    --secondary-hover: #D1D5DB;
    --background-color: #1F2937;
    --text-color: #F9FAFB;
    --text-secondary: #9CA3AF;
    --border-color: #374151;
    --log-bg: #111827;
  }
  
  .platform-header {
    background: linear-gradient(135deg, #374151 0%, #4B5563 100%);
  }
}

/* Responsive Design */
@media (max-width: 380px) {
  .popup-container {
    width: 100%;
    padding: 16px;
  }
  
  .platform-header {
    padding: 12px;
    gap: 10px;
  }
  
  .platform-icon {
    font-size: 1.8em;
  }
  
  .main-action-btn {
    padding: 14px 16px;
    font-size: 0.95em;
  }
}

/* Animation for smooth transitions */
.popup-container * {
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* Empty state */
.log-area:empty::before {
  content: "准备就绪...";
  display: block;
  padding: 20px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.8em;
}

/* 认证相关样式 */

/* 认证加载状态 */
.auth-loading {
  text-align: center;
  padding: 40px 20px;
}

.auth-loading span {
  font-size: 2em;
  display: block;
  margin-bottom: 10px;
}

.auth-loading p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9em;
}

/* 未认证状态 */
.auth-required {
  text-align: center;
  padding: 30px 20px;
}

.auth-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.auth-icon {
  font-size: 3em;
  margin-bottom: 8px;
  opacity: 0.8;
}

.auth-message h3 {
  margin: 0;
  font-size: 1.2em;
  color: var(--text-color);
  font-weight: 600;
}

.auth-message p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9em;
  line-height: 1.4;
  max-width: 280px;
}

/* 认证操作按钮容器 */
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

/* 登录按钮 */
.login-btn {
  background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  min-width: 160px;
  justify-content: center;
}

/* 刷新状态按钮 */
.refresh-btn {
  background: var(--background-color);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.85em;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  min-width: 120px;
  justify-content: center;
}

.refresh-btn:hover:not(:disabled) {
  background: var(--log-bg);
  border-color: var(--secondary-color);
  color: var(--text-color);
}

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

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

/* 已认证状态 */
.authenticated {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 用户信息栏 */
.user-info {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--log-bg) 0%, rgba(79, 70, 229, 0.05) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  gap: 12px;
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  object-fit: cover;
}

.user-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-name {
  font-weight: 500;
  font-size: 0.9em;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.75em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 登出按钮 */
.logout-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s ease;
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-btn:hover {
  background-color: var(--log-bg);
  border-color: var(--secondary-color);
  color: var(--text-color);
}

/* 错误显示 */
.error-container {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  margin-top: 12px;
  text-align: left;
}

.error-message {
  color: var(--error-color);
  font-size: 0.85em;
  margin-bottom: 8px;
  line-height: 1.4;
}

.retry-btn {
  background: var(--error-color);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background-color: var(--error-hover);
}

/* 响应式适配 */
@media (max-width: 380px) {
  .auth-required {
    padding: 20px 16px;
  }
  
  .auth-message h3 {
    font-size: 1.1em;
  }
  
  .auth-message p {
    font-size: 0.85em;
  }
  
  .user-info {
    padding: 10px 12px;
    gap: 10px;
  }
  
  .user-avatar {
    width: 28px;
    height: 28px;
  }
  
  .user-name {
    font-size: 0.85em;
  }
  
  .user-email {
    font-size: 0.7em;
  }
  
  .logout-btn {
    min-width: 28px;
    height: 28px;
    font-size: 0.8em;
  }
}

/* 格式选择区域 */
.format-selection {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--log-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.format-selection h3 {
  margin: 0 0 12px 0;
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text-color);
}

.format-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.format-option:hover {
  border-color: var(--primary-color);
  background: rgba(79, 70, 229, 0.02);
}

.format-option.selected {
  border-color: var(--primary-color);
  background: rgba(79, 70, 229, 0.05);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.format-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary-color);
}

.format-icon {
  font-size: 1.2em;
  line-height: 1;
}

.format-name {
  font-weight: 500;
  font-size: 0.9em;
  color: var(--text-color);
  min-width: 80px;
}

.format-desc {
  font-size: 0.8em;
  color: var(--text-secondary);
  flex: 1;
}

/* 深色模式下的认证样式调整 */
@media (prefers-color-scheme: dark) {
  .login-btn {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
  }
  
  .user-info {
    background: linear-gradient(135deg, var(--log-bg) 0%, rgba(99, 102, 241, 0.1) 100%);
  }
  
  .error-container {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
  }

  .format-option:hover {
    background: rgba(99, 102, 241, 0.03);
  }

  .format-option.selected {
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
  }
}

/* 响应式格式选择 */
@media (max-width: 380px) {
  .format-selection {
    padding: 12px;
  }
  
  .format-option {
    padding: 10px;
    gap: 10px;
  }
  
  .format-name {
    min-width: 70px;
    font-size: 0.85em;
  }
  
  .format-desc {
    font-size: 0.75em;
  }
}

/* 底部推广链接 */
.footer-link {
  margin-top: 20px;
  padding: 16px;
  background: linear-gradient(135deg, var(--log-bg) 0%, rgba(79, 70, 229, 0.03) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  text-align: center;
}

.footer-text {
  margin: 0 0 12px 0;
  font-size: 0.8em;
  color: var(--text-secondary);
  line-height: 1.4;
}

.footer-link-button {
  display: inline-block;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85em;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.footer-link-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
  text-decoration: none;
  color: white;
}

.footer-link-button:active {
  transform: translateY(0);
}

/* 深色模式下的底部链接样式 */
@media (prefers-color-scheme: dark) {
  .footer-link {
    background: linear-gradient(135deg, var(--log-bg) 0%, rgba(99, 102, 241, 0.05) 100%);
  }
  
  .footer-link-button {
    background: linear-gradient(135deg, #6366F1 0%, #7C3AED 100%);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.25);
  }
  
  .footer-link-button:hover {
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.35);
  }
}

/* 响应式底部链接 */
@media (max-width: 380px) {
  .footer-link {
    margin-top: 16px;
    padding: 12px;
  }
  
  .footer-text {
    font-size: 0.75em;
    margin-bottom: 10px;
  }
  
  .footer-link-button {
    padding: 6px 12px;
    font-size: 0.8em;
  }
}