/**
 * ONE RESIZER — Tool 04: Image Compressor Stylesheet
 * Side-by-Side Original vs Compressed Comparison, Dual Mode (Quality vs Target Size),
 * Real-Time Savings Ticker, Transparency Protection, and Responsive Layout.
 */

/* ========================================================
   CONTAINER & WORKSPACE VIEWS
   ======================================================== */
.comp-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.comp-view {
  display: block;
  width: 100%;
  box-sizing: border-box;
}
.comp-view.hidden {
  display: none !important;
}

/* ========================================================
   INITIAL UPLOAD HERO SCREEN
   ======================================================== */
.upload-hero-card {
  background: var(--bg-card);
  border: 2px dashed var(--primary-cyan);
  border-radius: var(--radius-xl);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.upload-hero-card:hover, .upload-hero-card.dragover {
  background: rgba(22, 135, 245, 0.08);
  border-color: var(--primary-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.upload-icon-wrapper {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(22, 135, 245, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-cyan);
}
.upload-icon-wrapper svg {
  width: 36px;
  height: 36px;
  stroke: currentColor;
  fill: none;
}

.upload-heading {
  font-size: 20px;
  font-weight: 850;
  color: var(--text-heading);
  margin-bottom: 6px;
}
.upload-subheading {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.upload-btn-fake {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-cyan);
  color: #fff;
  font-weight: 800;
  font-size: 13.5px;
  padding: 9px 22px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 14px var(--primary-glow);
  margin-bottom: 14px;
}
.upload-formats-badge {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  max-width: 100%;
}

/* ========================================================
   STUDIO LAYOUT: PREVIEWS (LEFT) + CONTROLS (RIGHT)
   ======================================================== */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 450px;
  gap: 24px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

/* LEFT COLUMN: SIDE-BY-SIDE OR STACKED COMPARISON */
.comparison-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.preview-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
  flex-wrap: wrap;
}
.file-info-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.file-info-badge .file-name {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-heading);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-info-badge .file-size-orig {
  font-size: 11.5px;
  font-weight: 750;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

/* REAL-TIME SAVINGS BANNER */
.savings-banner {
  background: rgba(16, 168, 88, 0.1);
  border: 1.5px solid rgba(16, 168, 88, 0.3);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.savings-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.savings-badge {
  background: #10a858;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(16, 168, 88, 0.4);
}
.savings-text {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-heading);
}
.savings-details {
  font-size: 12px;
  font-weight: 750;
  color: #10a858;
}

/* DUAL COMPARISON GRID */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}

.compare-card {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.compare-header .tag {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 10.5px;
}
.compare-header .tag-orig {
  background: var(--bg-card);
  color: var(--text-muted);
}
.compare-header .tag-comp {
  background: rgba(22, 135, 245, 0.15);
  color: var(--primary-cyan);
}

.compare-stage {
  position: relative;
  width: 100%;
  height: 240px;
  background-color: var(--bg-card);
  background-image: 
    linear-gradient(45deg, rgba(0,0,0,0.06) 25%, transparent 25%), 
    linear-gradient(-45deg, rgba(0,0,0,0.06) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.06) 75%), 
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.06) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  box-sizing: border-box;
}
html[data-theme="dark"] .compare-stage {
  background-image: 
    linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%), 
    linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%), 
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
}

.compare-stage img, .compare-stage canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.compare-meta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 750;
  color: var(--text-muted);
}
.compare-meta strong {
  font-size: 13px;
  font-weight: 850;
  color: var(--text-heading);
}

/* RIGHT COLUMN: CONTROLS PANEL */
.controls-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  width: 100%;
}

.control-section-header {
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

/* MODE TABS (QUALITY VS TARGET SIZE) */
.mode-tabs-group {
  display: flex;
  background: var(--bg-subtle);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
}
.mode-tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.mode-tab.active {
  background: var(--bg-card);
  color: var(--primary-cyan);
  box-shadow: var(--shadow-xs);
}

/* QUALITY MODE CONTAINER */
.quality-box {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
}
.quality-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 750;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.quality-slider {
  width: 100%;
  accent-color: var(--primary-cyan);
  cursor: pointer;
}

/* TARGET SIZE MODE CONTAINER */
.target-size-box {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
}
.target-input-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 8px;
  align-items: center;
}
.target-input-row input {
  width: 100%;
  height: 40px;
  background: var(--bg-input);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0 10px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.target-input-row input:focus {
  border-color: var(--primary-cyan);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.target-input-row select {
  width: 100%;
  height: 40px;
  background: var(--bg-input);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

/* 4-FORMAT GRID */
.format-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}
.format-btn {
  background: var(--bg-subtle);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 9px 2px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}
.format-btn:hover {
  border-color: var(--primary-cyan);
}
.format-btn.active {
  background: var(--primary-cyan);
  border-color: var(--primary-cyan);
  color: #fff;
  box-shadow: 0 3px 10px var(--primary-glow);
}

/* TRANSPARENCY WARNING */
.transparency-warning {
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 750;
  color: #ff9800;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* OPTIONAL RESIZE WHILE COMPRESSING */
.optional-resize-card {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
}
.optional-resize-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-heading);
}

.unit-toggle-group {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}
.unit-tab {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  text-align: center;
}
.unit-tab.active {
  background: var(--primary-cyan);
  color: #ffffff;
}

.dims-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}
.dim-input-wrapper label {
  display: block;
  font-size: 11px;
  font-weight: 750;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.dim-input-wrapper input {
  width: 100%;
  height: 38px;
  background: var(--bg-input);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.aspect-lock-btn {
  margin-top: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.aspect-lock-btn.locked {
  background: rgba(22, 135, 245, 0.12);
  border-color: var(--primary-cyan);
  color: var(--primary-cyan);
}

/* ACTION BUTTONS */
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
}
.btn-compress-execute {
  width: 100%;
  height: 46px;
  background: var(--primary-cyan);
  border: 0;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14.5px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-compress-execute:hover:not(:disabled) {
  background: var(--primary-blue);
  transform: translateY(-1px);
}
.btn-compress-execute:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-secondary-action {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  padding: 5px 10px;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-secondary-action:hover {
  background: var(--bg-subtle);
  color: var(--text-heading);
  border-color: var(--line-light);
}

/* ========================================================
   RESULT & DOWNLOAD CARD
   ======================================================== */
.result-card {
  background: var(--bg-card);
  border: 2px solid rgba(16, 168, 88, 0.4);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  width: 100%;
}
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 168, 88, 0.12);
  color: #10a858;
  border: 1px solid rgba(16, 168, 88, 0.3);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 800;
  margin-bottom: 14px;
}
.result-heading {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-heading);
  margin-bottom: 4px;
}
.result-subheading {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.result-preview-box {
  width: 100%;
  max-height: 240px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  margin-bottom: 18px;
  overflow: hidden;
  box-sizing: border-box;
}
.result-preview-box img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
}
.result-stat-item {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 4px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}
.result-stat-item span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
}
.result-stat-item strong {
  display: block;
  font-size: 13px;
  font-weight: 850;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-download-final {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: #10a858;
  border: 0;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 168, 88, 0.35);
  transition: var(--transition);
  margin-bottom: 10px;
}
.btn-download-final:hover {
  background: #0d8a47;
  transform: translateY(-1px);
}

/* ========================================================
   RESPONSIVE MEDIA QUERIES
   ======================================================== */
@media (max-width: 992px) {
  .editor-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}
@media (max-width: 768px) {
  .comparison-panel, .controls-panel, .result-card {
    padding: 16px 14px;
  }
  .comparison-grid {
    grid-template-columns: 1fr;
  }
  .compare-stage {
    height: 200px;
  }
  .result-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .format-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
