/* ================================================================
   Download Media — Material Design 3 Inspired Theme
   ================================================================ */

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

:root {
  /* Surface & background */
  --bg:           #0f0f14;
  --surface-0:    #16161e;
  --surface-1:    #1e1e28;
  --surface-2:    #262633;
  --surface-3:    #2e2e3e;

  /* Primary palette — deep violet / purple */
  --primary:      #a78bfa;
  --primary-dim:  #7c5cbf;
  --primary-bg:   rgba(167,139,250,.10);
  --on-primary:   #1a1025;

  /* Secondary — teal */
  --secondary:    #5eead4;
  --secondary-bg: rgba(94,234,212,.08);

  /* Accent — warm pink */
  --accent:       #f472b6;
  --accent-bg:    rgba(244,114,182,.08);

  /* Text */
  --text:         #e4e4ef;
  --text-dim:     #9898aa;
  --text-faint:   #5e5e72;

  /* States */
  --success:      #34d399;
  --error:        #fb7185;
  --warning:      #fbbf24;

  /* Misc */
  --radius:       14px;
  --radius-sm:    10px;
  --radius-xs:    6px;
  --shadow-sm:    0 2px 8px rgba(0,0,0,.35);
  --shadow-md:    0 4px 20px rgba(0,0,0,.45);
  --shadow-lg:    0 8px 40px rgba(0,0,0,.55);
  --transition:   .25s cubic-bezier(.4,0,.2,1);

  /* Font */
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(167,139,250,.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(94,234,212,.06), transparent),
    var(--bg);
}

/* ─── App Bar ──────────────────────────────────────────────────── */
.app-bar {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  background: rgba(15,15,20,.72);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.app-bar__inner {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px;
}
.app-bar__icon {
  font-size: 28px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.app-bar__title {
  font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em;
}
.app-bar__badge {
  margin-left: auto;
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  padding: 3px 8px; border-radius: 99px;
  background: var(--primary-bg); color: var(--primary);
}

/* ─── Container ────────────────────────────────────────────────── */
.container {
  flex: 1;
  max-width: 860px; width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex; flex-direction: column; gap: 28px;
}

/* ─── Hero ─────────────────────────────────────────────────────── */
.hero { text-align: center; }
.hero__subtitle {
  font-size: .95rem; color: var(--text-dim); margin-bottom: 22px;
}
.hero__subtitle strong { color: var(--text); font-weight: 600; }

/* URL input row */
.url-input-wrap {
  display: flex; align-items: center; gap: 0;
  background: var(--surface-1);
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 6px 6px 6px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.url-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.url-input-wrap__icon { color: var(--text-faint); font-size: 22px; flex-shrink: 0; }
.url-input {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: .95rem; padding: 12px;
  font-family: inherit;
}
.url-input::placeholder { color: var(--text-faint); }

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; cursor: pointer; font-family: inherit; font-weight: 600;
  border-radius: var(--radius-sm); padding: 12px 22px;
  font-size: .9rem; transition: all var(--transition);
  position: relative; overflow: hidden;
}
.btn__icon { font-size: 20px; }
.btn--primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: var(--on-primary);
  box-shadow: 0 4px 16px rgba(167,139,250,.35);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(167,139,250,.45);
}
.btn--primary:active { transform: scale(.97); }
.btn--primary:disabled {
  opacity: .5; cursor: not-allowed; transform: none;
  box-shadow: none;
}

.btn--outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn--outline:hover {
  background: var(--primary-bg);
}

/* ─── Platform Badge ───────────────────────────────────────────── */
.platform-badge {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 8px 16px;
  background: var(--surface-1); border-radius: 99px;
  font-size: .85rem; font-weight: 500;
  animation: fadeSlideUp .35s ease;
}
.platform-badge__icon { font-size: 1.2rem; }
.platform-badge__name { color: var(--text-dim); }

/* ─── Loader ───────────────────────────────────────────────────── */
.loader { text-align: center; padding: 32px 0; }
.loader__ring {
  width: 44px; height: 44px; margin: 0 auto 14px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loader__text { font-size: .85rem; color: var(--text-dim); }

/* ─── Toast ────────────────────────────────────────────────────── */
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-radius: var(--radius-sm);
  background: rgba(251,113,133,.12); color: var(--error);
  font-size: .88rem; font-weight: 500;
  animation: fadeSlideUp .3s ease;
}
.toast__icon { font-size: 22px; }

/* ─── Media Info Card ──────────────────────────────────────────── */
.media-card {
  display: flex; gap: 20px; align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm);
  animation: fadeSlideUp .4s ease;
}
.media-card__thumb-wrap {
  position: relative; flex-shrink: 0;
  width: 180px; border-radius: var(--radius-sm); overflow: hidden;
}
.media-card__thumb {
  width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover;
}
.media-card__duration {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,.75); color: #fff;
  font-size: .7rem; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
}
.media-card__info { flex: 1; min-width: 0; }
.media-card__title {
  font-size: 1rem; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-card__platform {
  display: inline-block; margin-top: 8px;
  font-size: .78rem; color: var(--text-dim);
  background: var(--surface-2); padding: 4px 10px; border-radius: 99px;
}

/* ─── Format Cards ─────────────────────────────────────────────── */
.formats__heading {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 600; color: var(--text-dim);
  margin-bottom: 12px; margin-top: 6px;
}
.formats__heading .material-icons-round { font-size: 20px; color: var(--primary); }
.formats__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px; margin-bottom: 20px;
}

.format-card {
  background: var(--surface-1);
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 16px; cursor: pointer;
  transition: all var(--transition);
  animation: fadeSlideUp .35s ease;
  display: flex; flex-direction: column; gap: 6px;
}
.format-card:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.format-card__label {
  font-size: 1.05rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.format-card__ext {
  display: inline-block;
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px;
  background: var(--secondary-bg); color: var(--secondary);
  width: fit-content;
}
.format-card__meta {
  font-size: .78rem; color: var(--text-faint);
}

/* ─── Progress ─────────────────────────────────────────────────── */
.progress-section {
  padding: 24px;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  animation: fadeSlideUp .35s ease;
}
.progress-section__title {
  display: flex; align-items: center; gap: 8px;
  font-size: .95rem; font-weight: 600; margin-bottom: 16px;
}
.progress-bar-wrap {
  width: 100%; height: 10px;
  background: var(--surface-3);
  border-radius: 99px; overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width .3s ease;
  position: relative;
}
.progress-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent);
  animation: shimmer 1.8s infinite;
}
.progress-stats {
  display: flex; justify-content: space-between;
  margin-top: 10px; font-size: .8rem; color: var(--text-dim);
}

/* ─── Success ──────────────────────────────────────────────────── */
.success-card {
  text-align: center; padding: 40px 24px;
  background: var(--surface-1);
  border: 1px solid rgba(52,211,153,.2);
  border-radius: var(--radius);
  animation: fadeSlideUp .4s ease;
}
.success-card__icon { font-size: 56px; color: var(--success); margin-bottom: 12px; }
.success-card__text {
  font-size: 1.1rem; font-weight: 600; margin-bottom: 20px;
}

/* ─── History ──────────────────────────────────────────────────── */
.history__heading {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 600; color: var(--text-dim); margin-bottom: 12px;
}
.history__heading .material-icons-round { font-size: 20px; color: var(--primary); }
.history__list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.history__empty { font-size: .82rem; color: var(--text-faint); padding: 12px 0; }
.history__item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-1); border: 1px solid var(--surface-3);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: .85rem; transition: background var(--transition);
}
.history__item:hover { background: var(--surface-2); }
.history__item-icon { color: var(--primary); font-size: 20px; flex-shrink: 0; }
.history__item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history__item-size { color: var(--text-dim); font-size: .78rem; flex-shrink: 0; }

/* ─── Footer ───────────────────────────────────────────────────── */
.footer {
  text-align: center; padding: 24px;
  font-size: .78rem; color: var(--text-faint);
  border-top: 1px solid var(--surface-2);
}

/* ─── Utilities ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Animations ───────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1.2s linear infinite; }

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

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 20px 14px 48px; }
  .media-card { flex-direction: column; }
  .media-card__thumb-wrap { width: 100%; }
  .url-input-wrap { flex-wrap: wrap; }
  .url-input { min-width: 0; }
  .btn--primary { width: 100%; justify-content: center; }
  .formats__grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
