/* Basic Reset & Styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.6;
  background: linear-gradient(135deg, #f6f9fc, #e6eef7);
  color: #333;
  padding: 20px;
  min-height: 100vh;
}

.container {
  position: relative; /* Needed for drop overlay positioning */
  max-width: 950px;
  margin: 20px auto;
  background-color: #fff;
  padding: 35px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border: 2px dashed transparent; /* For drag-over effect */
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.container.drag-over {
  border-color: #4361ee;
  background-color: #f0f7ff;
  transform: scale(1.01);
  box-shadow: 0 15px 35px rgba(67, 97, 238, 0.15);
}

/* Drop Overlay */
.drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(67, 97, 238, 0.85);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  font-weight: bold;
  border-radius: 16px; /* Match container */
  pointer-events: none; /* Allow clicks through */
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.drop-overlay::before {
  content: "📁";
  font-size: 2.5rem;
  margin-right: 15px;
}

.container.drag-over .drop-overlay {
  opacity: 1;
}

h1,
h2 {
  color: #1e3a8a;
  margin-bottom: 15px;
  text-align: center;
}

h1 {
  font-size: 2.4rem;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #4361ee, #3a0ca3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 10px rgba(67, 97, 238, 0.1);
}

p {
  margin-bottom: 25px;
  text-align: center;
  color: #555;
  font-size: 1.15rem;
  line-height: 1.5;
}

/* Controls Section */
.controls {
  background-color: #f8fafc;
  padding: 30px;
  border-radius: 12px;
  margin-bottom: 35px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.file-input-section {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.file-input-wrapper {
  display: inline-block; /* Align label and count */
  margin-right: 15px;
}

.file-label {
  display: inline-block;
  padding: 14px 28px;
  background: linear-gradient(135deg, #4361ee, #3a0ca3);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}

.file-label:hover {
  background: linear-gradient(135deg, #3a0ca3, #4361ee);
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(67, 97, 238, 0.4);
}

.file-label:active {
  transform: translateY(-1px);
}

#fileInput {
  display: none; /* Hide the default input */
}

#fileCount {
  display: inline-block; /* Keep on same line */
  margin-top: 10px;
  font-size: 1em;
  color: #4b5563;
  margin-right: 5px;
  font-weight: 500;
}

.file-input-section small {
  display: block;
  margin-top: 12px;
  font-size: 0.95em;
  color: #64748b;
}

/* Settings */
.settings {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 25px;
  margin-bottom: 30px;
  align-items: flex-start; /* Align tops of groups */
}

.slider-group,
.compression-group {
  flex: 1; /* Equal width */
  min-width: 250px; /* Prevent excessive shrinking */
  background-color: #fff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.slider-group:hover,
.compression-group:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.slider-group label,
.compression-toggle label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  color: #1e293b;
}

.slider-group label span {
  font-weight: normal;
  color: #ef4444;
}

.slider-group input[type="range"] {
  width: 100%;
  cursor: pointer;
  height: 8px;
  background: linear-gradient(to right, #4361ee, #a5b4fc);
  border-radius: 5px;
  outline: none;
  appearance: none; /* Override default look */
  -webkit-appearance: none;
  margin-top: 8px;
}

.slider-group.disabled {
  opacity: 0.7;
  pointer-events: none;
}

.slider-group.disabled label {
  color: #94a3b8;
}

.slider-group.disabled input[type="range"] {
  cursor: not-allowed;
}

/* Style range thumb (cross-browser) */
.slider-group input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: #4361ee;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  border: 2px solid white;
}

.slider-group input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: #4361ee;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Compression Toggle */
.compression-toggle {
  margin-bottom: 15px; /* Space before slider */
  display: flex;
  align-items: center;
}

.compression-toggle input[type="checkbox"] {
  margin-right: 10px;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  accent-color: #4361ee;
}

.compression-toggle label {
  display: inline-block; /* Keep on same line */
  font-weight: 500; /* Less emphasis */
  color: #1e293b;
  cursor: pointer;
}

/* Buttons */
button {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.1em;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

button:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669, #10b981);
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(16, 185, 129, 0.3);
}

button:active:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  background-color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}

#downloadAllBtn {
  margin-top: 20px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  padding: 14px;
  font-size: 1.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

#downloadAllBtn::before {
  content: "📦";
  font-size: 1.2em;
}

#downloadAllBtn:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  box-shadow: 0 6px 15px rgba(59, 130, 246, 0.3);
}

#outputArea {
  background-color: #f8fafc;
  padding: 30px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

#progressMessage {
  background-color: #ebf5ff;
  color: #1e40af;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 15px;
  text-align: center;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#progressMessage::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  animation: progress-animation 1.5s infinite linear;
  width: 100%;
}

@keyframes progress-animation {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

#resultsList {
  list-style-type: none;
  margin-top: 20px;
  max-height: 400px;
  overflow-y: auto;
  border-radius: 8px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.05);
}

.file-list-item {
  background-color: white;
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.file-list-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.file-list-item:last-child {
  margin-bottom: 0;
}

.file-list-item .file-info {
  flex: 2;
  min-width: 200px;
}

.file-list-item .file-info .filename {
  font-weight: 600;
  color: #1e293b;
  display: block;
  font-size: 1.05em;
  margin-bottom: 5px;
  word-break: break-all;
  max-width: 100%;
}

.file-list-item .file-info .filesize {
  font-size: 0.9em;
  color: #64748b;
  display: block;
}

.file-list-item .status-area {
  flex: 2;
  min-width: 200px;
  padding: 0 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.file-list-item .status-area .status {
  font-weight: 600;
  margin-bottom: 5px;
}

.file-list-item .status-area .output-details {
  margin-top: 5px;
}

.file-list-item .status-area .output-filename {
  font-size: 0.95em;
  color: #0f172a;
  display: block;
  font-weight: 500;
  margin-bottom: 3px;
  word-break: break-all;
  max-width: 100%;
}

.file-list-item .status-area .output-size {
  font-size: 0.9em;
  color: #64748b;
  display: block;
  margin-bottom: 3px;
}

.file-list-item .status-area .reduction {
  font-size: 0.9em;
  font-weight: 600;
  color: #10b981;
  background-color: rgba(16, 185, 129, 0.1);
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-block;
}

.file-list-item .actions {
  flex: 1;
  min-width: 100px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.file-list-item .actions .download-link {
  color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.1);
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95em;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.file-list-item .actions .download-link::before {
  content: "📥";
  font-size: 1.1em;
}

.file-list-item .actions .download-link:hover {
  background-color: rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
  color: #1d4ed8;
}

.file-list-item .error-message {
  color: #e74c3c;
  font-size: 0.9em;
  margin-top: 5px;
  display: block;
  background-color: rgba(231, 76, 60, 0.1);
  padding: 5px 10px;
  border-radius: 5px;
}

.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .settings {
    flex-direction: column;
    gap: 20px;
  }

  .slider-group,
  .compression-group {
    min-width: 100%;
  }

  .file-list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .file-list-item .file-info,
  .file-list-item .status-area {
    width: 100%;
    padding: 0;
    margin-bottom: 15px;
  }

  .file-list-item .actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 20px;
    margin: 10px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .file-label {
    padding: 12px 20px;
    font-size: 0.95em;
  }

  button {
    padding: 14px;
    font-size: 1em;
  }

  .controls {
    padding: 20px;
  }

  #outputArea {
    padding: 20px;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.file-list-item .status-area .status.processing {
  color: #3498db;
  animation: pulse 1.5s infinite;
}
