/* AI Designer CSS */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 헤더 */
.app-header {
  height: 60px;
  background: white;
  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);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.app-title {
  font-weight: 600;
  color: #333;
  margin-right: 20px;
}

/* 탭 */
.tabs {
  display: flex;
  gap: 4px;
  background: #f5f5f5;
  padding: 4px;
  border-radius: 8px;
}

.tab-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: white;
  color: #333;
}

.tab-btn.active {
  background: white;
  color: #2196f3;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 툴바 */
.header-center {
  display: flex;
  align-items: center;
}

.toolbar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f5f5f5;
  border-radius: 8px;
}

.tool-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;
}

.tool-btn:hover {
  background: white;
  color: #333;
}

.tool-btn.active {
  background: white;
  color: #2196f3;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 액션 버튼 */
.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.action-btn {
  padding: 8px 16px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn:hover {
  background: #f5f5f5;
}

.action-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.action-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* 메인 컨테이너 */
.app-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 왼쪽 패널 */
.left-panel {
  width: 320px;
  background: white;
  border-right: 1px solid #e0e0e0;
  padding: 20px;
  overflow-y: auto;
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.mode-panel h3 {
  font-size: 18px;
  margin-bottom: 20px;
  color: #333;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2196f3;
}

.generate-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* AI 명령 패널 */
.ai-command-panel {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

.ai-command-panel h4 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #333;
}

.ai-btn {
  width: 100%;
  padding: 10px;
  background: #2196f3;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-btn:hover {
  background: #1976d2;
}

/* 도형 그리드 */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.shape-btn {
  width: 100%;
  height: 40px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.shape-btn:hover {
  background: #f5f5f5;
  border-color: #2196f3;
}

/* 캔버스 영역 */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f7fa;
}

.canvas-container {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.canvas {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100%;
}

.page {
  width: calc(100% - 40px);
  max-width: 1200px;
  height: calc(100vh - 200px);
  min-height: 600px;
  background: white;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  border-radius: 8px;
  position: relative;
  display: none;
  overflow: auto;
  margin: 0 auto;
}

.page.active {
  display: block;
}

/* 페이지 네비게이션 */
.page-nav {
  height: 60px;
  background: white;
  border-top: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.page-btn {
  padding: 8px 16px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover {
  background: #f5f5f5;
}

.page-info {
  font-size: 14px;
  color: #666;
}

/* 오른쪽 패널 */
.right-panel {
  width: 260px;
  background: white;
  border-left: 1px solid #e0e0e0;
  overflow-y: auto;
}

.panel-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.panel-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.panel-content {
  padding: 20px;
}

.empty-state {
  color: #999;
  text-align: center;
  padding: 40px 0;
}

/* 컨테이너 박스 */
.container-box {
  position: absolute;
  background: #ffffff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  cursor: move;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 200px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.container-box:hover {
  border-color: #2196f3;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

.container-box.selected {
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.container-box.multi-selected {
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

.container-box.dragging {
  opacity: 0.8;
  cursor: grabbing !important;
  z-index: 1000;
  /* 드래그 중에는 transition 제거 */
  transition: none !important;
}

/* 컨테이너 콘텐츠 */
.container-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.container-placeholder {
  color: #999;
  font-size: 14px;
  text-align: center;
  user-select: none;
}

.container-text {
  width: 100%;
  min-height: 30px;
  outline: none;
  text-align: center;
}

.container-image {
  width: 100%;
  height: auto;
}

.container-image img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.container-video {
  width: 100%;
  height: auto;
}

.container-video iframe,
.container-video video {
  width: 100%;
  border-radius: 4px;
}

/* 리사이즈 핸들 */
.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; }

/* 컨텍스트 메뉴 */
.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;
}

.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;
}

/* 로딩 오버레이 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #2196f3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay p {
  color: white;
  margin-top: 20px;
  font-size: 16px;
}

/* 애니메이션 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes slideDown {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
}

/* 반응형 */
@media (max-width: 1400px) {
  .left-panel {
    width: 280px;
  }
  .right-panel {
    width: 240px;
  }
}

@media (max-width: 1200px) {
  .page {
    width: 100%;
    margin: 0 20px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .left-panel,
  .right-panel {
    width: 100%;
    height: auto;
  }
}