body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
  background-color: white;
  color: #333;
  line-height: 1.6;
}

.header {
  text-align: center;
  margin-bottom: 30px;
}

h1 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 2.2em;
}

.subtitle {
  color: #7f8c8d;
  font-size: 1.1em;
  margin-bottom: 30px;
}

.input-section {
  background: #f8f9fa;
  padding: 30px;
  border-radius: 12px;
  border: 2px solid #e1e8ed;
  margin-bottom: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.support-note {
  text-align: center;
  font-size: 0.85em;
  color: #7f8c8d;
  margin: 15px 0 0 0;
  line-height: 1.4;
}

#urlInput {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s ease;
}

#urlInput:focus {
  outline: none;
  border-color: #3498db;
}

.input-container {
  position: relative;
  display: flex; /* Aligns input and button if button were inside */
  flex-grow: 1; /* Allows input container to take available space */
}

#urlInput {
  padding-right: 30px; /* Space for the clear icon */
  /* Ensure existing width/flex properties are maintained or adjusted */
  width: 100%; /* Make sure input takes full width of its container */
}

.clear-input-icon {
  position: absolute;
  right: 15px; /* Increased for more space from edge */
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 20px;
  color: #aaa;
  line-height: 1; /* Ensure consistent vertical alignment */
  display: none; /* Initially hidden, JS controls visibility */
}

.clear-input-icon:hover {
  color: #333;
}

/* General styles for buttons in the input section */
.input-section button {
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 10px; /* Space between buttons */
}

.input-section button:first-of-type {
  margin-left: 0; /* No left margin for the first button in the group */
}

#extractBtn {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

#extractBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

#extractBtn:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #7f8c8d;
  display: none;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

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

#videoThumbnail {
  display: none; /* Initially hidden, JS will make it block */
  max-width: 240px;
  margin-bottom: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.results {
  display: none;
}

.video-info {
  background: white;
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.video-title {
  font-size: 1.3em;
  font-weight: 600;
  color: #2c3e50;
}

.video-meta {
  color: #7f8c8d;
  font-size: 0.9em;
  margin-bottom: 0px;
}

.formats-section {
  margin-top: 0;
}

.format-list {
  display: grid;
  gap: 12px;
}

.format-item {
  display: flex;
  flex-direction: column;
  padding: 10px 15px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  transition: all 0.2s ease;
}

.format-item-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.format-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.format-details {
  flex: 1;
}

.format-type {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

.format-specs {
  font-size: 0.85em;
  color: #7f8c8d;
}

.download-btn {
  /* Initial background set by JavaScript based on section type */
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(39, 174, 96, 0.3);
}

.note {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 8px;
  padding: 15px;
  margin-top: 20px;
  font-size: 0.9em;
  color: #856404;
}

.section-header {
  font-size: 1.2em;
  font-weight: 700;
  padding: 10px 15px;
  margin: 20px 0 5px 0;
  border-radius: 6px;
  color: #ffffff; /* Default white text, assuming dark backgrounds */
  /* Default/Fallback background and border, if no data-section-type matches */
  background-color: #7f8c8d;
  border-bottom: 2px solid #607070;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Subtle shadow for a bit of lift */
}

.section-header[data-section-type="high-quality"] {
  background-color: #8e44ad; /* Purple */
  border-bottom-color: #703080; /* Darker purple */
}

.section-header[data-section-type="video-audio"] {
  background-color: #27ae60; /* Green */
  border-bottom-color: #1f8b4c; /* Darker green */
}

.section-header[data-section-type="video-only"] {
  background-color: #d35400; /* Darker Orange */
  border-bottom-color: #a04000; /* Even darker orange */
}

.section-header[data-section-type="audio-only"] {
  background-color: #2980b9; /* Blue */
  border-bottom-color: #1f618d; /* Darker blue */
}

.section-header[data-section-type="other"] {
  background-color: #7f8c8d; /* Slate/Grey (same as default) */
  border-bottom-color: #607070; /* Darker Slate/Grey */
}

footer {
  text-align: center;
  padding: 30px 20px;
  margin-top: 40px;
  font-size: 0.8em;
  color: #777;
  border-top: 1px solid #eee;
}

footer p {
  margin: 0;
  line-height: 1.4;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  body {
    max-width: 100%;
    padding: 20px 15px;
  }

  h1 {
    font-size: 1.8em;
  }

  .subtitle {
    font-size: 1em;
  }

  .header {
    margin-bottom: 30px;
  }

  .input-section {
    padding: 20px 15px;
    margin-bottom: 20px;
  }

  .input-group {
    flex-direction: column;
    gap: 15px;
  }

  .input-container {
    width: 100%;
  }

  #urlInput {
    font-size: 16px; /* Prevents zoom on iOS */
    width: 100%;
    box-sizing: border-box;
  }

  #extractBtn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
  }

  .video-info {
    padding: 20px 15px;
  }

  .video-title {
    font-size: 1.1em;
    line-height: 1.4;
  }

  .format-item {
    padding: 15px;
  }

  .format-item-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .format-details {
    width: 100%;
  }

  .download-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
  }

  .section-header {
    font-size: 1.1em;
    padding: 8px 12px;
    margin: 20px 0 10px 0;
  }

  #videoThumbnail {
    max-width: 100%;
    height: auto;
  }

  .note {
    padding: 12px;
    font-size: 0.85em;
  }

  footer {
    margin-top: 30px; /* Increase for better visual balance with header spacing */
  }
}

@media (max-width: 480px) {
  body {
    padding: 15px 10px;
  }

  h1 {
    font-size: 1.6em;
  }

  .input-section {
    padding: 15px 10px;
  }

  .video-info {
    padding: 15px 10px;
  }

  .format-item {
    padding: 12px;
  }

  .clear-input-icon {
    right: 10px;
  }

  .progress-container {
    margin-top: 8px;
  }
}

/* Progress Bar Styles */
.progress-container {
  margin-top: 10px;
  margin-bottom: 10px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.phase-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 2px 4px;
  background: transparent;
  border-radius: 6px;
}

.phase-icon {
  font-size: 16px;
}

.phase-label {
  font-weight: 600;
  color: #2c3e50;
  min-width: 85px;
}

.phase-status {
  color: #7f8c8d;
  font-weight: 500;
}

.progress-bar-bg {
  width: 100%;
  height: 18px;
  background: linear-gradient(135deg, #ecf0f1, #d5dbdb);
  border-radius: 9px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(135deg, #3498db, #2980b9);
  border-radius: 9px;
  transition: width 0.3s ease;
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

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

.progress-text {
  margin-top: 6px;
  font-size: 13px;
  color: #555;
  text-align: left;
  font-weight: 500;
}

/* Cancel Confirmation Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-dialog {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.2s ease-out;
}

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

.modal-title {
  font-size: 1.3em;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 15px;
}

.modal-message {
  font-size: 1em;
  color: #555;
  margin-bottom: 25px;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn-cancel {
  background: #e74c3c;
  color: white;
}

.modal-btn-cancel:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

.modal-btn-keep {
  background: #ecf0f1;
  color: #2c3e50;
}

.modal-btn-keep:hover {
  background: #bdc3c7;
}

@media (max-width: 480px) {
  .modal-dialog {
    padding: 20px;
  }

  .modal-buttons {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .modal-btn {
    width: 100%;
  }
}
