/**
 * Fabric Vector Designer - Core CSS
 * Professional design system inspired by Adobe Illustrator
 * Version: 2.0.0
 */

/* CSS Reset & Base Styles */
.fabric-designer-container,
.fabric-designer-container *,
.fabric-designer-container *::before,
.fabric-designer-container *::after {
  box-sizing: border-box;
}

.fabric-designer-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: #333;
  background: #f0f0f0;
  position: relative;
  overflow: hidden;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.fabric-designer-container.loaded {
  opacity: 1;
}

/* Loading Screen */
.fabric-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #f5f5f5;
  z-index: 10000;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-left: 4px solid #007acc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.loader-text {
  color: #666;
  font-size: 16px;
}

/* Main Interface */
.fabric-interface {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #e8e8e8;
}

/* Menu Bar */
.fabric-menubar {
  background: linear-gradient(180deg, #f8f8f8 0%, #f0f0f0 100%);
  border-bottom: 1px solid #c0c0c0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 13px;
  user-select: none;
}

.menubar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-section {
  margin-right: 16px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #333;
}

.logo-icon {
  width: 18px;
  height: 18px;
  fill: #007acc;
}

.main-menu {
  display: flex;
  gap: 2px;
}

.menu-item {
  position: relative;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.15s ease;
}

.menu-item:hover,
.menu-item.active {
  background: rgba(0, 122, 204, 0.1);
}

.submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  display: none;
  z-index: 1000;
}

.menu-item:hover .submenu {
  display: block;
}

.submenu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.15s ease;
}

.submenu-item:hover {
  background: #f0f7ff;
}

.submenu-item kbd {
  font-size: 11px;
  color: #888;
  background: #f5f5f5;
  padding: 2px 4px;
  border-radius: 2px;
  margin-left: 12px;
}

.submenu-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 8px;
}

.submenu-item.checkbox {
  position: relative;
}

.checkbox-indicator {
  width: 12px;
  height: 12px;
  border: 1px solid #999;
  border-radius: 2px;
  position: relative;
  margin-left: 8px;
}

.submenu-item.checked .checkbox-indicator {
  background: #007acc;
  border-color: #007acc;
}

.submenu-item.checked .checkbox-indicator::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 10px;
  line-height: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Zoom Controls */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-btn {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid #999;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  background: #f0f7ff;
  border-color: #007acc;
}

.zoom-btn svg {
  width: 12px;
  height: 12px;
  fill: #333;
  stroke: #333;
}

.zoom-display {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
}

/* Toolbar */
.fabric-toolbar {
  background: linear-gradient(180deg, #f0f0f0 0%, #e8e8e8 100%);
  border-bottom: 1px solid #c0c0c0;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  user-select: none;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-group {
  display: flex;
  gap: 2px;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 4px;
  padding: 2px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: #e8f4fd;
}

.tool-btn.active {
  background: #007acc;
  color: white;
}

.tool-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: currentColor;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: #bbb;
  margin: 0 4px;
}

/* Color Controls */
.color-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch-group {
  display: flex;
  gap: 4px;
}

.color-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
  transition: background-color 0.15s ease;
}

.color-swatch:hover {
  background: rgba(0, 122, 204, 0.1);
}

.color-preview {
  width: 24px;
  height: 24px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  margin-bottom: 2px;
}

.color-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  font-weight: 500;
}

.color-actions {
  display: flex;
  gap: 2px;
}

.color-btn {
  width: 20px;
  height: 20px;
  background: transparent;
  border: 1px solid #999;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.color-btn:hover {
  background: #f0f7ff;
  border-color: #007acc;
}

.color-btn svg {
  width: 12px;
  height: 12px;
  fill: #333;
  stroke: #333;
}

/* Main Content Area */
.fabric-main-content {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Panels */
.left-panels,
.right-panels {
  width: 280px;
  background: #f8f8f8;
  border-right: 1px solid #c0c0c0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-panels {
  border-right: none;
  border-left: 1px solid #c0c0c0;
}

.panel {
  border-bottom: 1px solid #d0d0d0;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.panel:last-child {
  border-bottom: none;
  flex: 1;
}

.panel-header {
  background: linear-gradient(180deg, #f0f0f0 0%, #e8e8e8 100%);
  border-bottom: 1px solid #d0d0d0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
}

.panel-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-actions {
  display: flex;
  gap: 2px;
}

.panel-btn {
  width: 20px;
  height: 20px;
  background: transparent;
  border: 1px solid #999;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  color: #333;
  transition: all 0.15s ease;
}

.panel-btn:hover {
  background: #e8f4fd;
  border-color: #007acc;
}

.panel-content {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

/* Canvas Area */
.canvas-area {
  flex: 1;
  position: relative;
  background: #e0e0e0;
  overflow: auto;
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.main-canvas {
  background: #fff;
  box-shadow: 0 0 0 1px #999, 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: default;
}

/* Canvas Rulers */
.canvas-rulers {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.ruler-horizontal {
  position: absolute;
  top: 0;
  left: 20px;
  right: 0;
  height: 20px;
  background: #f8f8f8;
  border-bottom: 1px solid #ccc;
}

.ruler-vertical {
  position: absolute;
  top: 20px;
  left: 0;
  bottom: 0;
  width: 20px;
  background: #f8f8f8;
  border-right: 1px solid #ccc;
}

.ruler-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: #f0f0f0;
  border-bottom: 1px solid #ccc;
  border-right: 1px solid #ccc;
}

/* Canvas Grid */
.canvas-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Status Bar */
.fabric-statusbar {
  background: linear-gradient(180deg, #e8e8e8 0%, #d8d8d8 100%);
  border-top: 1px solid #c0c0c0;
  height: 24px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  color: #666;
  user-select: none;
}

.status-section {
  margin-right: 16px;
  padding-right: 16px;
  border-right: 1px solid #bbb;
}

.status-section:last-child {
  border-right: none;
  margin-right: 0;
  padding-right: 0;
}

/* Layers Panel */
.layers-list {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  min-height: 120px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.layer-item:hover {
  background: #f8f8f8;
}

.layer-item.active {
  background: #e8f4fd;
  border-color: #007acc;
}

.layer-item:last-child {
  border-bottom: none;
}

.layer-visibility,
.layer-lock {
  cursor: pointer;
  padding: 2px;
  border-radius: 2px;
  transition: background-color 0.15s ease;
}

.layer-visibility:hover,
.layer-lock:hover {
  background: rgba(0, 122, 204, 0.1);
}

.layer-visibility svg,
.layer-lock svg {
  width: 16px;
  height: 16px;
  fill: #666;
  stroke: #666;
}

.layer-name {
  flex: 1;
  font-size: 12px;
  outline: none;
  background: transparent;
  border: none;
  padding: 2px 4px;
  border-radius: 2px;
}

.layer-name:focus {
  background: #fff;
  border: 1px solid #007acc;
}

/* Assets Panel */
.asset-categories {
  display: flex;
  margin-bottom: 8px;
  background: #f0f0f0;
  border-radius: 3px;
  padding: 2px;
}

.category-tab {
  flex: 1;
  text-align: center;
  padding: 6px 8px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.category-tab:hover {
  background: rgba(0, 122, 204, 0.1);
}

.category-tab.active {
  background: #007acc;
  color: white;
}

.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
}

.asset-item {
  aspect-ratio: 1;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.asset-item:hover {
  border-color: #007acc;
  background: #f8feff;
}

.asset-item svg {
  width: 24px;
  height: 24px;
  fill: #333;
  stroke: #333;
}

/* Properties Panel */
.properties-content {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  padding: 12px;
}

.no-selection {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 20px;
}

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

.property-group:last-child {
  margin-bottom: 0;
}

.property-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.property-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.property-input {
  flex: 1;
  height: 24px;
  padding: 0 6px;
  border: 1px solid #ccc;
  border-radius: 2px;
  font-size: 12px;
}

.property-input:focus {
  outline: none;
  border-color: #007acc;
  box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.property-unit {
  font-size: 10px;
  color: #666;
  min-width: 20px;
}

/* History Panel */
.history-list {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  min-height: 120px;
}

.history-item {
  padding: 6px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.15s ease;
  position: relative;
}

.history-item:hover {
  background: #f8f8f8;
}

.history-item.current {
  background: #e8f4fd;
  border-color: #007acc;
  font-weight: 500;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item.current::before {
  content: '▶';
  position: absolute;
  left: 4px;
  color: #007acc;
  font-size: 10px;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .left-panels,
  .right-panels {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .left-panels,
  .right-panels {
    position: absolute;
    top: 80px;
    bottom: 24px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .right-panels {
    right: 0;
    transform: translateX(100%);
  }
  
  .left-panels.visible,
  .right-panels.visible {
    transform: translateX(0);
  }
  
  .fabric-toolbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding: 8px;
  }
  
  .main-menu {
    display: none;
  }
}