/* Modern Reset & Base */
* {
  box-sizing: border-box;
}

.img-tool-container {
  width: 100%;
  max-width: 1100px;
  margin: 40px auto;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 20px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.03);
  padding: 32px 36px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: #1e293b;
}

.img-tool-container h2 {
  padding-top: 0;
  margin: 0 0 20px 0;
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  font-size: 1.8em;
  letter-spacing: -0.02em;
}

/* Instructions */
.instructions {
  background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
  border-left: 4px solid #2563eb;
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-size: 0.9em;
  line-height: 1.5;
  color: #1e40af;
}

.instructions strong {
  display: block;
  margin-bottom: 4px;
  color: #1e3a8a;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.tabs::-webkit-scrollbar {
  height: 6px;
}

.tabs::-webkit-scrollbar-track {
  background: transparent;
}

.tabs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.tab-btn,
.add-tab-btn {
  flex: 0 0 auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn {
  background: #f1f5f9;
  border: 2px solid transparent;
  border-radius: 12px 12px 0 0;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
  color: #64748b;
  position: relative;
  overflow: hidden;
  font-size: 0.9em;
}

.tab-btn::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.tab-btn:hover {
  background: #e2e8f0;
  color: #475569;
}

.tab-btn.active {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.tab-btn.active::before {
  transform: scaleX(1);
}

.tab-btn .close {
  margin-left: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
  font-size: 1.2em;
  line-height: 1;
}

.tab-btn .close:hover {
  color: #fca5a5;
}

.tab-btn:not(.active) .close {
  color: #ef4444;
}

.add-tab-btn {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.add-tab-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

/* Batch Panels */
.batch-panel {
  display: none;
  animation: fadeIn 0.4s ease;
}

.batch-panel.active {
  display: block;
}

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

/* Drop Area */
.drop-area {
  border: 3px dashed #cbd5e1;
  border-radius: 14px;
  padding: 24px 20px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  transition: all 0.3s ease;
  position: relative;
}

.drop-area.dragover {
  border-color: #06b6d4;
  background: linear-gradient(135deg, #ecfeff 0%, #e0f2fe 100%);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.1);
  transform: scale(1.01);
}

.drop-message {
  color: #64748b;
  font-size: 1em;
  font-weight: 500;
  margin-bottom: 16px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.drop-message::before {
  content: "📁";
  font-size: 1.3em;
}

.drop-area label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
  display: block;
  letter-spacing: -0.01em;
  font-size: 0.85em;
  text-transform: uppercase;
}

.drop-area input[type="file"] {
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.9em;
  transition: all 0.2s;
  width: 100%;
  background: white;
}

.drop-area input[type="file"]:hover {
  border-color: #cbd5e1;
}

.drop-area input[type="file"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Preview List */
.preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin: 20px 0;
  min-height: 100px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 12px;
  position: relative;
}

.preview-list::after {
  content: "💡 Drag to re-order";
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75em;
  color: #94a3b8;
  font-style: italic;
  white-space: nowrap;
}

.preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
  border-radius: 10px;
  padding: 10px 8px 8px 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  position: relative;
  cursor: grab;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.preview-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-color: #2563eb;
}

.preview-item:active {
  cursor: grabbing;
}

.preview-item img {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #f1f5f9;
  border: 2px solid #e2e8f0;
  transition: border-color 0.2s;
}

.preview-item:hover img {
  border-color: #2563eb;
}

.preview-filename {
  font-size: 0.75em;
  color: #475569;
  font-weight: 600;
  word-break: break-all;
  text-align: center;
  margin-top: 4px;
}

.preview-item .desc {
  font-size: 0.7em;
  color: #94a3b8;
  margin-top: 2px;
  margin-bottom: 6px;
}

.preview-item .remove-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.7em;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 600;
  width: 100%;
  margin-top: auto;
}

.preview-item .remove-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* Arrows */
.preview-arrows {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.preview-arrows button {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: none;
  border-radius: 6px;
  font-size: 1em;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: #475569;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.preview-arrows button:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

.preview-arrows button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Form Elements */
.prefix-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0 16px 0;
}

.prefix-group input[type="text"] {
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95em;
  transition: all 0.2s;
  background: white;
}

.prefix-group input[type="text"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Compression Toggle */
.compression-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  background: white;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
}

.compression-toggle label {
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  flex: 1;
  font-size: 0.95em;
}

.compression-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
  width: 100%;
  height: 100%;
  margin: 0;
  z-index: 2;
}

.toggle-switch {
  position: relative;
  width: 56px;
  height: 30px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cbd5e1;
  border-radius: 30px;
  transition: all 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

.compression-options {
  margin-top: 14px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 10px;
  display: none;
}

.compression-options.active {
  display: block;
  animation: slideDown 0.3s ease;
}

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

.compression-options label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #475569;
  font-size: 0.85em;
}

select {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9em;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 10px;
}

select:hover {
  border-color: #cbd5e1;
}

select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.desc {
  color: #64748b;
  font-size: 0.85em;
  line-height: 1.5;
  margin: 4px 0;
}

.desc code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  color: #2563eb;
  font-size: 0.95em;
}

/* Progress Bar */
#progress-container {
  display: none;
  margin: 20px 0;
  padding: 16px;
  background: white;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
}

#progress-bar-bg {
  background: #e2e8f0;
  border-radius: 10px;
  height: 20px;
  width: 100%;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

#progress-bar {
  background: linear-gradient(90deg, #2563eb 0%, #06b6d4 100%);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

#progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 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 {
  font-size: 0.9em;
  color: #2563eb;
  margin-top: 10px;
  text-align: center;
  font-weight: 600;
}

/* Main Button */
.img-tool-container button.main {
  margin-top: 20px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.05em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
  transition: all 0.3s ease;
  width: 100%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.img-tool-container button.main::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.img-tool-container button.main:hover::before {
  left: 100%;
}

.img-tool-container button.main:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.img-tool-container button.main:active {
  transform: translateY(0);
}

/* Signature */
.img-tool-signature {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  margin-top: 24px;
  margin-bottom: -8px;
  max-width: 300px !important;
}

.img-tool-signature img {
  opacity: 0.6;
  transition: opacity 0.3s;
  height: 22px;
  width: auto;
}

.img-tool-signature img:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 1200px) {
  .img-tool-container {
    max-width: 95vw;
    padding: 32px 28px;
  }
}

@media (max-width: 768px) {
  .img-tool-container {
    margin: 20px auto;
    padding: 28px 20px;
    border-radius: 18px;
  }

  .img-tool-container h2 {
    font-size: 1.5em;
    margin-bottom: 16px;
  }

  .preview-list {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    padding: 12px;
  }

  .preview-item img {
    width: 100px;
    height: 65px;
  }
}

@media (max-width: 480px) {
  .img-tool-container {
    padding: 20px 14px;
    border-radius: 16px;
  }

  .preview-list {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 0.85em;
  }
}
