/* ==========================================================================
   Photo to SVG Outline Generator - Professional Dark Theme Stylesheet
   ========================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-surface: #111827;
  --bg-card: #1f2937;
  --bg-hover: #374151;
  --border-color: #374151;
  --border-focus: #3689BC;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-primary: #3689BC;
  --accent-primary-hover: #2b709b;
  --accent-cyan: #3689BC;
  --accent-cyan-hover: #2b709b;
  --accent-green: #10b981;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.2);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header Bar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(54, 137, 188, 0.35);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.preset-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}

.preset-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.preset-btn.active {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Main Layout */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar Controls */
.sidebar {
  width: 380px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-dark);
}

.tab-btn {
  flex: 1;
  padding: 12px 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: var(--bg-surface);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.tab-pane.active {
  display: flex;
}

/* Form Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-header label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.control-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.toggle-group {
  padding: 8px 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: var(--border-color);
  border-radius: 12px;
  transition: background-color 0.2s ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

input[type="checkbox"] {
  display: none;
}

input[type="checkbox"]:checked + .toggle-switch {
  background-color: var(--accent-primary);
}

input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(20px);
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
}

.form-select:focus {
  border-color: var(--accent-primary);
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* Viewport Section */
.viewport-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-dark);
  position: relative;
  overflow: hidden;
}

.viewport-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  z-index: 4;
}

.view-mode-selector {
  display: flex;
  background: var(--bg-dark);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);

  #zoomLevelText {
    font-size: 0.8rem;
    font-weight: 600;
    width: 44px;
    text-align: center;
  }
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

/* Stage & Drag / Zoom Viewport */
.viewport-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: radial-gradient(var(--border-color) 1px, transparent 0);
  background-size: 24px 24px;
}

/* Upload Dropzone Overlay */
.upload-dropzone {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;

  &.hidden {
    display: none;
  }
}

.dropzone-card {
  background: var(--bg-surface);
  border: 2px dashed var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.dropzone-icon {
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.dropzone-card h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.dropzone-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

/* Transform Wrapper for Pan & Zoom */
.canvas-transform-wrapper {
  position: absolute;
  transform-origin: center center;
  cursor: grab;
  user-select: none;

  &.grabbing {
    cursor: grabbing;
  }
}

/* Split Comparison Viewport */
.split-comparison-container {
  position: relative;
  display: inline-block;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

#canvasOriginal {
  display: block;
}

.vector-overlay-layer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 50%; /* Controlled dynamically by split slider */
  overflow: hidden;
  background: #ffffff;
  border-right: 2px solid var(--accent-cyan);
}

.svg-container {
  position: absolute;
  top: 0;
  left: 0;

  svg {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
  }
}

.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent-cyan);
  cursor: ew-resize;
  z-index: 10;

  .split-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.8);
  }
}

/* Status Bar */
.app-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  z-index: 10;
  position: relative;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);

  &.processing {
    background: var(--accent-cyan);
    box-shadow: 0 0 6px var(--accent-cyan);
    animation: pulse 1s infinite alternate;
  }
}

@keyframes pulse {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

.status-metrics {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pipe {
  color: var(--border-color);
}

.progress-bar-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
  transition: width 0.2s ease;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  color: #fff;
  border: none;

  &:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
  }
}

.btn-primary-outline {
  background: transparent;
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);

  &:hover {
    background: rgba(6, 182, 212, 0.1);
  }
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);

  &:hover {
    background: var(--bg-hover);
  }
}

.btn-block {
  width: 100%;
}

.export-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* Utility */
.hidden {
  display: none !important;
}
