:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #a855f7;
  --accent-color: #ec4899;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --canvas-bg: #f8fafc;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --north-color: #ef4444;
  --east-color: #10b981;
  --south-color: #3b82f6;
  --west-color: #f59e0b;
  --devta-north: #fee2e2;
  --devta-east: #d1fae5;
  --devta-south: #dbeafe;
  --devta-west: #fed7aa;
  --devta-center: #f3e8ff;
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gradient-1);
  overflow: hidden;
}

/* Dark mode styles */
body.dark-mode {
  --sidebar-bg: #1a1a1a;
  --sidebar-text: #e2e8f0;
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --border-color: #2d3748;
  --card-bg: #2d3748;
  --canvas-bg: #1a202c;
}

body.dark-mode .canvas-container {
  background: #1a202c;
}

body.dark-mode canvas {
  background: #2d3748;
  border-color: #4a5568;
}

body.dark-mode .control-group {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .control-group:hover {
  background: rgba(0, 0, 0, 0.3);
}

body.dark-mode .control-group input[type="file"],
body.dark-mode .control-group button,
body.dark-mode .control-group select {
  background-color: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--sidebar-text);
}

body.dark-mode .zoom-controls button,
body.dark-mode .zoom-level {
  background: #2d3748;
  color: var(--sidebar-text);
  border-color: #4a5568;
}

body.dark-mode .app-footer {
  background: rgba(0, 0, 0, 0.7);
  color: var(--sidebar-text);
}

.main-container {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
  background: var(--canvas-bg);
}

.controls-sidebar {
  width: 320px;
  background: var(--sidebar-bg);
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
  z-index: 1000;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--primary-color);
  margin-bottom: 10px;
}

.sidebar-header h2 {
  font-size: 20px;
  margin: 0;
  color: var(--sidebar-text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h2 i {
  color: var(--primary-color);
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  color: var(--sidebar-text);
  transition: color 0.2s;
}

.mobile-menu-btn:hover {
  color: var(--primary-color);
}

.control-group {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-group:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: rgba(255, 255, 255, 0.08);
}

.control-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-text);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group input[type="file"],
.control-group button,
.control-group select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  font-size: 14px;
  transition: all 0.2s;
}

.control-group input[type="file"]::-webkit-file-upload-button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  margin-right: 10px;
  cursor: pointer;
  font-weight: 500;
}

.control-group input[type="file"]:hover,
.control-group select:hover {
  border-color: var(--primary-color);
  background-color: rgba(255, 255, 255, 0.15);
}

.control-group button {
  cursor: pointer;
  background: var(--primary-color);
  color: white;
  border: none;
  font-weight: 500;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.control-group button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.control-group button:active {
  transform: translateY(0);
}

.control-group button.danger {
  background: var(--danger-color);
}

.control-group button.danger:hover {
  background: #dc2626;
}

.slider-container {
  margin: 10px 0;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--sidebar-text);
}

.slider-value {
  background: var(--primary-color);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.1);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.controls-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.controls-row button {
  flex: 1;
  padding: 8px;
  font-size: 16px;
}

.checkbox-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.checkbox-label:hover {
  background: rgba(255, 255, 255, 0.1);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.help-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 8px;
  font-style: italic;
}

.canvas-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  background: var(--canvas-bg);
  overflow: hidden;
}

canvas {
  border: 2px solid white;
  background: white;
  cursor: grab;
  max-width: 100%;
  max-height: 100%;
  box-shadow: var(--shadow-xl);
  border-radius: 12px;
  transition: transform 0.2s;
}

canvas:active {
  cursor: grabbing;
}

.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

.mobile-overlay.active {
  display: block;
}

.app-footer {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.app-footer img {
  height: 30px;
  width: auto;
}

.app-footer span {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.floating-toolbar {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 10px;
  border-radius: 30px;
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  gap: 10px;
}

.floating-toolbar button {
  background: var(--primary-color);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-toolbar button:hover {
  transform: scale(1.1);
  background: var(--primary-hover);
}

.zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.zoom-controls button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s;
}

.zoom-controls button:hover {
  background: var(--primary-color);
  color: white;
  transform: scale(1.05);
}

.zoom-level {
  position: absolute;
  bottom: 80px;
  left: 20px;
  background: white;
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

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

.color-picker {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.color-label {
  font-size: 14px;
  color: var(--sidebar-text);
}

@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
  }

  .controls-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    z-index: 1002;
  }

  .controls-sidebar.active {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: block;
  }

  .canvas-container {
    height: 100vh;
    padding: 10px;
  }

  .floating-toolbar {
    display: flex;
  }

  .app-footer {
    bottom: 80px;
    right: 10px;
    padding: 8px 12px;
  }

  .app-footer img {
    height: 25px;
  }

  canvas {
    border-radius: 8px;
  }
  
  .zoom-controls {
    bottom: 100px;
    left: 10px;
  }
  
  .zoom-level {
    bottom: 160px;
    left: 10px;
  }
}

@media (max-width: 480px) {
  .controls-sidebar {
    width: 100%;
    max-width: 100%;
  }

  .control-group {
    padding: 12px;
  }

  .sidebar-header h2 {
    font-size: 18px;
  }
}

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0,0,0,0.1);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Enhanced UI Elements */
.feature-highlight {
  position: relative;
  overflow: hidden;
}

.feature-highlight::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.feature-highlight:hover::before {
  left: 100%;
}

.gradient-text {
  background: var(--gradient-2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

.glass-effect {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tab-container {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px;
  border-radius: 10px;
}

.tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
}

.tab.active {
  background: var(--primary-color);
  color: white;
}

.tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  z-index: 2000;
}

.notification.show {
  transform: translateX(0);
}

.notification.success {
  border-left: 4px solid var(--success-color);
}

.notification.error {
  border-left: 4px solid var(--danger-color);
}

.notification.info {
  border-left: 4px solid var(--primary-color);
}

.notification i {
  font-size: 20px;
}

.notification.success i {
  color: var(--success-color);
}

.notification.error i {
  color: var(--danger-color);
}

.notification.info i {
  color: var(--primary-color);
}

.notification-content h4 {
  margin: 0 0 5px 0;
  font-size: 16px;
  font-weight: 600;
}

.notification-content p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.theme-toggle i {
  color: var(--sidebar-text);
  font-size: 18px;
}

.plan-size-controls {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.plan-size-controls button {
  flex: 1;
  padding: 8px;
  font-size: 14px;
}