/* =====================================================
   NPRIMG — Image Toolkit
   Theme: Dark Industrial + Neon Green
   ===================================================== */

:root {
  --bg: #0e0e0e;
  --surface: #1d1d1d;
  --surface2: #252525;
  --border: #2e2e2e;
  --accent: #48f955;
  --accent-dim: rgba(72,249,85,0.12);
  --accent-glow: rgba(72,249,85,0.3);
  --text: #f0f0f0;
  --text-muted: #6a6a6a;
  --text-dim: #9a9a9a;
  --danger: #ff4d4d;
  --warn: #f9a048;
  --radius: 10px;
  --radius-sm: 6px;
  --font-mono: 'Space Mono', monospace;
  --font-main: 'Syne', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 600px 400px at 80% 0%, rgba(72,249,85,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 10% 80%, rgba(72,249,85,0.03) 0%, transparent 70%);
}

/* =================== HEADER =================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  height: 64px;
  background: rgba(14,14,14,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 2px;
  position: relative;
  flex-shrink: 0;
}
.logo-npr {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  letter-spacing: -1px;
}
.logo-img {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: -1px;
}
.logo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  top: 6px;
  right: -10px;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.6); }
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.nav-btn:hover {
  color: var(--text);
  background: var(--surface);
}
.nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  flex-shrink: 0;
}
.badge-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* =================== MAIN =================== */
.main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* =================== UPLOAD =================== */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 48px 32px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-hover {
  border-color: var(--accent);
  background: rgba(29,29,29,0.95);
  box-shadow: 0 0 0 4px var(--accent-dim), inset 0 0 40px rgba(72,249,85,0.04);
}
.upload-zone.drag-hover .upload-inner { opacity: 0.3; }
.upload-zone.drag-hover .drop-overlay { opacity: 1; }

.upload-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  transition: opacity 0.2s;
  pointer-events: none;
}

.upload-icon {
  width: 56px;
  height: 56px;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0.8;
}
.upload-icon svg { width: 100%; height: 100%; }

.upload-text { pointer-events: auto; }
.upload-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.upload-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.file-label {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  pointer-events: auto;
}
.upload-formats {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  letter-spacing: 2px;
}

/* =================== STATS BAR =================== */
.stats-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 0;
  animation: slide-up 0.3s ease;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.stat-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-sep {
  width: 1px;
  height: 32px;
  background: var(--border);
}
.clear-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 8px;
}
.clear-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* =================== TOOL SECTION =================== */
.tool-section { position: relative; }

.tool-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  animation: fade-in 0.2s ease;
}
.tool-panel.active { display: block; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header { margin-bottom: 24px; }
.panel-header h2 {
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 12px;
}
.panel-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  letter-spacing: 0.5px;
}

/* =================== CONTROLS =================== */
.panel-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.control-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ctrl-val {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

.control-group.inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.control-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}
.control-row .control-group { flex: 1; }

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  position: relative;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.25); }
.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: -2px;
}

/* Number Input */
.num-input, .text-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.num-input:focus, .text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Pills */
.format-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Format Grid */
.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.fmt-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 8px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  text-align: center;
}
.fmt-btn:hover { border-color: var(--accent); color: var(--accent); }
.fmt-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0e0e0e;
}

/* Preset Chips */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Toggle */
.toggle { position: relative; display: inline-flex; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 100px;
  transition: background 0.2s;
  position: relative;
  display: block;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after {
  left: 21px;
  background: #0e0e0e;
}

/* Lock icon */
.lock-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: 2px;
  transition: color 0.2s;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.lock-icon:hover, .lock-icon.locked { color: var(--accent); border-color: var(--accent); }
.lock-icon svg { width: 16px; height: 16px; }

/* Position grid */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  gap: 4px;
}
.pos-btn {
  width: 40px; height: 40px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.pos-btn:hover { border-color: var(--accent); color: var(--accent); }
.pos-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Color picker */
.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-pick {
  width: 44px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 2px;
}
.color-pick::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick::-webkit-color-swatch { border: none; border-radius: 4px; }

/* Filter grid */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Crop preview */
.crop-preview-area {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.crop-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}
.crop-placeholder svg {
  width: 48px; height: 48px;
  opacity: 0.4;
}
.crop-placeholder p { font-size: 13px; }

/* Action Button */
.action-btn {
  width: 100%;
  background: var(--accent);
  color: #0e0e0e;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  padding: 14px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}
.action-btn svg { width: 18px; height: 18px; }
.action-btn:hover {
  background: #5dff6a;
  box-shadow: 0 0 24px var(--accent-glow);
  transform: translateY(-1px);
}
.action-btn:active { transform: translateY(0); }
.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Ghost Button */
.ghost-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
.ghost-btn svg { width: 15px; height: 15px; }
.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =================== QUEUE =================== */
.queue-section {
  animation: slide-up 0.3s ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.queue-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.queue-badge {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(72,249,85,0.3);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
}

/* File List */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s;
  animation: item-in 0.25s ease;
}
@keyframes item-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.file-item:hover { border-color: var(--surface2); }
.file-item.processing { border-color: rgba(249,160,72,0.4); }
.file-item.done { border-color: rgba(72,249,85,0.3); }
.file-item.error { border-color: rgba(255,77,77,0.4); }

.file-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb-placeholder {
  color: var(--text-muted);
  font-size: 20px;
}

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.file-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.file-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
  text-transform: uppercase;
}
.file-tag.format { color: var(--accent); border-color: rgba(72,249,85,0.2); }
.file-tag.savings { color: #48f9b0; border-color: rgba(72,249,176,0.2); }
.file-tag.size-new { color: var(--warn); }

.file-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}
.status-badge.ready { background: rgba(106,106,106,0.2); color: var(--text-muted); }
.status-badge.processing { background: rgba(249,160,72,0.15); color: var(--warn); animation: blink 1s infinite; }
.status-badge.done { background: rgba(72,249,85,0.1); color: var(--accent); }
.status-badge.error { background: rgba(255,77,77,0.1); color: var(--danger); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.download-btn {
  background: var(--accent);
  color: #0e0e0e;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.download-btn svg { width: 13px; height: 13px; }
.download-btn:hover {
  background: #5dff6a;
  box-shadow: 0 0 12px var(--accent-glow);
}

.remove-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 30px; height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.remove-btn svg { width: 14px; height: 14px; }
.remove-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Progress bar inside file item */
.file-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 10px 10px;
  transition: width 0.3s;
}
.file-item { position: relative; overflow: hidden; }

/* =================== TOAST =================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  min-width: 260px;
  max-width: 360px;
  animation: toast-in 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.toast.success { border-color: rgba(72,249,85,0.4); }
.toast.success .toast-icon { color: var(--accent); }
.toast.error { border-color: rgba(255,77,77,0.4); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info { border-color: rgba(72,163,249,0.4); }
.toast.info .toast-icon { color: #48a3f9; }
.toast-icon { font-size: 16px; flex-shrink: 0; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(16px); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =================== RESPONSIVE =================== */
@media (max-width: 768px) {
  .header { padding: 0 16px; gap: 12px; }
  .header-badge { display: none; }
  .main { padding: 20px 12px 60px; }
  .upload-inner { flex-direction: column; text-align: center; }
  .filter-grid { grid-template-columns: 1fr; }
  .control-row { flex-direction: column; }
  .lock-icon { display: none; }
}