/* -------------------------------------------------------------------------
   Design tokens
   ------------------------------------------------------------------------- */
:root {
  --bg:          #0d0f18;
  --surface:     #13162a;
  --surface-2:   #1a1e35;
  --border:      #252a45;
  --border-hover:#3a4070;
  --primary:     #5865f2;
  --primary-hov: #4752c4;
  --discord:     #5865f2;
  --discord-hov: #4752c4;
  --success:     #2ecc71;
  --error:       #e74c3c;
  --warning:     #f39c12;
  --text:        #e2e8f0;
  --muted:       #8892a4;
  --code-bg:     #1e2236;
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  0.18s ease;
}

/* -------------------------------------------------------------------------
   Reset / base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.88em;
  color: #a5b4fc;
}

ul { list-style: none; }
ol { padding-left: 1.5rem; }
ol li + li { margin-top: 0.4rem; }

/* -------------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* -------------------------------------------------------------------------
   Header
   ------------------------------------------------------------------------- */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

/* User chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px 4px 4px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--error); }

/* -------------------------------------------------------------------------
   Auth screen
   ------------------------------------------------------------------------- */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  min-height: calc(100vh - 60px - 54px); /* minus header + footer */
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.1rem;
}

.auth-logo {
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.auth-desc {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.55;
}

.auth-footer {
  font-size: 0.78rem;
  color: #4a5270;
}

/* Auth error banner */
.auth-error-banner {
  width: 100%;
  background: #e74c3c14;
  border: 1px solid #e74c3c44;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
}

/* Discord button */
.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.5rem;
  background: var(--discord);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.975rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  text-decoration: none;
  width: 100%;
  justify-content: center;
}
.btn-discord:hover {
  background: var(--discord-hov);
  text-decoration: none;
  color: #fff;
}
.btn-discord:active { transform: scale(0.97); }

/* -------------------------------------------------------------------------
   Hero
   ------------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 2.5rem 0 2rem;
}

.hero h1 {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #e2e8f0 30%, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 540px;
  margin: 0 auto;
}

/* -------------------------------------------------------------------------
   Upload form
   ------------------------------------------------------------------------- */
.upload-form { display: flex; flex-direction: column; gap: 1.5rem; }

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .upload-grid { grid-template-columns: 1fr; }
}

/* Drop zone */
.drop-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  transition: border-color var(--transition), background var(--transition);
  min-height: 220px;
  justify-content: center;
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--surface-2);
}

.drop-zone.has-file {
  border-color: var(--success);
  border-style: solid;
}

.drop-icon {
  color: var(--muted);
  transition: color var(--transition);
}

.drop-zone:hover .drop-icon,
.drop-zone.has-file .drop-icon {
  color: var(--primary);
}

.drop-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.drop-label strong {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.drop-label span {
  font-size: 0.875rem;
  color: var(--muted);
}

.drop-hint {
  font-size: 0.78rem !important;
  color: #5a6380 !important;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

/* File badge (world) */
.file-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  word-break: break-all;
}

/* Packs list */
.packs-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 140px;
  overflow-y: auto;
  margin-top: 0.25rem;
}

.pack-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

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

.pack-item .pack-size {
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.pack-type-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}

.pack-type-badge.mcpack  { background: #2563eb22; color: #60a5fa; }
.pack-type-badge.mcaddon { background: #7c3aed22; color: #a78bfa; }

/* Action row */
.action-row {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hov); text-decoration: none; color: #fff; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }

.btn-download {
  background: var(--success);
  color: #fff !important;
  width: 100%;
  justify-content: center;
}
.btn-download:hover { background: #27ae60; text-decoration: none; }

/* -------------------------------------------------------------------------
   Progress
   ------------------------------------------------------------------------- */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-label { font-size: 0.95rem; color: var(--text); }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.progress-bar-wrap {
  background: var(--surface-2);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #a78bfa);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
}

/* -------------------------------------------------------------------------
   Result / Error cards
   ------------------------------------------------------------------------- */
.result-card,
.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-card { border-color: #2ecc7133; }
.error-card {
  flex-direction: row;
  align-items: flex-start;
  gap: 1rem;
  border-color: #e74c3c33;
}

.result-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.result-icon { flex-shrink: 0; margin-top: 2px; }
.result-icon.success { color: var(--success); }
.result-icon.error   { color: var(--error); flex-shrink: 0; }

.result-title { font-size: 1.25rem; font-weight: 700; }
.result-sub   { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }

.error-message { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }

/* Download link block */
.download-link-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dl-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.dl-row {
  display: flex;
  gap: 0.5rem;
}

.dl-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.85rem;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  min-width: 0;
  outline: none;
}

.dl-input:focus { border-color: var(--primary); }

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-copy:hover { border-color: var(--primary); color: var(--primary); }
.btn-copy.copied { border-color: var(--success); color: var(--success); }

/* Installed packs */
.result-packs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.installed-pack {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ip-name { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.ip-meta { font-size: 0.78rem; color: var(--muted); }

.ip-type {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  flex-shrink: 0;
}
.ip-type.behavior_pack { background: #2563eb22; color: #60a5fa; }
.ip-type.resource_pack  { background: #7c3aed22; color: #a78bfa; }

/* Instructions */
.result-instructions,
.warnings-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
}

.result-instructions h3,
.warnings-block h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.result-instructions ol { color: var(--text); font-size: 0.9rem; }

/* Warnings */
.warnings-block {
  background: #f39c1208;
  border-color: #f39c1233;
}

.warnings-block ul { display: flex; flex-direction: column; gap: 0.35rem; }

.warnings-block li {
  font-size: 0.875rem;
  color: var(--warning);
  padding-left: 1.2rem;
  position: relative;
}

.warnings-block li::before {
  content: '⚠';
  position: absolute;
  left: 0;
  font-size: 0.75rem;
  top: 1px;
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* -------------------------------------------------------------------------
   Utility
   ------------------------------------------------------------------------- */
[hidden] { display: none !important; }
