/* VIDEA — Premium Minimalist Video Downloader */

:root {
  --bg-color: #0a0a0a;
  --bg-card: rgba(24, 24, 27, 0.4);
  --bg-card-hover: rgba(39, 39, 42, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.25);

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;

  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --sky: #38bdf8;
  --indigo: #818cf8;
  --green: #4ade80;
  --yellow: #facc15;
  --red: #f43f5e;

  --font-sans: 'Inter', 'Noto Sans Telugu', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

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

/* The hidden attribute must always win over component display rules */
[hidden] { display: none !important; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8vh;
  padding-bottom: 50px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  width: 100%;
  max-width: 580px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
}

/* ============ HEADER ============ */
.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
}

.logo svg {
  width: 34px;
  height: 34px;
  color: var(--sky);
}

.logo-text {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  white-space: nowrap;
}

.logo-subtext {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--text-muted);
}

/* Language switch */
.lang-switch {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-70%);
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 99px;
  padding: 3px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.lang-btn:hover {
  color: var(--text-main);
}

.lang-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--sky);
}

/* ============ MAIN CONTENT ============ */
.main-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 8px;
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 12px 48px rgba(56, 189, 248, 0.15);
}

.input-field-group {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  min-width: 0;
}

.input-icon {
  width: 20px;
  height: 20px;
  color: var(--text-faint);
  margin-left: 14px;
  flex-shrink: 0;
}

#urlInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  padding: 14px 12px;
  min-width: 0;
}

#urlInput::placeholder {
  color: var(--text-faint);
  font-weight: 500;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

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

.primary-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.primary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ============ RESULT CARD ============ */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

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

.video-meta-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.video-thumb-wrapper {
  width: 110px;
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: #000;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.video-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dur-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.src-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--sky);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
}

.video-meta-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

#videoTitle {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-row {
  font-size: 12px;
  color: var(--text-muted);
}

.card-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 16px 0;
}

.options-section {
  margin-bottom: 18px;
}

.options-section:last-child {
  margin-bottom: 0;
}

.options-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* ============ QUALITY GRID ============ */
.q-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.q-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
  color: var(--text-main);
  font-family: var(--font-sans);
  text-align: left;
}

.q-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.q-chip.best {
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.05);
}

.q-chip.best:hover {
  border-color: rgba(250, 204, 21, 0.55);
}

.q-res {
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.q-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.q-tag.hd { background: rgba(56, 189, 248, 0.15); color: var(--sky); }
.q-tag.ds { background: rgba(74, 222, 128, 0.13); color: var(--green); }
.q-tag.fps { background: rgba(129, 140, 248, 0.15); color: var(--indigo); }
.q-tag.best-tag { background: rgba(250, 204, 21, 0.15); color: var(--yellow); }

.q-size {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: auto;
}

/* ============ OPTION CARDS (audio / whatsapp / zip) ============ */
.opt-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dl-option-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
  font-family: var(--font-sans);
  text-align: left;
  width: 100%;
}

.dl-option-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.dl-option-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dl-option-icon svg {
  width: 20px;
  height: 20px;
}

.dl-option-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dl-option-info strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.dl-option-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.dl-option-arrow {
  color: var(--text-faint);
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.dl-option-arrow svg {
  width: 20px;
  height: 20px;
}

.dl-option-card:hover .dl-option-arrow {
  color: var(--text-main);
}

/* Individual colors */
.best .dl-option-icon { color: var(--yellow); }
.fast .dl-option-icon { color: var(--sky); }
.audio .dl-option-icon { color: var(--red); }
.audio.saver .dl-option-icon { color: #fb7185; }
.wa .dl-option-icon { color: var(--green); }
.wa.alt .dl-option-icon { color: #34d399; }

/* ZIP button */
.zip-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: rgba(129, 140, 248, 0.07);
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--indigo);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.zip-btn:hover {
  background: rgba(129, 140, 248, 0.13);
  border-color: rgba(129, 140, 248, 0.45);
  transform: translateY(-1px);
}

.zip-btn .dl-option-arrow { color: var(--indigo); }
.zip-btn:hover .dl-option-arrow { color: var(--text-main); }

/* ============ CAROUSEL SLIDES ============ */
.slides-note {
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 8px 2px 10px;
}

.carousel-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.slide-tile {
  width: 88px;
  height: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: #000;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.slide-tile:hover {
  border-color: rgba(56, 189, 248, 0.6);
  transform: translateY(-2px);
}

.slide-num {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide-kind {
  position: absolute;
  bottom: 5px;
  right: 7px;
  color: #fff;
  font-size: 11px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* ============ STATUS POPUP (MODAL) ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
  animation: overlayIn 0.25s ease forwards;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: rgba(24, 24, 27, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.status-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.status-meta { min-width: 0; }

.status-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.status-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}

.status-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--sky);
  flex-shrink: 0;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

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

.progress-fill.err {
  background: linear-gradient(90deg, #f43f5e, #fb7185);
}

.status-stats {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-height: 0;
}

.status-stats:empty { display: none; }

/* Done buttons */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.manual-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.manual-save:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: var(--green);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-btn:hover {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.5);
}

/* WhatsApp parts */
.parts-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.parts-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.part-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(74, 222, 128, 0.05);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s ease;
  cursor: pointer;
}

.part-btn:hover {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.45);
}

.part-btn em {
  font-style: normal;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
}

.part-size {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.save-all-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.save-all-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Trust line */
.trust-line {
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.6;
  max-width: 440px;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(24, 24, 27, 0.9);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast:not(.ok) {
  border-color: rgba(244, 63, 94, 0.35);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 500px) {
  body { padding-top: 5vh; }

  .search-bar {
    flex-direction: column;
    padding: 12px;
  }
  .primary-btn { width: 100%; }
  .input-field-group { width: 100%; }
  .input-icon { margin-left: 6px; }

  /* Language pills flow above the brand — no overlap with the longer name */
  .lang-switch {
    position: static;
    transform: none;
    align-self: flex-end;
    margin-bottom: 2px;
  }
  .lang-btn { padding: 4px 8px; font-size: 11px; }
  .logo svg { width: 28px; height: 28px; }
  .logo-text { font-size: 25px; }

  .q-grid { grid-template-columns: repeat(2, 1fr); }
  .result-card { padding: 16px; }

  /* Bottom-sheet style popup on phones */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
    animation: sheetIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  @keyframes sheetIn {
    from { opacity: 0; transform: translateY(60%); }
    to { opacity: 1; transform: translateY(0); }
  }
}
