/* TikTok Downloader Plugin — All scoped to #ttdl-widget */

#ttdl-widget, #ttdl-widget * {
  box-sizing: border-box !important;
  font-family: 'Poppins', sans-serif;
}

#ttdl-widget {
  padding: 20px 0;
  width: 100%;
}

#ttdl-widget .ttdl-wrapper {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── SEARCH BAR ── */
#ttdl-widget .ttdl-search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: #ffffff;
  border: 2px solid #e8192c;
  border-radius: 10px;
  overflow: hidden;
}

#ttdl-widget .ttdl-search-top {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

#ttdl-widget #ttdl-urlInput {
  flex: 1 !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  font-size: 0.95rem !important;
  color: #111 !important;
  padding: 15px 16px !important;
  background: #ffffff !important;
  min-width: 0 !important;
  border-radius: 0 !important;
  height: auto !important;
  line-height: normal !important;
  margin: 0 !important;
}

#ttdl-widget #ttdl-urlInput::placeholder { color: #999 !important; }

#ttdl-widget #ttdl-pasteBtn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  padding: 6px 14px !important;
  margin: 7px 8px 7px 0 !important;
  background: #1e1e1e !important;
  border: 1.5px solid #555 !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  color: #fff !important;
  transition: all 0.2s !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  line-height: 1 !important;
  text-decoration: none !important;
}

#ttdl-widget #ttdl-pasteBtn:hover { background: #2a2a2a !important; }
#ttdl-widget #ttdl-pasteBtn.clear-mode { border-color: #e8192c !important; color: #e8192c !important; background: #1a0505 !important; }
#ttdl-widget #ttdl-pasteBtn svg { display: block !important; }

#ttdl-widget #ttdl-searchBtn {
  padding: 0 24px !important;
  background: #e8192c !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  transition: background 0.2s !important;
  flex-shrink: 0 !important;
  min-width: 120px !important;
  border-radius: 0 !important;
  margin: 0 !important;
  text-decoration: none !important;
}

#ttdl-widget #ttdl-searchBtn:hover { background: #c8111f !important; }
#ttdl-widget #ttdl-searchBtn:disabled { background: #888 !important; cursor: not-allowed !important; }

#ttdl-widget #ttdl-searchBtnContent {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  line-height: 1 !important;
}

/* Mobile */
@media (max-width: 520px) {
  #ttdl-widget .ttdl-search-bar {
    background: transparent !important;
    border: none !important;
    gap: 10px !important;
  }
  #ttdl-widget .ttdl-search-top {
    flex: 1 1 100% !important;
    background: #ffffff !important;
    border: 2px solid #e8192c !important;
    border-radius: 10px !important;
    overflow: hidden !important;
  }
  #ttdl-widget #ttdl-searchBtn {
    flex: 1 1 100% !important;
    width: 100% !important;
    padding: 14px !important;
    border-radius: 10px !important;
    min-width: unset !important;
  }
}

/* ── LOADING ── */
#ttdl-widget .ttdl-loading {
  text-align: center;
  padding: 40px 20px;
  background: #111;
  border-radius: 16px;
  border: 1px solid #1e1e1e;
}

#ttdl-widget .ttdl-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #1e1e1e;
  border-top-color: #e8192c;
  border-radius: 50%;
  animation: ttdl-spin 0.8s linear infinite;
  margin: 0 auto 14px;
}

@keyframes ttdl-spin { to { transform: rotate(360deg); } }
#ttdl-widget .ttdl-loading p { color: #aaa; font-size: 0.88rem; margin: 0; }

/* ── ERROR ── */
#ttdl-widget .ttdl-error {
  background: #1a0505;
  border: 1.5px solid #e8192c;
  border-radius: 12px;
  padding: 14px 18px;
  color: #f87171;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ── RESULT CARD ── */
#ttdl-widget .ttdl-result {
  background: #111;
  border-radius: 16px;
  padding: 22px;
  border: 1px solid #1e1e1e;
}

#ttdl-widget .ttdl-video-info {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 0 0 20px 0;
  padding: 0;
  border: none;
}

#ttdl-widget .ttdl-thumb {
  position: relative;
  flex-shrink: 0;
  width: 160px;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

@media (max-width: 520px) {
  #ttdl-widget .ttdl-thumb {
    width: 120px;
    height: 90px;
  }
}

#ttdl-widget .ttdl-thumb img,
#ttdl-widget .ttdl-thumb video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border: none !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
}

/* play overlay removed - using actual video element now */

#ttdl-widget .ttdl-meta { flex: 1; min-width: 0; }

#ttdl-widget .ttdl-meta h3 {
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  color: #eee !important;
  margin: 0 0 4px 0 !important;
  padding: 0 !important;
  line-height: 1.5 !important;
  border: none !important;
  background: none !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

#ttdl-widget .ttdl-author {
  color: #777;
  font-size: 0.8rem;
  margin: 0 0 8px 0;
}

#ttdl-widget .ttdl-stats {
  display: flex;
  gap: 14px;
  font-size: 0.76rem;
  color: #777;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
}

#ttdl-widget .ttdl-stats span { margin: 0; padding: 0; }

/* ── FORMAT SELECTOR ── */
#ttdl-widget .ttdl-format-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#ttdl-widget .ttdl-formats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px 0;
  padding: 0;
}

#ttdl-widget .ttdl-fmt-btn {
  flex: 1 !important;
  min-width: 120px !important;
  padding: 11px 13px !important;
  background: #161616 !important;
  border: 2px solid #222 !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  color: #ccc !important;
  text-align: left !important;
  transition: all 0.18s !important;
  text-decoration: none !important;
  margin: 0 !important;
  line-height: normal !important;
}

#ttdl-widget .ttdl-fmt-btn:hover { border-color: #333 !important; background: #1c1c1c !important; }
#ttdl-widget .ttdl-fmt-btn.active { border-color: #e8192c !important; background: #160606 !important; }

#ttdl-widget .ttdl-fmt-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 3px 0;
  padding: 0;
}

#ttdl-widget .ttdl-fmt-title { font-size: 0.87rem; font-weight: 700; color: #eee; }

#ttdl-widget .ttdl-badge {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e8192c;
  color: #fff;
  text-transform: uppercase;
}

#ttdl-widget .badge-mp3 { background: #0a7a6a; }
#ttdl-widget .badge-hd  { background: #1d4ed8; }
#ttdl-widget .ttdl-fmt-sub { font-size: 0.69rem; color: #555; margin: 0; padding: 0; }

/* ── DOWNLOAD BTN ── */
#ttdl-widget #ttdl-dlBtn {
  width: 100% !important;
  padding: 14px !important;
  background: #161616 !important;
  border: 2px solid #2a2a2a !important;
  border-radius: 10px !important;
  color: #ccc !important;
  font-size: 0.97rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  line-height: 1 !important;
  transition: all 0.2s !important;
  text-decoration: none !important;
  margin: 0 !important;
}

#ttdl-widget #ttdl-dlBtn:hover:not(:disabled) { background: #e8192c !important; border-color: #e8192c !important; color: #fff !important; }
#ttdl-widget #ttdl-dlBtn:disabled { opacity: 0.5 !important; cursor: not-allowed !important; }

/* ── PROGRESS ── */
#ttdl-widget .ttdl-progress-wrap {
  margin-top: 12px;
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  height: 6px;
}

#ttdl-widget .ttdl-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e8192c, #ff6b6b);
  border-radius: 8px;
  transition: width 0.3s ease;
}

#ttdl-widget .ttdl-progress-status {
  font-size: 0.75rem;
  color: #777;
  margin-top: 7px;
  text-align: center;
}

/* ── ANOTHER BTN ── */
#ttdl-widget .ttdl-another {
  text-align: center;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #1a1a1a;
}

#ttdl-widget #ttdl-anotherBtn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 10px 30px !important;
  background: transparent !important;
  color: #5bc8e0 !important;
  border: 2px solid #5bc8e0 !important;
  border-radius: 50px !important;
  cursor: pointer !important;
  font-size: 0.87rem !important;
  font-weight: 600 !important;
  transition: all 0.22s !important;
  text-decoration: none !important;
  margin: 0 !important;
  line-height: 1 !important;
}

#ttdl-widget #ttdl-anotherBtn:hover { background: #5bc8e0 !important; color: #0d0d0d !important; }
