/* =========================================================
   VidGrab — Social Media Video Downloader
   Dark, glassy, modern UI
   ========================================================= */

:root {
  --bg: #0a0b14;
  --bg-2: #111225;
  --card: rgba(255, 255, 255, 0.04);
  --card-brd: rgba(255, 255, 255, 0.09);
  --text: #eef0f7;
  --muted: #99a0b8;
  --brand: #ff2d55;
  --brand-2: #7c3aed;
  --accent: #22d3ee;
  --ok: #22c55e;
  --err: #ef4444;
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 80% -10%, #1a1140 0%, transparent 60%),
              radial-gradient(1000px 700px at -10% 110%, #0d2a3a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* floating background orbs */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-orbs span {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35;
  animation: float 18s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { width: 340px; height: 340px; background: var(--brand);   top: 8%; left: 10%; }
.bg-orbs span:nth-child(2) { width: 300px; height: 300px; background: var(--brand-2); top: 55%; right: 8%; animation-delay: -6s; }
.bg-orbs span:nth-child(3) { width: 260px; height: 260px; background: var(--accent);  bottom: 5%; left: 40%; animation-delay: -12s; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-40px) } }

/* topbar */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; max-width: 1000px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 24px rgba(255, 45, 85, 0.35);
}
.brand h1 { font-size: 22px; letter-spacing: 0.5px; }
.brand p { font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 8px; }
.badge {
  font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--card-brd); color: var(--accent);
}

/* container */
.container { position: relative; z-index: 2; max-width: 780px; margin: 0 auto; padding: 20px 18px 60px; }

.hero { text-align: center; margin: 18px 0 26px; }
.hero h2 { font-size: 27px; line-height: 1.25; }
.hero .sub { color: var(--muted); margin-top: 10px; font-size: 15px; }

/* input card */
.input-card {
  background: var(--card); border: 1px solid var(--card-brd); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input-wrap { position: relative; flex: 1 1 320px; display: flex; align-items: center; }
.link-ic {
  position: absolute; left: 14px; width: 18px; height: 18px; fill: none;
  stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
#url {
  width: 100%; padding: 15px 40px 15px 42px; font-size: 15px;
  border-radius: 12px; border: 1px solid var(--card-brd); color: var(--text);
  background: rgba(0, 0, 0, 0.25); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
#url:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.15); }
#url::placeholder { color: #6b7290; }
.clear-btn {
  position: absolute; right: 12px; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 15px;
}

.primary-btn, .ghost-btn {
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 14px 18px; border-radius: 12px; transition: transform 0.12s, filter 0.2s, background 0.2s;
  white-space: nowrap;
}
.primary-btn { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active, .ghost-btn:active { transform: scale(0.97); }
.ghost-btn {
  color: var(--text); background: var(--card); border: 1px solid var(--card-brd);
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* platform buttons */
.platforms {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px;
}
.pf-btn {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 14px; border-radius: 30px; font-size: 13px; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-brd); transition: transform 0.12s, border-color 0.2s, background 0.2s;
}
.pf-btn:hover { transform: translateY(-2px); }
.pf-btn .pf-ic { width: 18px; height: 18px; display: grid; place-items: center; font-size: 15px; }
.pf-btn.active { border-color: currentColor; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08) inset; }

/* message */
.message {
  margin-top: 16px; padding: 13px 16px; border-radius: 12px; font-size: 14px;
  border: 1px solid var(--card-brd); background: var(--card);
}
.message.error { border-color: rgba(239, 68, 68, 0.5); color: #ffb4b4; background: rgba(239, 68, 68, 0.1); }
.message.info { color: var(--muted); }
.message .spin { display: inline-block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* preview */
.preview-card {
  display: flex; gap: 18px; margin-top: 18px; padding: 16px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--card-brd); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
  animation: rise 0.4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
.preview-media { position: relative; flex: 0 0 240px; }
.preview-media img {
  width: 240px; height: 135px; object-fit: cover; border-radius: 12px;
  background: #000; display: block;
}
.dur-badge {
  position: absolute; bottom: 8px; right: 8px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.8); font-size: 12px; font-weight: 600;
}
.preview-info { flex: 1 1 260px; display: flex; flex-direction: column; }
.preview-info h3 { font-size: 17px; line-height: 1.35; }
.v-meta { color: var(--muted); font-size: 13px; margin-top: 6px; }

.quality-block { margin: 16px 0; }
.q-label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 10px; }
.quality-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.q-chip {
  cursor: pointer; padding: 9px 15px; border-radius: 10px; font-size: 13px; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--card-brd);
  transition: all 0.15s;
}
.q-chip:hover { border-color: var(--accent); }
.q-chip.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent;
}
.q-chip.dim { opacity: 0.4; }

.download-btn, .save-btn {
  margin-top: auto; cursor: pointer; border: none; text-decoration: none; text-align: center;
  padding: 15px 20px; border-radius: 12px; font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--ok), #16a34a);
  transition: transform 0.12s, filter 0.2s; display: inline-block;
}
.download-btn:hover, .save-btn:hover { filter: brightness(1.08); }
.download-btn:active { transform: scale(0.98); }
.download-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* progress */
.progress-card {
  margin-top: 18px; padding: 18px; background: var(--card); border: 1px solid var(--card-brd);
  border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(14px);
  animation: rise 0.4s ease;
}
.progress-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.p-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-status {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
  background: rgba(124, 58, 237, 0.2); color: #c4b5fd; text-transform: uppercase; letter-spacing: 0.5px;
}
.p-status.finished { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.p-status.error { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.bar { height: 12px; border-radius: 20px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0%; border-radius: 20px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--accent));
  background-size: 200% 100%; transition: width 0.3s ease; animation: shimmer 2s linear infinite;
}
@keyframes shimmer { to { background-position: 200% 0 } }
.progress-meta { display: flex; gap: 18px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.done-row { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.save-btn { margin: 0; }

/* history */
.history { margin-top: 30px; }
.history h3 { font-size: 16px; margin-bottom: 14px; color: var(--muted); }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.h-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--card-brd); border-radius: 12px;
}
.h-item .h-title { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-item .h-q { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); color: var(--accent); }
.h-item a { color: var(--ok); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.h-item .h-err { color: var(--err); font-size: 12px; }

/* footer */
.footer { position: relative; z-index: 2; text-align: center; padding: 24px; color: var(--muted); font-size: 12px; }

/* responsive */
@media (max-width: 600px) {
  .hero h2 { font-size: 22px; }
  .preview-media, .preview-media img { flex-basis: auto; width: 100%; height: auto; aspect-ratio: 16/9; }
  .input-row { flex-direction: column; }
  .primary-btn, .ghost-btn { width: 100%; }
}
