/* Variables & Core Design System */
:root {
  --bg-primary: #080b11;
  --bg-secondary: #0f1422;
  --bg-glass: rgba(17, 25, 40, 0.65);
  --bg-glass-hover: rgba(23, 33, 53, 0.8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(99, 102, 241, 0.5);
  --border-color-success: rgba(16, 185, 129, 0.5);

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --color-primary: #6366f1; /* Indigo */
  --color-primary-glow: rgba(99, 102, 241, 0.15);
  --color-accent: #06b6d4;  /* Cyan */
  --color-success: #10b981; /* Emerald */
  --color-danger: #ef4444;  /* Red */

  --font-sans: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --shadow-glow-success: 0 0 25px rgba(16, 185, 129, 0.25);
}

/* Base resets & setup */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1.5;
}

/* Ambient glow spheres */
.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
  animation: float 20s infinite alternate;
}

.sphere-1 {
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 80%);
  top: -10%;
  left: -10%;
}

.sphere-2 {
  width: 35vw;
  height: 35vw;
  background: radial-gradient(circle, var(--color-accent) 0%, transparent 80%);
  bottom: -10%;
  right: -10%;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5%, 8%) scale(1.1); }
  100% { transform: translate(-5%, -5%) scale(0.9); }
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 1200px;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.app-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo-icon {
  width: 2.75rem;
  height: 2.75rem;
  color: var(--color-primary);
  filter: drop-shadow(0 0 8px var(--color-primary));
}

.text-gradient {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 400;
  max-width: 600px;
}

/* Stats Ticker */
.stats-ticker {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.75rem 2rem;
  border-radius: 50px;
  align-self: center;
  backdrop-filter: blur(10px);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

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

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

.stat-separator {
  width: 1px;
  height: 15px;
  background-color: var(--border-color);
}

/* Main Dashboard Grid */
.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

/* Glassmorphism Panels */
.glass {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.step-num {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  color: white;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.panel-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Drag and Drop Zone */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.04);
  box-shadow: var(--shadow-glow);
}

.icon-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  width: 4.5rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  transition: transform 0.3s ease, background 0.3s ease;
}

.dropzone:hover .icon-wrapper, .dropzone.dragover .icon-wrapper {
  transform: translateY(-5px);
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--color-primary-glow);
}

.upload-icon {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.dropzone:hover .upload-icon, .dropzone.dragover .upload-icon {
  color: var(--color-primary);
}

.dropzone h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.dropzone p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Selected Files Wrapper */
.selected-files-list {
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.selected-files-list h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.files-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 150px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.file-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.file-item-size {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Settings Group Panel */
.settings-group {
  margin-top: 1.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.4s ease;
}

.settings-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-title h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.badge {
  background: var(--color-primary-glow);
  border: 1px solid var(--border-color-active);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
}

/* Tabs */
.tab-container {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  gap: 0.25rem;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-content.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.tab-info-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(99, 102, 241, 0.05);
  border-left: 3px solid var(--color-primary);
  padding: 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Input Styles */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tooltip-trigger {
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: help;
  color: var(--text-muted);
}

.styled-select, .styled-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease;
}

.styled-select:focus, .styled-input:focus {
  border-color: var(--color-primary);
}

/* Slider Customization */
.slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.styled-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.styled-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--color-primary);
  transition: transform 0.1s ease;
}

.styled-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-marks {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Toggle Switch */
.toggle-item {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 24px;
}

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

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

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Resize Sub-Inputs */
.resize-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-col label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Compress Buttons */
.action-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  color: white;
  border: none;
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-glow);
}

.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}

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

.btn-icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Right Panel Styles */
.results-panel {
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

/* Results Placeholder */
.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
}

.placeholder-icon {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  width: 5rem;
  height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 1.5rem;
}

.placeholder-icon svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--text-muted);
}

.result-placeholder h3 {
  color: var(--text-secondary);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-placeholder p {
  font-size: 0.85rem;
  max-width: 280px;
}

/* Loading State */
.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.spinner-container {
  position: relative;
  width: 4rem;
  height: 4rem;
  margin-bottom: 1.5rem;
}

.spinner {
  width: 100%;
  height: 100%;
  border: 4px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: var(--shadow-glow);
  opacity: 0.5;
}

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

.result-loading h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.result-loading p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Results Dashboard (Success state) */
.result-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
  animation: fadeIn 0.5s ease;
}

.success-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid var(--border-color-success);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.05);
}

.success-icon-wrapper {
  background: var(--color-success);
  color: white;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
  flex-shrink: 0;
}

.success-icon-wrapper svg {
  width: 1.25rem;
  height: 1.25rem;
}

.success-banner h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.success-banner p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Comparison Widget */
.comparison-widget {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

@media (max-width: 580px) {
  .comparison-widget {
    flex-direction: column;
    align-items: stretch;
  }
  .compare-arrow {
    transform: rotate(90deg);
    margin: 0.5rem 0;
  }
}

.compare-card {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  min-width: 130px; /* Prevent shrinking too small */
}

.compare-card.compressed {
  border-color: var(--border-color-success);
  background: rgba(16, 185, 129, 0.02);
  box-shadow: var(--shadow-glow-success);
}

.card-type {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.compare-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.size-display {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-sans);
  letter-spacing: -0.02em;
}

.file-badge {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.compare-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: var(--text-muted);
}

.compare-arrow svg {
  width: 1.5rem;
  height: 1.5rem;
}

.savings-percentage {
  background: var(--color-success);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 50px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Image Preview */
.preview-frame {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  border-radius: var(--radius-md);
}

.preview-frame h4 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.preview-img-wrapper {
  width: 100%;
  max-height: 250px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.05) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
  border: 1px solid var(--border-color);
}

.preview-img-wrapper img {
  max-width: 100%;
  max-height: 250px;
  object-fit: contain;
  display: block;
}

/* Downloads section */
.download-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: auto;
}

.download-btn {
  background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.download-btn:hover {
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

/* Footer Styling */
.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

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

/* Mobile Layout Locking & Squeezing Prevention */
@media (max-width: 480px) {
  .logo {
    font-size: 2rem;
  }
  .logo-icon {
    width: 2.25rem;
    height: 2.25rem;
  }
  .subtitle {
    font-size: 0.95rem;
  }
  .stats-ticker {
    flex-direction: column;
    gap: 0.5rem;
    border-radius: var(--radius-md);
    padding: 1rem;
    width: 100%;
  }
  .stat-separator {
    display: none;
  }
  .glass {
    padding: 1.25rem;
  }
  .dropzone {
    padding: 2rem 1rem;
  }
  .preview-img-wrapper {
    max-height: 180px;
  }
  .preview-img-wrapper img {
    max-height: 180px;
  }
  .resize-inputs {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}
