/* =========================
   GLOBAL STYLE
========================= */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Soft Pastel Theme */
  --bg-light: #f8f9fa;
  --bg-dark: #e9ecef;
  --card-bg: #ffffff;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-light: #adb5bd;

  --border-color: #dee2e6;
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.07);

  --accent-primary: #7c5cff;
  --accent-primary-light: #a38fff;
  --accent-primary-bg: #f4f1ff;

  --accent-secondary: #00c49a;
  --accent-secondary-bg: #e6f9f5;
  
  --danger: #ff6b6b;
  --danger-light: #ff8787;
  --danger-bg: #fff0f0;

  --success: #1bde9b;
  --warning: #ffb703;

  --gradient: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-light) 100%);
  --gradient-danger: linear-gradient(90deg, var(--danger) 0%, var(--danger-light) 100%);

  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font);
}

body {
  background: var(--bg-light);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-weight: 400;
  font-size: 14px;
}

/* =========================
   CUSTOM SCROLLBAR
========================= */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* =========================
   MAIN LAYOUT
========================= */
.wrap {
  display: flex;
  flex: 1;
  padding: 24px;
  height: 100%;
}

.app {
  display: flex;
  flex: 1;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

/* =========================
   LEFT PANEL (OPTIONS)
========================= */
.panel {
  width: 360px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo svg {
  width: 24px;
  height: 24px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.brand p {
  font-size: 13px;
  color: var(--text-secondary);
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  background: var(--bg-light);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}
.stat {
  text-align: center;
}
.stat strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-primary);
}
.stat small {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 500;
}

/* =========================
   OPTION PANEL
========================= */
.options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row {
  display: flex;
  gap: 12px;
}
.row > * {
  flex: 1;
}
.small {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="number"],
input[type="text"],
select {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  width: 100%;
  font-size: 14px;
  transition: var(--transition);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-bg);
}

input[type="number"] {
  text-align: left;
}
input::placeholder {
  color: var(--text-light);
}

/* Custom Range Input */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-dark);
  border-radius: 5px;
  outline: none;
  padding: 0;
  margin-top: 8px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--card-bg);
  box-shadow: var(--shadow-sm);
}

/* Custom Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-light);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}
.checkbox-group:hover {
  background: var(--accent-primary-bg);
  border-color: var(--accent-primary-light);
}
.checkbox-group input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--card-bg);
  margin: 0;
  font: inherit;
  color: currentColor;
  width: 1.15em;
  height: 1.15em;
  border: 1px solid var(--border-color);
  border-radius: 0.25em;
  transform: translateY(-0.075em);
  display: grid;
  place-content: center;
  cursor: pointer;
}
.checkbox-group input[type="checkbox"]::before {
  content: "";
  width: 0.65em;
  height: 0.65em;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
  box-shadow: inset 1em 1em var(--accent-primary);
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.checkbox-group input[type="checkbox"]:checked::before {
  transform: scale(1.2);
}
.checkbox-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

/* Panel Footer */
.footer-actions {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hint {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* =========================
   BUTTONS
========================= */
.btn {
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.2;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn.small {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--border-radius-sm);
}
.btn.large {
  padding: 14px 24px;
  font-size: 16px;
  border-radius: var(--border-radius-md);
}

.btn.primary {
  background: var(--gradient);
  color: #fff;
  background-size: 200% auto;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover {
  background-position: right center;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn.primary:disabled {
  background: var(--bg-dark);
  color: var(--text-light);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-light);
}
.btn.danger:hover {
  background: var(--danger);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* =========================
   WORKSPACE
========================= */
.workspace {
  flex: 1;
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow: hidden;
  gap: 20px;
}
.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.workspace-header h2 {
  font-size: 20px;
  font-weight: 700;
}
#fileInput {
  display: none;
}

.thumb-container {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 40px;
  text-align: center;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
}
#drop-zone svg {
  width: 48px;
  height: 48px;
  color: var(--accent-primary);
  margin-bottom: 12px;
  opacity: 0.5;
}
#drop-zone p {
  font-size: 16px;
  color: var(--text-secondary);
}
#drop-zone p strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Drop zone active state */
.workspace:has(#fileInput:focus-visible) #drop-zone,
.workspace.dragover #drop-zone {
  border-color: var(--accent-primary);
  background: var(--accent-primary-bg);
  box-shadow: 0 0 0 4px var(--accent-primary-bg);
}
.workspace.dragover #drop-zone svg {
  opacity: 1;
}

/* Hide drop zone when there are images */
.workspace:has(.thumb) #drop-zone {
  opacity: 0;
  pointer-events: none;
}

/* =========================
   THUMBNAILS
========================= */
.thumb-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  padding: 4px;
  position: relative;
  z-index: 2;
  height: 100%;
}

.thumb {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  position: relative;
  overflow: hidden;
  cursor: grab;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  aspect-ratio: 1 / 1;
}
.thumb:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--text-light);
}
.thumb.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  box-shadow: var(--shadow-lg);
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease; /* Transisi untuk rotasi */
}

.thumb .actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateX(10px);
  transition: var(--transition);
}
.thumb:hover .actions {
  opacity: 1;
  transform: translateX(0);
}

.thumb .actions button {
  background: rgba(33, 37, 41, 0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.thumb .actions button svg {
  width: 16px;
  height: 16px;
}
.thumb .actions button:hover {
  background: var(--accent-primary);
  transform: scale(1.1);
}
.thumb .actions button.delete:hover {
  background: var(--danger);
}

/* =========================
   WORKSPACE FOOTER & PROGRESS
========================= */
.workspace-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}
.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress {
  background: var(--bg-dark);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gradient);
  border-radius: 100px;
  transition: width 0.4s ease;
}
.status-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* =========================
   MODAL PREVIEW
========================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(33, 37, 41, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  padding: 16px;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}
.modal-overlay.active .modal-content {
  transform: scale(1);
}
.modal-content img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
}

/* =========================
   PROCESSING OVERLAY
========================= */
.processing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.processing-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.processing-overlay p {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 20px;
}
.processing-overlay span {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Spinner Animation */
.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: inline-block;
  border-top: 4px solid var(--accent-primary);
  border-right: 4px solid transparent;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* =========================
   TOAST
========================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 999;
}

.toast {
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  font-weight: 500;
  opacity: 1;
  animation: toastIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
