@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@400;500;600&display=swap');

:root {
  --bg-color: #1e1e2e;
  --container-bg: #2a2a3a;
  --text-color: #e0e0e0;
  --primary-color: #6c5ce7;
  --secondary-color: #636e72;
  --success-color: #00b894;
  --border-color: #4a4a5a;
  --danger-color: #f87171;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  max-width: 800px;
  width: 100%;
  padding: 25px;
  border-radius: 16px;
  background-color: var(--container-bg);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
}

h1 {
  font-size: 28px;
  margin-bottom: 25px;
  text-align: center;
  color: var(--text-color);
  font-weight: 600;
}

h1 i {
  color: var(--primary-color);
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 20px;
  background-color: rgba(108, 92, 231, 0.05);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary-color);
  background-color: rgba(108, 92, 231, 0.1);
}

.upload-area i {
  font-size: 48px;
  margin-bottom: 15px;
  color: var(--primary-color);
}

.upload-area h5 {
  margin-bottom: 10px;
  font-size: 1.2rem;
  font-weight: 500;
}

.upload-area p {
  color: var(--secondary-color);
  font-size: 14px;
}

#fileInput {
  display: none;
}

/* File Info */
.file-info {
  background-color: var(--border-color);
  padding: 12px 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
}

.file-name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* URL Input */
.or-divider {
  display: flex;
  align-items: center;
  margin: 15px 0;
  color: var(--secondary-color);
  font-size: 14px;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.or-divider::before {
  margin-right: 10px;
}

.or-divider::after {
  margin-left: 10px;
}

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

.form-control, .form-select {
  width: 100%;
  background-color: #3a3a4a;
  border: 1px solid #4a4a5a;
  color: var(--text-color);
  padding: 10px 15px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
}

.form-control:focus, .form-select:focus {
  outline: none;
  background-color: #3a3a4a;
  color: var(--text-color);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem rgba(108, 92, 231, 0.25);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e0e0e0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 40px;
}

/* Settings Cards */
.settings-card {
  background-color: var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.settings-card h3 {
  margin-bottom: 15px;
  color: var(--text-color);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
}

/* Custom Toggle */
.toggle-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  margin-right: 10px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #3a3a4a;
  transition: .4s;
  border-radius: 34px;
  border: 1px solid #4a4a5a;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #e0e0e0;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: white;
}

.toggle-label {
  font-weight: 500;
  color: var(--text-color);
  cursor: pointer;
}

/* Inputs */
.input-group {
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.dimensions-row {
  display: flex;
  gap: 15px;
}

.dimensions-row .input-group {
  flex: 1;
  margin-bottom: 0;
}

/* Range Slider */
.range-container {
  margin-bottom: 15px;
}

.range-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 500;
}

.range-value {
  display: inline-block;
  width: 45px;
  text-align: center;
  margin-left: 10px;
  font-weight: 600;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]:focus {
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: #3a3a4a;
  border-radius: 10px;
}

input[type=range]::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -5px;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: #5a4bc7;
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

.btn-download {
  background-color: var(--success-color);
  color: white;
  width: 100%;
  display: none;
  margin-top: 15px;
}

.btn-download:hover {
  background-color: #00a884;
  transform: translateY(-2px);
}

/* Loading */
#loading {
  display: none;
  text-align: center;
  margin: 20px 0;
}

.spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

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

/* Results */
.result-container {
  margin-top: 25px;
  display: none;
}

.image-comparison {
  position: relative;
  width: 100%;
  height: 400px;
  border-radius: 12px;
  overflow: hidden;
  background-color: #1a1a1a;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  margin-bottom: 20px;
}

.image-comparison img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.img-original {
  width: 50%;
  z-index: 1;
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.img-processed {
  z-index: 2;
}

.comparison-slider {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background-color: white;
  z-index: 3;
  cursor: ew-resize;
  transform: translateX(-50%);
}

.comparison-slider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  background-color: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.comparison-slider::after {
  content: '↔';
  position: absolute;
  top: 50%;
  left: 50%;
  color: var(--primary-color);
  font-size: 20px;
  font-weight: bold;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Stats */
.stats-card {
  background-color: var(--border-color);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stat-item:last-child {
  margin-bottom: 0;
}

.stat-label {
  color: var(--secondary-color);
}

.stat-value {
  font-weight: 500;
}

.savings {
  font-weight: 600;
}