/* ═══════════════════════════════════════════
   IMAGE COMPRESSOR — Design System
═══════════════════════════════════════════ */
:root {
  --bg-primary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-card2: #1C2333;
  --bg-input: #1e293b;
  --border: rgba(59, 130, 246, 0.15);
  --border-focus: rgba(96, 165, 250, 0.6);
  --accent: #3b82f6;
  --accent-2: #3b82f6;
  --accent-3: #F78166;
  --accent-glow: rgba(57,211,83,0.18);
  --accent-glow2: rgba(88,166,255,0.15);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ═══ HEADER ═══ */
header {
  background: linear-gradient(180deg, #0A1628 0%, #0D1117 100%);
  border-bottom: 1px solid var(--border);
  padding: 32px 0 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(57,211,83,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.logo-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}
.logo-icon { font-size: 16px; }

header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  background: linear-gradient(135deg, #E6EDF3 30%, #39D353 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.header-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.header-stats {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  min-width: 110px;
}
.stat-icon { font-size: 18px; }
.stat-num { font-size: 12px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 11px; color: var(--text-secondary); }

/* ═══ AD SLOTS ═══ */
.ad-slot {
  background: var(--bg-card2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
  margin: 20px 0;
}
.ad-slot-top { height: 90px; }
.ad-slot-mid { height: 250px; max-width: 300px; margin: 24px auto; }

/* ═══ DROP ZONE ═══ */
.drop-zone-wrapper { margin: 24px 0 0; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 20px;
  padding: 56px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: linear-gradient(135deg, #161B22 0%, #1C2333 100%);
  position: relative;
  overflow: hidden;
}
.drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 70% at 50% 50%, var(--accent-glow) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.3s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-lg);
  transform: translateY(-2px);
}
.drop-zone:hover::before, .drop-zone.drag-over::before { opacity: 1; }
.drop-zone.drag-over { border-style: solid; }

.drop-zone-inner { position: relative; z-index: 1; }
.drop-icon { color: var(--accent); margin-bottom: 16px; display: inline-block; transition: transform 0.3s; }
.drop-zone:hover .drop-icon { transform: translateY(-4px); }
.drop-title { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.drop-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 8px; }
.drop-link {
  color: var(--accent); text-decoration: underline; cursor: pointer;
  font-weight: 600; transition: color var(--transition);
}
.drop-link:hover { color: #5ef07a; }
.drop-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.drop-formats { display: flex; gap: 8px; justify-content: center; }
.format-badge {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 10px;
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: 0.5px;
}

/* ═══ SETTINGS BAR ═══ */
.settings-bar { margin: 20px 0; }
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.settings-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media(max-width:768px){ .settings-grid { grid-template-columns: 1fr; } }

.setting-group { display: flex; flex-direction: column; gap: 10px; }
.setting-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.setting-icon { font-size: 14px; }

.quality-value-badge {
  margin-left: auto;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 100px;
  padding: 1px 10px;
  font-size: 13px; font-weight: 700;
}

.slider-wrap { display: flex; align-items: center; gap: 8px; }
.slider-hint { font-size: 11px; color: var(--text-muted); width: 24px; }
.quality-slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--slider-pct, 70%), var(--bg-card2) var(--slider-pct, 70%));
  border-radius: 100px; outline: none; cursor: pointer;
  transition: background var(--transition);
}
.quality-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  cursor: pointer; transition: transform var(--transition);
}
.quality-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.quality-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: white; border: 3px solid var(--accent); cursor: pointer;
}

.quality-presets, .width-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-btn, .width-btn {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 10px;
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition); font-family: inherit;
}
.preset-btn:hover, .width-btn:hover, .preset-btn.active, .width-btn.active {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-glow);
}

.format-select, .max-width-input {
  width: 100%; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  padding: 10px 12px; outline: none; transition: border-color var(--transition);
}
.format-select:focus, .max-width-input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.format-select option { background: var(--bg-card2); }

/* ═══ BATCH BAR ═══ */
.batch-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin: 0 0 16px;
  animation: fadeIn 0.3s ease;
}
.batch-info { display: flex; align-items: center; gap: 12px; }
.batch-count { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.batch-summary { font-size: 13px; color: var(--accent); font-weight: 600; }
.batch-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-sm); padding: 9px 16px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition);
}
.btn-compress {
  background: linear-gradient(135deg, #39D353, #0fad36);
  color: #000; border-color: #39D353;
}
.btn-compress:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(57,211,83,0.4); }
.btn-compress:active { transform: translateY(0); }
.btn-compress:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-download-all {
  background: var(--bg-card2); color: var(--accent-2);
  border-color: var(--accent-2);
}
.btn-download-all:hover:not(:disabled) { background: var(--accent-glow2); box-shadow: 0 4px 16px rgba(88,166,255,0.3); }
.btn-download-all:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-clear {
  background: transparent; color: var(--text-muted); border-color: var(--border);
}
.btn-clear:hover { color: var(--accent-3); border-color: var(--accent-3); }

/* ═══ FILE LIST ═══ */
.file-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

.file-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 16px; align-items: center;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: slideIn 0.3s ease;
}
.file-card:hover { border-color: #30363D; box-shadow: var(--shadow); }
.file-card.done { border-color: rgba(57,211,83,0.3); }
.file-card.compressing { border-color: rgba(88,166,255,0.3); }

.file-thumb {
  width: 80px; height: 60px;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.file-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.file-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.file-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-sizes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.size-original { font-size: 13px; color: var(--text-secondary); }
.size-arrow { color: var(--text-muted); }
.size-compressed { font-size: 13px; color: var(--accent); font-weight: 700; }
.size-badge {
  background: rgba(57,211,83,0.12); border: 1px solid rgba(57,211,83,0.3);
  color: var(--accent); border-radius: 100px; padding: 1px 8px;
  font-size: 11px; font-weight: 700;
}
.size-badge.bad { background: rgba(247,129,102,0.12); border-color: rgba(247,129,102,0.3); color: var(--accent-3); }

.file-progress { margin-top: 4px; }
.progress-bar {
  width: 100%; height: 4px;
  background: var(--bg-card2); border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), #58A6FF);
  transition: width 0.4s ease;
  width: 0%;
}

.file-status {
  font-size: 11px; margin-top: 3px;
  color: var(--text-muted);
}
.file-status.compressing { color: var(--accent-2); }
.file-status.done { color: var(--accent); }
.file-status.error { color: var(--accent-3); }

.file-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.btn-icon {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 12px;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; font-family: inherit; transition: all var(--transition);
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.btn-icon:hover { border-color: var(--accent-2); color: var(--accent-2); }
.btn-icon.btn-download-single { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-icon.btn-download-single:hover { background: rgba(57,211,83,0.25); }
.btn-icon.btn-remove { color: var(--text-muted); }
.btn-icon.btn-remove:hover { border-color: var(--accent-3); color: var(--accent-3); background: rgba(247,129,102,0.1); }

/* ═══ PRIVACY BANNER ═══ */
.privacy-banner {
  background: linear-gradient(135deg, rgba(57,211,83,0.06), rgba(88,166,255,0.06));
  border: 1px solid rgba(57,211,83,0.2);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
}
.privacy-content { display: flex; align-items: flex-start; gap: 16px; }
.privacy-icon { font-size: 2rem; flex-shrink: 0; }
.privacy-text strong { font-size: 15px; font-weight: 700; color: var(--accent); display: block; margin-bottom: 4px; }
.privacy-text p { font-size: 13px; color: var(--text-secondary); }

/* ═══ HOW TO ═══ */
.how-to-section { margin: 32px 0 40px; }
.section-title {
  text-align: center; font-size: 1.4rem; font-weight: 700;
  margin-bottom: 24px; color: var(--text-primary);
}
.how-to-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media(max-width:768px){ .how-to-grid { grid-template-columns: repeat(2, 1fr); } }
@media(max-width:480px){ .how-to-grid { grid-template-columns: 1fr; } }

.how-to-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 16px; text-align: center;
  transition: border-color var(--transition), transform var(--transition);
  position: relative;
}
.how-to-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.how-to-num {
  position: absolute; top: 12px; right: 12px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #000;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.how-to-icon { font-size: 2rem; margin-bottom: 10px; }
.how-to-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.how-to-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* ═══ SPLIT PREVIEW MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%; max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700;
}
.modal-title-icon { font-size: 18px; }
.modal-filename { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.modal-close {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 32px; height: 32px;
  color: var(--text-secondary); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--accent-3); color: var(--accent-3); }
.modal-stats {
  display: flex; gap: 16px; padding: 12px 20px;
  background: var(--bg-card2); border-bottom: 1px solid var(--border);
  font-size: 13px; flex-wrap: wrap;
}
.modal-stat { display: flex; align-items: center; gap: 6px; }
.modal-stat-label { color: var(--text-muted); }
.modal-stat-val { font-weight: 700; color: var(--text-primary); }
.modal-stat-val.green { color: var(--accent); }

.split-container {
  position: relative; overflow: hidden;
  flex: 1; min-height: 300px; max-height: 60vh;
  background: #000; user-select: none;
}
.split-before, .split-after {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.split-after { clip-path: inset(0 0 0 50%); }
.split-before img, .split-after img {
  max-width: 100%; max-height: 100%;
  width: 100%; height: 100%; object-fit: contain;
}
.split-label {
  position: absolute; top: 12px;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  border-radius: 100px; padding: 3px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
}
.split-label-before { left: 12px; color: var(--accent-3); }
.split-label-after { right: 12px; color: var(--accent); }
.split-divider {
  position: absolute; top: 0; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 4px; background: white;
  cursor: ew-resize; z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
.split-handle {
  background: white; border-radius: 100px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  color: #333; gap: 0; flex-shrink: 0;
}
.split-handle svg { width: 14px; height: 14px; }

/* ═══ TOAST ═══ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-size: 14px; color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(80px); opacity: 0;
  transition: all 0.3s ease;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.error { border-color: var(--accent-3); color: var(--accent-3); }
.toast.info { border-color: var(--accent-2); color: var(--accent-2); }

/* ═══ FOOTER ═══ */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  margin-top: 40px;
}
.footer-logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; color: var(--accent);
  margin-bottom: 10px;
}
footer p { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.footer-sub { font-size: 12px; color: var(--text-muted) !important; }
.footer-links {
  display: flex; justify-content: center; gap: 20px;
  margin: 16px 0;
}
.footer-links a {
  color: var(--text-secondary); font-size: 13px; text-decoration: none;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--accent); }
.footer-privacy { font-size: 12px; color: var(--accent) !important; margin-top: 8px !important; }

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:0.5 } }

.spinning { animation: spin 1s linear infinite; }
.pulsing { animation: pulse 1.5s ease infinite; }

/* ═══ RESPONSIVE ═══ */
@media(max-width:600px){
  .file-card { grid-template-columns: 60px 1fr; }
  .file-actions { display: none; }
  .file-card .file-actions { display: flex; grid-column: 1/-1; flex-direction: row; }
  header h1 { font-size: 1.4rem; }
  .header-stats { gap: 6px; }
  .stat-item { padding: 8px 12px; min-width: 80px; }
  .batch-bar { flex-direction: column; align-items: stretch; }
}
