* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Light Mode (Default) */
body.light-mode {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.light-mode .container {
  background: white;
  color: #333;
}

body.light-mode input[type="text"] {
  background: white;
  border-color: #e0e0e0;
  color: #333;
}

body.light-mode .quality-selector select {
  background: white;
  border-color: #e0e0e0;
  color: #333;
}

body.light-mode .video-info {
  background: #f8f9fa;
}

body.light-mode .progress-bar-container {
  background: #e0e0e0;
}

body.light-mode .progress-bar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Dark Mode */
body.dark-mode {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .container {
  background: #1e1e2f;
  color: #e0e0e0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body.dark-mode input[type="text"] {
  background: #2d2d44;
  border-color: #404060;
  color: #e0e0e0;
}

body.dark-mode input[type="text"]:focus {
  border-color: #7b2eda;
}

body.dark-mode .quality-selector select {
  background: #2d2d44;
  border-color: #404060;
  color: #e0e0e0;
}

body.dark-mode .format-badge.mp4 {
  background: #1e3a5f;
  color: #89c2ff;
}

body.dark-mode .format-badge.mp3 {
  background: #4a2b5f;
  color: #e0aaff;
}

body.dark-mode .video-info {
  background: #2a2a40;
}

body.dark-mode .video-details h3 {
  color: #e0e0e0;
}

body.dark-mode .video-details p {
  color: #a0a0c0;
}

body.dark-mode .progress-bar-container {
  background: #404060;
}

body.dark-mode .progress-bar {
  background: linear-gradient(135deg, #7b2eda 0%, #a55eea 100%);
}

body.dark-mode .error {
  background: #442222;
  color: #ffaaaa;
  border-left-color: #ff5555;
}

body.dark-mode .success {
  background: #224422;
  color: #aaffaa;
  border-left-color: #55ff55;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.theme-btn {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s;
}

.theme-btn:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.3);
}

.light-mode .light-icon,
.dark-mode .dark-icon {
  display: inline-block;
}

.light-mode .dark-icon,
.dark-mode .light-icon {
  display: none;
}

/* Container */
.container {
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 600px;
  width: 100%;
}

h1 {
  font-size: 2.2em;
  margin-bottom: 10px;
  text-align: center;
}

.subtitle {
  text-align: center;
  margin-bottom: 30px;
  font-size: 1.1em;
  opacity: 0.8;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

/* URL Input with Search Button */
.url-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.url-input-wrapper input[type="text"] {
  flex: 1;
  padding: 15px 20px;
  border: 2px solid;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s;
  width: 100%;
}

.url-input-wrapper input[type="text"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.search-btn {
  background: linear-gradient(135deg, #4a90e2 0%, #3570b2 100%);
  color: white;
  border: none;
  padding: 15px 25px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 110px;
  justify-content: center;
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(74, 144, 226, 0.4);
}

.search-btn:active {
  transform: translateY(0);
}

.search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.search-icon {
  font-size: 18px;
}

.search-loader {
  font-size: 18px;
}

/* Dark mode search button */
body.dark-mode .search-btn {
  background: linear-gradient(135deg, #4a2b5f 0%, #6b3f8a 100%);
}

body.dark-mode .search-btn:hover {
  box-shadow: 0 5px 15px rgba(107, 63, 138, 0.4);
}

/* Format Selector */
.format-selector {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.format-option {
  cursor: pointer;
}

.format-option input[type="radio"] {
  display: none;
}

.format-badge {
  display: inline-block;
  padding: 10px 25px;
  border-radius: 30px;
  font-weight: 600;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.format-badge.mp4 {
  background: #e3f2fd;
  color: #1976d2;
}

.format-badge.mp3 {
  background: #f3e5f5;
  color: #7b1fa2;
}

input[type="radio"]:checked + .format-badge.mp4 {
  background: #1976d2;
  color: white;
  border-color: #0d47a1;
}

input[type="radio"]:checked + .format-badge.mp3 {
  background: #7b1fa2;
  color: white;
  border-color: #4a0072;
}

/* Quality Selector */
.quality-selector {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  border-radius: 10px;
}

.quality-selector label {
  font-weight: 600;
}

.quality-select-wrapper {
  flex: 1;
  position: relative;
}

.quality-selector select {
  width: 100%;
  padding: 10px;
  border: 2px solid;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.3s;
}

.quality-selector select:focus {
  outline: none;
  border-color: #764ba2;
}

.quality-selector select:disabled {
  opacity: 0.6;
  cursor: wait;
}

.select-loader {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #764ba2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Download Button */
#downloadBtn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#downloadBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(118, 75, 162, 0.4);
}

#downloadBtn:active:not(:disabled) {
  transform: translateY(0);
}

#downloadBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#downloadBtn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.btn-loader {
  font-size: 20px;
}

/* Video Info */
.video-info {
  display: flex;
  gap: 20px;
  padding: 20px;
  border-radius: 12px;
  margin: 20px 0;
  align-items: center;
}

.video-info img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
}

.video-details {
  flex: 1;
}

.video-details h3 {
  margin-bottom: 5px;
  font-size: 1.1em;
}

.video-details p {
  font-size: 0.9em;
  opacity: 0.8;
}

.qualities-list {
  margin-top: 5px;
  font-size: 0.85em;
  color: #764ba2 !important;
}

/* Progress Section */
.progress-section {
  margin-top: 20px;
  padding: 20px;
  border-radius: 12px;
  background: rgba(118, 75, 162, 0.1);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
}

.progress-bar-container {
  width: 100%;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  transition: width 0.3s ease;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.9em;
  opacity: 0.8;
}

/* Loading Spinner */
.loading {
  text-align: center;
  margin-top: 20px;
}

.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #764ba2;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error and Success Messages */
.error, .success {
  padding: 12px;
  border-radius: 8px;
  margin-top: 20px;
  text-align: center;
  border-left: 4px solid;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error {
  background: #fee;
  color: #c33;
  border-left-color: #c33;
}

.success {
  background: #e8f5e8;
  color: #2e7d32;
  border-left-color: #2e7d32;
}

.hidden {
  display: none;
}

/* Responsive design for mobile */
@media (max-width: 600px) {
  .container {
    padding: 20px;
  }
  
  h1 {
    font-size: 1.8em;
  }
  
  .url-input-wrapper {
    flex-direction: column;
  }
  
  .search-btn {
    width: 100%;
  }
  
  .search-text {
    display: inline;
  }
  
  .format-selector {
    flex-direction: column;
    align-items: stretch;
  }
  
  .format-option {
    width: 100%;
  }
  
  .format-badge {
    display: block;
    text-align: center;
  }
  
  .quality-selector {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .quality-select-wrapper {
    width: 100%;
  }
  
  .video-info {
    flex-direction: column;
    text-align: center;
  }
  
  .video-info img {
    width: 100%;
    height: auto;
    max-height: 180px;
  }
  
  .theme-toggle {
    top: 10px;
    right: 10px;
  }
  
  .theme-btn {
    padding: 8px 15px;
    font-size: 16px;
  }
}

/* Loading state for search button */
.search-btn .search-text.hidden,
.search-btn .search-loader.hidden {
  display: none;
}

/* Focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #764ba2;
  outline-offset: 2px;
}

/* Smooth transitions */
.progress-bar,
.spinner,
.spinner-small {
  will-change: transform;
}

/* Custom scrollbar for quality select */
.quality-selector select {
  scrollbar-width: thin;
  scrollbar-color: #764ba2 #f0f0f0;
}

.quality-selector select::-webkit-scrollbar {
  width: 8px;
}

.quality-selector select::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 4px;
}

.quality-selector select::-webkit-scrollbar-thumb {
  background: #764ba2;
  border-radius: 4px;
}

body.dark-mode .quality-selector select::-webkit-scrollbar-track {
  background: #2d2d44;
}

body.dark-mode .quality-selector select::-webkit-scrollbar-thumb {
  background: #a55eea;
}