/* Clean Flat Design System for App-like Experience */
:root {
  /* Clean app colors - no gradients */
  --app-bg-primary: #2a2a2a;
  --app-bg-secondary: #323232;
  --app-bg-tertiary: #3a3a3a;
  --app-bg-panel: #353535;
  
  /* Text colors */
  --app-text-primary: #f0f0f0;
  --app-text-secondary: #d0d0d0;
  --app-text-tertiary: #b0b0b0;
  
  /* Accent colors */
  --app-accent-blue: #007acc;
  --app-accent-blue-light: #0097ff;
  --app-accent-red: #e81123;
  --app-accent-green: #16c60c;
  
  /* Border colors */
  --app-border-primary: #404040;
  --app-border-secondary: #505050;
  
  /* Shadows - subtle for depth */
  --app-shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.2);
  --app-shadow-medium: 0 2px 4px rgba(0, 0, 0, 0.25);
  
  /* Typography - friendlier font */
  --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  
  /* Spacing - app standard */
  --space-xs: 4px;
  --space-sm: 6px;
  --space-md: 8px;
  --space-lg: 12px;
  --space-xl: 16px;
  
  /* Border radius - minimal */
  --radius-sm: 2px;
  --radius-md: 3px;
  --radius-lg: 4px;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--app-text-primary);
  background-color: var(--app-bg-primary);
  line-height: 1.4;
  overflow: hidden;
}

/* Clean flat toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--app-bg-secondary);
  border-bottom: 1px solid var(--app-border-primary);
  padding: var(--space-sm) var(--space-md);
  height: 44px;
  z-index: 100;
}

.toolbar h1 {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--app-text-primary);
  margin: 0;
}

.toolbar-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Clean flat icon buttons */
.icon-btn {
  background: var(--app-bg-secondary);
  border: 1px solid var(--app-border-primary);
  color: var(--app-text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  /* No transition for instant dropdown interaction */
  transition: none;
  font-size: 16px;
}

.icon-btn:hover {
  background: var(--app-bg-tertiary);
  border-color: var(--app-border-secondary);
  color: var(--app-accent-blue-light);
}

.icon-btn:active {
  background: var(--app-bg-primary);
  transform: scale(0.95);
}

.icon-btn.active {
  background: rgba(0, 122, 204, 0.15);
  border-color: rgba(0, 122, 204, 0.4);
  color: var(--app-accent-blue);
}

/* Main app layout inspired by modern desktop apps */
.app {
  display: flex;
  height: calc(100vh - 48px);
  background: var(--bg-primary);
}

/* Clean flat sidebar */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--app-bg-secondary);
  border-right: 1px solid var(--app-border-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: none; /* Disable any animation */
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  transform: translateX(-100%);
  transition: none;
}

/* Clean flat panel styling */
.panel {
  background: var(--app-bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--app-border-primary);
  margin: var(--space-sm);
  overflow: hidden;
  transition: none;
}

.panel h2 {
  background: #4a4a4a;
  color: #ffffff;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
  border-bottom: 1px solid var(--app-border-primary);
}

.panel h2 .material-icons {
  font-size: 18px;
  color: #d0d0d0;
  vertical-align: middle;
  margin-right: 4px;
}

.panel-content {
  padding: var(--space-md);
}

/* Modern form controls inspired by Apple Human Interface */
.panel form {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  align-items: center;
}

/* Clean flat form inputs */
.panel input,
.panel select {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--app-border-primary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: var(--app-bg-tertiary);
  color: var(--app-text-primary);
  transition: all 0.15s ease-out;
  min-width: 0;
  font-family: var(--font-family);
  height: 28px;
}

.panel input:focus,
.panel select:focus {
  outline: none;
  border: 2px solid var(--app-accent-blue);
  /* Preserve arrow image while changing background */
  background-color: var(--app-bg-panel);
}

.panel input:hover,
.panel select:hover {
  border-color: var(--app-border-secondary);
  /* Keep custom arrow; only change background color */
  background-color: var(--app-bg-panel);
}

.panel input::placeholder {
  color: var(--app-text-tertiary);
}

.panel select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b0b0b0' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-sm) center;
  background-size: 12px 12px;
  padding-right: var(--space-lg);
  /* Disable transition to keep arrow static on hover */
  transition: none;
}

/* Clean flat sidebar buttons */
.sidebar-btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--app-bg-tertiary);
  color: var(--app-text-primary);
  border: 1px solid var(--app-border-primary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  white-space: nowrap;
  min-height: 28px;
}

.sidebar-btn:hover {
  /* Preserve default styling on hover – no background change */
  background: var(--app-bg-tertiary);
  border-color: var(--app-border-primary);
  color: var(--app-text-primary);
  transition: none;
}

.sidebar-btn:active {
  background: var(--app-bg-secondary);
}

.sidebar-btn .material-icons {
  font-size: 14px;
  opacity: 0.9;
}

/* Modern form controls inspired by Apple Human Interface */
.panel form {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  align-items: center;
}

/* Lists with modern styling */
.panel ul {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

/* Clean flat list items */
.panel li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  /* Reduce spacing between items */
  margin-bottom: 0;
  font-size: var(--font-size-sm);
  transition: all 0.15s ease-out;
  background: var(--app-bg-panel); /* Darker background for sidebar items */
  /* Only side and bottom borders to avoid double borders */
  border-left: 1px solid var(--app-border-primary);
  border-right: 1px solid var(--app-border-primary);
  border-bottom: 1px solid var(--app-border-primary);
  border-top: none;
  position: relative;
  transition: none;
}

/* Adjust border radius when items touch vertically */
/* Remove top radius for all but the first item */
.panel li:not(:first-child) {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Remove bottom radius for all but the last item */
.panel li:not(:last-child) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.panel li:hover {
  /* Keep default styling on hover – no background change */
  background: var(--app-bg-panel); /* Match darker background on hover */
  border-color: var(--app-border-primary);
  transition: none;
}

/* Ensure the first sidebar item has a top border */
.panel li:first-child {
  border-top: 1px solid var(--app-border-primary);
}

.panel li button {
  /* Larger clickable area for delete/jump buttons */
  padding: var(--space-sm);
  /* Slightly brighter background for delete/jump buttons */
  background: var(--app-bg-tertiary);
  border: 1px solid var(--app-border-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  width: 24px;
  height: 24px;
  color: var(--app-text-secondary);
}

/* Smaller icons inside delete/jump‑to‑point buttons */
.panel li button .material-icons {
  font-size: 14px;
}

/* Delete button (no .jump-btn class) gets red hover */
.panel li button:not(.jump-btn):hover {
  background: var(--app-bg-tertiary);
  border-color: var(--app-accent-red);
  color: var(--app-accent-red);
}

/* Jump-to-point button (has .jump-btn) gets blue hover */
.panel li button.jump-btn:hover {
  background: var(--app-bg-tertiary);
  border-color: var(--app-accent-blue);
  color: var(--app-accent-blue);
}

.panel li button:active {
  background: var(--app-bg-secondary);
}

/* Main canvas area */
.canvas-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-primary);
  position: relative;
}

#vector-canvas {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  cursor: crosshair;
}

/* Minimal floating controls */
.zoom-overlay {
  position: absolute;
  bottom: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.zoom-overlay .icon-btn {
  background: var(--app-bg-secondary);
  color: var(--app-text-secondary);
  border: 1px solid var(--app-border-primary);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: 14px;
  line-height: 1;
}

.zoom-overlay .icon-btn:hover {
  background: var(--app-bg-tertiary);
  color: var(--app-text-primary);
  border-color: var(--app-border-secondary);
}

.zoom-overlay .icon-btn:active {
  background: var(--app-bg-secondary);
}

/* Custom scrollbar - minimal */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--app-border-primary);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--app-border-secondary);
}

/* Responsive design */
@media (max-width: 768px) {
  .toolbar h1 {
    font-size: var(--font-size-base);
  }
  
  .sidebar {
    width: 100%;
    position: fixed;
    top: 44px;
    left: 0;
    height: calc(100vh - 44px);
    transform: translateX(-100%);
    z-index: 200;
    background: var(--app-bg-primary);
  }
  
  .sidebar.open {
    transform: translateX(0);
    transition: none; /* Ensure instant opening */
  }
  
  .zoom-overlay {
    bottom: var(--space-md);
    right: var(--space-md);
  }
  
  .zoom-overlay .icon-btn {
    width: 40px;
    height: 40px;
  }
}

/* Remove input spinners */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

/* Accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-primary: #000000;
    --border-secondary: #000000;
    --text-secondary: #000000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
