/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f9fa;
  color: #333;
  overflow: hidden;
}

/* App container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: white;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid hsl(20, 5.9%, 90%);
  flex-shrink: 0;
}

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

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: hsl(20, 14.3%, 4.1%);
  border-radius: 8px;
  color: white;
}

.logo-text {
  font-size: 20px;
  font-weight: 600;
  color: hsl(20, 14.3%, 4.1%);
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 6px;
  background: white;
  color: hsl(20, 14.3%, 4.1%);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: hsl(20, 5.9%, 98%);
  border-color: hsl(20, 5.9%, 80%);
}

.action-btn.primary {
  background: hsl(207, 90%, 54%);
  border-color: hsl(207, 90%, 54%);
  color: white;
}

.action-btn.primary:hover {
  background: hsl(207, 90%, 48%);
  border-color: hsl(207, 90%, 48%);
}

/* Property Inspector */
.inspector {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 250px;
  background: white;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.inspector.active {
  opacity: 1;
  pointer-events: auto;
}

.property-group {
  margin-bottom: 16px;
}

.property-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: hsl(20, 14.3%, 4.1%);
}

.color-input {
  width: 100%;
  height: 36px;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

.range-input {
  width: calc(100% - 40px);
  margin-right: 8px;
}

.stroke-style-group {
  display: flex;
  gap: 4px;
}

.stroke-style-btn {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 4px;
  background: white;
  color: hsl(20, 14.3%, 4.1%);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.stroke-style-btn:hover {
  background: hsl(20, 5.9%, 98%);
}

.stroke-style-btn.active {
  background: hsl(207, 90%, 54%);
  border-color: hsl(207, 90%, 54%);
  color: white;
}

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

/* Toolbar */
.toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  background: white;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.tool-btn {
  width: 44px;
  height: 44px;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 6px;
  background: white;
  color: hsl(20, 14.3%, 4.1%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: hsl(20, 5.9%, 98%);
  border-color: hsl(20, 5.9%, 80%);
}

.tool-btn.active {
  background: hsl(207, 90%, 54%);
  border-color: hsl(207, 90%, 54%);
  color: white;
}

.delete-btn {
  border-color: #EF4444 !important;
}

.delete-btn:hover {
  background-color: #DC2626 !important;
  border-color: #DC2626 !important;
}

/* Canvas */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: white;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Zoom controls */
.zoom-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 4px;
  background: white;
  color: hsl(20, 14.3%, 4.1%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background: hsl(20, 5.9%, 98%);
  border-color: hsl(20, 5.9%, 80%);
}

#zoomLevel {
  font-size: 14px;
  font-weight: 500;
  color: hsl(20, 14.3%, 4.1%);
  min-width: 40px;
  text-align: center;
}

/* Mobile styles */
@media (max-width: 768px) {
  .inspector {
    display: none;
  }
  
  .toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 12px;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .zoom-controls {
    bottom: 80px;
    right: 12px;
  }
}

/* Mobile Property Inspector */
.mobile-inspector {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid hsl(20, 5.9%, 90%);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 200;
  max-height: 70vh;
  overflow-y: auto;
}

.mobile-inspector.active {
  transform: translateY(0);
}

.mobile-inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.mobile-inspector-title {
  font-size: 18px;
  font-weight: 600;
  color: hsl(20, 14.3%, 4.1%);
}

.close-inspector {
  width: 32px;
  height: 32px;
  border: none;
  background: hsl(20, 5.9%, 95%);
  border-radius: 16px;
  color: hsl(20, 14.3%, 4.1%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
}

.mobile-property-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.mobile-property-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-property-item:last-child {
  grid-column: 1 / -1;
}

/* Cursor modes */
.select-mode {
  cursor: default;
}

.text-mode {
  cursor: text;
}

.pencil-mode {
  cursor: crosshair;
}

.rectangle-mode,
.circle-mode,
.line-mode {
  cursor: crosshair;
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
  .tool-btn:hover {
    background: white;
    border-color: hsl(20, 5.9%, 90%);
  }
  
  .tool-btn.active:hover {
    background: hsl(207, 90%, 54%);
    border-color: hsl(207, 90%, 54%);
  }
}

/* Hide scrollbars but keep functionality */
.mobile-inspector::-webkit-scrollbar {
  display: none;
}

.mobile-inspector {
  -ms-overflow-style: none;
  scrollbar-width: none;
}