/* Simple Editor CSS - 깔끔하고 현대적인 디자인 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 헤더 */
.editor-header {
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #333;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border-right: 1px solid #e0e0e0;
}

.tool-group:last-child {
  border-right: none;
}

/* 버튼 스타일 */
.tool-btn,
.action-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
}

.tool-btn:hover,
.action-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.tool-btn.active {
  background: #e3f2fd;
  color: #2196f3;
}

.action-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.action-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.action-btn.success {
  background: #4caf50;
  color: white;
}

.action-btn.success:hover {
  background: #45a049;
}

/* 메인 에디터 영역 */
.editor-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* 캔버스 */
.canvas-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: #f5f5f5;
  position: relative;
}

/* 드래그 중일 때 전체 페이지 스타일 */
body.dragging {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

body.dragging * {
  cursor: grabbing !important;
}

.canvas {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.page {
  width: 1200px;
  min-height: 800px;
  background: white;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

/* 편집 요소 */
.element {
  position: absolute;
  cursor: move;
  user-select: none;
  transition: box-shadow 0.2s;
}

.element:hover {
  box-shadow: 0 0 0 2px #2196f3;
}

.element.selected {
  box-shadow: 0 0 0 2px #2196f3;
}

.element.dragging {
  opacity: 0.7;
  cursor: grabbing !important;
  pointer-events: none;
  z-index: 1000;
}

/* 텍스트 요소 */
.element-text {
  padding: 12px;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: transparent;
  min-width: 100px;
  min-height: 40px;
}

.element-text[contenteditable="true"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px #2196f3;
}

/* 이미지 요소 */
.element-image {
  overflow: hidden;
  border-radius: 4px;
}

.element-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 박스 요소 */
.element-box {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  min-width: 100px;
  min-height: 100px;
  transition: all 0.3s ease;
}

/* 컨테이너 박스 */
.element-container {
  overflow: auto;
}

.element-container.drag-over {
  background: #e3f2fd !important;
  border: 2px dashed #2196f3 !important;
  transform: scale(1.02);
}

.container-placeholder {
  pointer-events: none;
  user-select: none;
}

.container-text {
  min-height: 30px;
  cursor: text;
}

.container-text:focus {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
}

.container-image {
  margin: 10px 0;
}

/* 리사이즈 핸들 */
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #2196f3;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

/* 속성 패널 */
.property-panel {
  position: fixed;
  right: 20px;
  top: 80px;
  width: 300px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 100;
}

.panel-header {
  padding: 15px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.close-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  border-radius: 4px;
}

.close-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.panel-content {
  padding: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #2196f3;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

/* 모달 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.modal-body {
  padding: 20px;
}

/* AI 액션 버튼 */
.ai-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  flex: 1;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
  flex: 1;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

/* 템플릿 그리드 */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.template-item {
  cursor: pointer;
  transition: transform 0.2s;
}

.template-item:hover {
  transform: scale(1.05);
}

.template-preview {
  height: 120px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 로딩 상태 */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '⏳ 처리 중...';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 20px 40px;
  border-radius: 8px;
  font-size: 16px;
  z-index: 2000;
}

/* 컨텍스트 메뉴 */
.context-menu {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 8px 0;
  min-width: 200px;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
  font-size: 14px;
  color: #333;
}

.context-menu-item:hover {
  background: #f0f0f0;
}

.context-menu-item span {
  width: 20px;
  text-align: center;
}

.context-menu-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

/* 반응형 */
@media (max-width: 768px) {
  .toolbar {
    flex-wrap: wrap;
  }
  
  .page {
    width: 100%;
    margin: 20px;
  }
  
  .property-panel {
    width: calc(100% - 40px);
    left: 20px;
    right: 20px;
  }
  
  .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}