/* 全体のリセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f7fa;
  color: #333;
}

/* アプリ全体のレイアウト */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-links {
  display: flex;
  gap: 1.5rem;
}

.header-links a {
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.2s;
  border: 1px solid rgba(255,255,255,0.2);
}

.header-links a:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-1px);
}

/* メインコンテンツ */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  gap: 0;
  overflow: hidden;
}

/* フィールドパレット */
.field-palette {
  background: white;
  border-right: 1px solid #e1e5e9;
  padding: 1rem;
  overflow-y: auto;
}

.field-palette h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: #555;
}

.category {
  margin-bottom: 1.5rem;
}

.category h3 {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-item {
  background: #f8f9fa;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
  font-size: 0.85rem;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}

.field-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.field-item:active {
  cursor: grabbing;
}

/* フォームエディター */
.form-editor {
  background: #fafbfc;
  padding: 1rem;
  overflow-y: auto;
}

.editor-header {
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-header h2 {
  font-size: 1.1rem;
  color: #555;
}

.editor-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.validation-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
  color: #666;
}

.validation-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.editor-header .export-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.editor-header .export-btn:hover {
  background: #5a6fd8;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.drop-zone {
  background: white;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  min-height: 500px;
  padding: 2rem;
  transition: all 0.2s;
}

.drop-zone.drag-over {
  border-color: #667eea;
  background: #f0f4ff;
}

.drop-message {
  text-align: center;
  color: #9ca3af;
  font-size: 1rem;
  margin-bottom: 2rem;
}

.preview-form {
  max-width: 600px;
  margin: 0 auto;
}

/* 設定パネル */
.settings-panel {
  background: white;
  border-left: 1px solid #e1e5e9;
  padding: 1rem;
  overflow-y: auto;
}

.settings-panel h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: #555;
}

.settings-content {
  color: #777;
}

.setting-group {
  margin-bottom: 1rem;
}

.setting-group label {
  display: block;
  font-weight: 600;
  color: #555;
  font-size: 14px;
  margin-bottom: 0.5rem;
}

.setting-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e1e5e9;
  border-radius: 4px;
  font-size: 14px;
}

.options-list {
  margin-bottom: 0.5rem;
}

.option-item {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.option-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #e1e5e9;
  border-radius: 4px;
  font-size: 14px;
}

.option-delete {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.add-option {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

/* フォームフィールドのスタイル（sampleから継承） */
.Form-Item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 1.5rem;
  position: relative;
}

.Form-Item.selected {
  outline: 2px solid #667eea;
  outline-offset: 4px;
  border-radius: 8px;
}

.Form-Item-Label {
  font-weight: 600;
  color: #555;
  font-size: 14px;
}

.Form-Item-Input,
.Form-Item-Textarea,
.Form-Item-Select {
  border-radius: 8px;
  border: 2px solid #e1e5e9;
  width: 100%;
  padding: 16px;
  font-size: 16px;
  background-color: #fafbfc;
  transition: all 0.2s;
}

.Form-Item-Input:focus,
.Form-Item-Textarea:focus,
.Form-Item-Select:focus {
  outline: none;
  border-color: #667eea;
  background-color: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.Form-Item-Input:user-invalid {
  border-color: #e74c3c;
  background-color: #fdf2f2;
}

.Form-Item-Input:user-valid {
  border-color: #27ae60;
  background-color: #f8fff8;
}

/* カラーピッカーのスタイル */
.Form-Item-Input[type="color"] {
  width: 60px;
  height: 40px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px;
  background-color: white;
}

.Form-Item-Input[type="color"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.Form-Item-Textarea {
  min-height: 100px;
  resize: vertical;
}

/* ラジオボタン・チェックボックス */
.Form-Item-Choice {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.choice-option input[type="radio"],
.choice-option input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ボタン */
.Form-Item-Button {
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.Form-Item-Button:hover {
  background: #5a6fd8;
}

.Form-Item-Button.reset {
  background: #6c757d;
}

.Form-Item-Button.button {
  background: #28a745;
}

/* フィールド削除ボタン */
.field-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: none;
  z-index: 10;
}

.Form-Item:hover .field-delete,
.Form-Item.selected .field-delete {
  display: block;
}

/* SortableJSのスタイル */
.sortable-ghost {
  opacity: 0.4;
}

.sortable-chosen {
  cursor: grabbing;
}

.sortable-drag {
  opacity: 0.8;
}

.Form-Item {
  cursor: grab;
}

.Form-Item:active {
  cursor: grabbing;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 80%;
  max-width: 800px;
  max-height: 80%;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.modal-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

.modal-body {
  padding: 2rem;
}

.code-tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tab-btn {
  background: #f8f9fa;
  border: 1px solid #e1e5e9;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #667eea;
  color: white;
}

.code-content {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  max-height: 400px;
  overflow-y: auto;
}

.code-content pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  line-height: 1.4;
}

.copy-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.copy-btn:hover {
  background: #218838;
}

/* レスポンシブ */
@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 200px 1fr 250px;
  }
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  
  .field-palette,
  .settings-panel {
    border: none;
    border-bottom: 1px solid #e1e5e9;
  }
}