/* ==============================================================================
   TeleFetch - 星雲轉存 Modern Glassmorphic Cyber Dark UI
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(23, 32, 54, 0.7);
  --bg-card-hover: rgba(30, 41, 69, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-focus: rgba(99, 102, 241, 0.5);

  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --gradient-neon: linear-gradient(135deg, #06b6d4 0%, #6366f1 50%, #8b5cf6 100%);
  --gradient-card: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.01) 100%);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(139, 92, 246, 0.08) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 14px 60px;
  padding-top: max(16px, env(safe-area-inset-top));
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border);
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: var(--gradient-neon);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-title {
  min-width: 0;
  overflow: hidden;
}

.brand-title h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.brand-title p {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.kofi-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #ff5e5b, #ff8a65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255, 94, 91, 0.35);
  transition: var(--transition);
}

.kofi-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 94, 91, 0.5);
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 5px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-emerald);
  white-space: nowrap;
  flex-shrink: 0;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
}

.tab-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--glass-border-focus);
}

.tab-btn.active {
  background: var(--gradient-neon);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

/* Tab Contents */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}
.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-item {
  background: var(--gradient-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.stat-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-cyan);
}
.stat-item.purple::before { background: var(--accent-purple); }
.stat-item.indigo::before { background: var(--accent-indigo); }
.stat-item.emerald::before { background: var(--accent-emerald); }

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Progress Bar Component */
.progress-container {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-neon);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Form Styles */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.input-box {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.input-box:focus {
  outline: none;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.select-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.select-btn:hover {
  background: rgba(30, 41, 69, 0.8);
  color: var(--text-primary);
}

.select-btn.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-indigo);
  color: #fff;
  font-weight: 600;
}

.btn-primary {
  background: var(--gradient-neon);
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
}

/* Tasks & File List */
.task-item, .file-item {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
}

.task-item:hover, .file-item:hover {
  background: rgba(23, 32, 54, 0.8);
  border-color: rgba(255, 255, 255, 0.15);
}

.item-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-queued { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-downloading { background: rgba(6, 182, 212, 0.2); color: var(--accent-cyan); }
.badge-processing { background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); }
.badge-uploading { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }
.badge-completed { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }
.badge-failed { background: rgba(244, 63, 94, 0.2); color: var(--accent-rose); }

/* File Tags & Category Pills */
.tag-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-indigo);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.pill-btn.active {
  background: var(--gradient-neon);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.tag-badge-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.tag-badge-btn:hover, .tag-badge-btn.active {
  background: rgba(99, 102, 241, 0.35);
  border-color: var(--accent-indigo);
  color: #fff;
}

.tag-badge-btn.clear-btn {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card-hover);
  border: 1px solid var(--glass-border-focus);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9999;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==============================================================================
   Mobile Responsiveness & Telegram Mini App Optimizations
   ============================================================================== */
@media (max-width: 640px) {
  .app-container {
    padding: 12px 10px 50px;
  }

  .app-header {
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 18px;
    border-radius: 8px;
  }

  .brand-title h1 {
    font-size: 16px;
  }

  .brand-title p {
    font-size: 10px;
  }

  .kofi-btn {
    padding: 4px 8px;
    font-size: 10.5px;
    gap: 3px;
  }

  .header-status {
    padding: 4px 8px;
    font-size: 10.5px;
    gap: 4px;
  }

  .nav-tabs {
    gap: 5px;
    padding-bottom: 6px;
    margin-bottom: 14px;
  }

  .tab-btn {
    padding: 7px 11px;
    font-size: 12px;
    border-radius: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-item {
    padding: 12px;
    border-radius: 10px;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 17px;
  }

  .glass-card {
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 14px;
  }

  .card-title {
    font-size: 15px;
  }

  .select-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .input-box {
    padding: 10px 12px;
    font-size: 13px;
  }

  .btn-primary {
    padding: 11px 16px;
    font-size: 13.5px;
  }
}

@media (max-width: 380px) {
  .brand-title p {
    display: none;
  }

  .brand-title h1 {
    font-size: 15px;
  }

  .kofi-btn span:last-child {
    font-size: 10px;
  }

  .header-status span:last-child {
    font-size: 10px;
  }
}


