/* ─── RESET & BASE ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:         #e53e3e;
  --red-dark:    #c53030;
  --blue:        #4299e1;
  --blue-dark:   #2b6cb0;
  --green:       #48bb78;
  --green-dark:  #276749;
  --bg:          #0d0f14;
  --surface:     #161923;
  --surface2:    #1e2433;
  --border:      rgba(255,255,255,0.07);
  --text:        #e2e8f0;
  --text-muted:  #718096;
  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 8px 32px rgba(0,0,0,0.45);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ─── BACKGROUND ORBS ───────────────────────────────────────────────────── */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  animation: float 12s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: #e53e3e; top: -150px; left: -150px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: #4299e1; bottom: -100px; right: -100px; animation-delay: -4s; }
.orb-3 { width: 300px; height: 300px; background: #805ad5; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -8s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-30px) scale(1.05); }
}

/* ─── LAYOUT ────────────────────────────────────────────────────────────── */
.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ─── HEADER ────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}

.logo-area { display: flex; align-items: center; gap: 16px; }

.logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--red), #ff6b6b);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 24px rgba(229,62,62,0.4);
}
.logo-icon svg { width: 26px; height: 26px; stroke: #fff; }

.site-title  { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
.site-sub    { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ─── STATUS BADGE ──────────────────────────────────────────────────────── */
.badge {
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.3s;
}
.badge-idle    { background: rgba(255,255,255,0.07); color: var(--text-muted); }
.badge-running { background: rgba(66,153,225,0.2); color: var(--blue); animation: pulse-blue 2s infinite; }
.badge-done    { background: rgba(72,187,120,0.2); color: var(--green); }
.badge-error   { background: rgba(229,62,62,0.2);  color: var(--red); }

@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(66,153,225,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(66,153,225,0); }
}

/* ─── CARDS ─────────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
@media (max-width: 620px) { .cards-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 16px 48px rgba(0,0,0,0.55); }

.card-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.card-icon svg { width: 22px; height: 22px; }

.glow-red  { background: rgba(229,62,62,0.15); color: var(--red); box-shadow: 0 0 16px rgba(229,62,62,0.2); }
.glow-red svg { stroke: var(--red); }
.glow-blue { background: rgba(66,153,225,0.15); color: var(--blue); box-shadow: 0 0 16px rgba(66,153,225,0.2); }
.glow-blue svg { stroke: var(--blue); }

.card h2    { font-size: 1.05rem; font-weight: 700; }
.card p     { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; flex: 1; }

/* ─── BUTTONS ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  align-self: flex-start;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn:active   { transform: scale(0.97); }

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

.btn-danger  { background: linear-gradient(135deg, var(--red), #fc5c7d); color: #fff; box-shadow: 0 4px 16px rgba(229,62,62,0.35); }
.btn-danger:hover  { box-shadow: 0 6px 24px rgba(229,62,62,0.5); transform: translateY(-1px); }

.btn-primary { background: linear-gradient(135deg, var(--blue), #6cb4f8); color: #fff; box-shadow: 0 4px 16px rgba(66,153,225,0.35); }
.btn-primary:hover { box-shadow: 0 6px 24px rgba(66,153,225,0.5); transform: translateY(-1px); }

.btn-success { background: linear-gradient(135deg, var(--green), #68d391); color: #fff; box-shadow: 0 4px 16px rgba(72,187,120,0.35); }
.btn-success:hover { box-shadow: 0 6px 24px rgba(72,187,120,0.5); transform: translateY(-1px); }

/* ─── PROGRESS ──────────────────────────────────────────────────────────── */
.progress-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}
#progress-pct { color: var(--blue); font-size: 1rem; }

.progress-track {
  position: relative;
  height: 10px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: visible;
  margin-bottom: 20px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue), #90cdf4);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}
.progress-bar.done-bar {
  background: linear-gradient(90deg, var(--green-dark), var(--green), #9ae6b4);
}
.progress-bar.error-bar {
  background: linear-gradient(90deg, var(--red-dark), var(--red), #fc8181);
}

.progress-glow {
  position: absolute;
  top: -3px;
  left: 0;
  height: 16px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, rgba(66,153,225,0.6));
  filter: blur(6px);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

/* ─── TERMINAL ──────────────────────────────────────────────────────────── */
.terminal {
  background: #0a0c10;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }
.terminal-title { margin-left: 6px; font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

.terminal-body {
  padding: 14px 16px;
  max-height: 260px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: #a0aec0;
  scroll-behavior: smooth;
}
.terminal-body::-webkit-scrollbar { width: 4px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.log-placeholder { color: var(--text-muted); font-style: italic; }
.log-line        { color: #a0aec0; }
.log-line.success { color: #68d391; }
.log-line.error   { color: #fc8181; }

/* ─── PDF SECTION ───────────────────────────────────────────────────────── */
.pdf-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.pdf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 14px;
}

.pdf-title-area { display: flex; align-items: center; gap: 14px; }

.pdf-icon {
  width: 44px; height: 44px;
  background: rgba(72,187,120,0.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.pdf-icon svg { width: 22px; height: 22px; stroke: var(--green); }

.pdf-title-area h3   { font-size: 1rem; font-weight: 700; }
.pdf-title-area p    { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.pdf-viewer iframe {
  width: 100%;
  height: 680px;
  border: none;
  display: block;
}

/* ─── SPINNING LOADER ON BUTTON ─────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; display: inline-block; }

/* ─── PDF WARNING (no pdf found) ────────────────────────────────────────── */
.pdf-warning {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 28px;
  background: rgba(229,62,62,0.07);
  border-top: 1px solid rgba(229,62,62,0.15);
}
.pdf-warning svg {
  width: 32px; height: 32px;
  stroke: var(--red);
  flex-shrink: 0;
  margin-top: 2px;
}
.pdf-warning strong { font-size: 1rem; font-weight: 700; color: var(--text); }
.pdf-warning p  { font-size: 0.84rem; color: var(--text-muted); margin-top: 4px; line-height: 1.6; }
.pdf-warning code {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  color: #fc8181;
}

/* ─── GHOST BUTTON ──────────────────────────────────────────────────────── */
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  transform: translateY(-1px);
}
.btn-ghost svg { width: 14px; height: 14px; }

/* ─── CATEGORY DOWNLOAD SECTION ─────────────────────────────────────────── */
.cat-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-top: 28px;
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 14px;
}

.cat-title-area { display: flex; align-items: center; gap: 14px; }

.cat-icon {
  width: 44px; height: 44px;
  background: rgba(128,90,213,0.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.cat-icon svg { width: 20px; height: 20px; stroke: #b794f4; }

.cat-title-area h3 { font-size: 1rem; font-weight: 700; }
.cat-title-area p  { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--border);
}

.cat-placeholder {
  grid-column: 1 / -1;
  background: var(--surface);
  text-align: center;
  padding: 36px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
}
.cat-error { color: #fc8181 !important; }

.cat-card {
  background: var(--surface);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background 0.2s;
}
.cat-card:hover { background: var(--surface2); }

.cat-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cat-card-icon {
  width: 36px; height: 36px;
  background: rgba(66,153,225,0.1);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cat-card-icon svg { width: 17px; height: 17px; stroke: var(--blue); }

.cat-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-card-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: rgba(66,153,225,0.15);
  color: var(--blue);
  border: 1px solid rgba(66,153,225,0.25);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-cat:hover {
  background: rgba(66,153,225,0.28);
  border-color: rgba(66,153,225,0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(66,153,225,0.25);
}
.btn-cat:active { transform: scale(0.97); }
.btn-cat svg { width: 14px; height: 14px; }

/* ─── PDF SECTION MARGIN ────────────────────────────────────────────────── */
.pdf-section { margin-bottom: 0; }

/* ─── CATEGORY SEARCH BAR ───────────────────────────────────────────────── */
.cat-search-wrap { display: flex; align-items: center; gap: 10px; }

.cat-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cat-search-box:focus-within {
  border-color: rgba(66,153,225,0.5);
  box-shadow: 0 0 0 3px rgba(66,153,225,0.12);
}
.cat-search-box svg {
  width: 15px; height: 15px;
  stroke: var(--text-muted);
  flex-shrink: 0;
}
.cat-search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.86rem;
  width: 190px;
}
.cat-search-box input::placeholder { color: var(--text-muted); }

/* ─── LIVE DOT ──────────────────────────────────────────────────────────── */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  animation: live-pulse 2s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(72,187,120,0.6);
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}


