/* 코딩 에디터 전용 스타일 */
#coding-editor-app {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  overflow: hidden;
}

/* 전체화면 모드에서 body 스크롤 방지 */
body.editor-fullscreen-active,
body.preview-fullscreen-active {
  overflow: hidden !important;
  height: 100vh;
  position: fixed;
  width: 100%;
}

.coding-toolbar {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 코드박스 */
.code-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}

.code-box-header ul {
  list-style: none;
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.code-box-header li {
  color: #666;
  font-size: 14px;
}

.cbh-left, .cbh-right {
  display: flex;
  gap: 10px;
}

.cbh-center {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.cbh-center button {
  padding: 4px 10px;
  background: #f5f5f5;
  color: #333;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.cbh-center button:hover {
  background: #ccc;
}

/* 탭 스타일 */
.editor-tabs {
  display: flex;
  gap: 5px;
  background: #f5f5f5;
  padding: 5px 10px 0;
  border-bottom: 1px solid #e0e0e0;
}

.editor-tabs button {
  position: relative;
  padding: 8px 20px;
  background: #ffffff;
  color: #666;
  border: 1px solid #e0e0e0;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: 14px;
  border-bottom: none;
}

.editor-tabs button:hover {
  background: #f8f8f8;
  color: #333;
}

.editor-tabs button.active {
  color: #007aff;
}
.editor-tabs button.active::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #007aff;
}

.code-box-con-lr {
  display: flex;
  height: 100%;
  overflow: hidden;
  border-bottom: 1px solid #e0e0e0;
}

/* 에디터 패널 */
.code-box-con {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel {
  flex: 0 0 50%;
  display: flex;
  flex-direction: column;
  min-width: 400px;
  position: relative;
}

.editor-panel.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
  background: white;
}

.editor-panel .fullscreen-toggle-btn {
  top: 5px;
  right: 8px;
  z-index: 100;
  width: 28px;
  height: 28px;
}

.editor-panel.fullscreen .fullscreen-toggle-btn {
  top: 4px;
  right: 10px;
  z-index: 10000;
  width: 32px;
  height: 32px;
}

.editor-panel.fullscreen .fullscreen-toggle-btn img {
  width: 20px;
  height: 20px;
}

/* 에디터 복사 버튼 */
.editor-copy-btn {
  position: absolute;
  top: 5px;
  right: 42px;
  z-index: 100;
  width: 28px;
  height: 28px;
  padding: 4px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
  color: #666;
}

.editor-copy-btn svg {
  width: 18px;
  height: 18px;
}

.editor-copy-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  color: #333;
}

.editor-panel.fullscreen .editor-copy-btn {
  top: 4px;
  right: 48px;
  z-index: 10000;
  width: 32px;
  height: 32px;
  padding: 5px;
}

.editor-panel.fullscreen .editor-copy-btn svg {
  width: 20px;
  height: 20px;
}

.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.editor-container {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-wrapper {
  width: 100%;
  height: 100%;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* CodeMirror 6 스타일 */
.cm-editor {
  height: 100%;
  font-size: 14px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: #ffffff !important;
}

.cm-editor .cm-gutters {
  background: #f8f8f8 !important;
  border-right: 1px solid #e0e0e0 !important;
}

/* CodeMirror 하이라이팅 색상 보장 */
.cm-editor .cm-content {
  color: #000000;
}

/* 전체화면 모드에서도 하이라이팅 색상 유지 */
.editor-panel.fullscreen .cm-editor {
  background: #ffffff;
}

/* CodeMirror 텍스트 선택 스타일 - 모든 방식 커버 */

/* 1. 선택 레이어 (CodeMirror 6의 주요 방식) */
.cm-selectionLayer .cm-selectionBackground {
  background: rgba(179, 215, 255, 0.5) !important;
}

.cm-focused .cm-selectionLayer .cm-selectionBackground {
  background: rgba(0, 102, 204, 0.4) !important;
}

/* 2. 브라우저 기본 선택 스타일 */
.cm-content ::selection {
  background: rgba(179, 215, 255, 0.99) !important;
  color: inherit !important;
}

.cm-content ::-moz-selection {
  background: rgba(179, 215, 255, 0.99) !important;
  color: inherit !important;
}

/* 3. 라인별 선택 */
.cm-line ::selection {
  background: rgba(179, 215, 255, 0.99) !important;
  color: inherit !important;
}

.cm-line ::-moz-selection {
  background: rgba(179, 215, 255, 0.99) !important;
  color: inherit !important;
}

/* 4. 최상위 선택 (fallback) */
.cm-editor ::selection {
  background: rgba(179, 215, 255, 0.99) !important;
  color: inherit !important;
}

.cm-editor ::-moz-selection {
  background: rgba(179, 215, 255, 0.99) !important;
  color: inherit !important;
}

/* 같은 단어 매칭 */
.cm-selectionMatch {
  background-color: rgba(255, 235, 59, 0.5) !important;
}

/* 커서 스타일 */
.cm-cursor,
.cm-cursor-primary {
  border-left: 2px solid #000000 !important;
  margin-left: -1px;
  animation: cm-blink 1.2s step-end infinite;
}

@keyframes cm-blink {
  0%, 50% { opacity: 1; }
  50.1%, 100% { opacity: 0; }
}

/* 리사이저 */
.resizer {
  width: 4px;
  background-color: #e0e0e0;
  cursor: col-resize;
  user-select: none;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.resizer:hover,
.resizer:active {
  background-color: #007aff;
}

/* 리사이저 드래그 오버레이 */
.resize-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  cursor: col-resize;
  display: none;
}

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

/* 미리보기 */
.code-box-preview-con {
  width: 100%;
  height: 100%;
  background: white;
  overflow: hidden;
  position: relative;
}

.fullscreen-toggle-btn {
  position: absolute;
  top: 5px;
  right: 10px;
  z-index: 100;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
}

.fullscreen-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fullscreen-toggle-btn img {
  width: 20px;
  height: 20px;
}

#preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.code-box-preview-con.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
  background: white;
}

.code-box-preview-con.fullscreen .fullscreen-toggle-btn {
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: transparent;
}

.code-box-preview-con.fullscreen .fullscreen-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 입력 컨테이너 */
.prompt-container {
  padding: 6px 6px 6px 2px;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.prompt-container textarea {
  flex: 1;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #ccc;
  outline: none;
  resize: none;
  font-size: 14px;
  box-sizing: border-box;
  height: 70px;
  min-height: 70px;
  max-height: 180px;
  font-family: inherit;
  overflow-y: auto;
  line-height: 1.5;
}

.prompt-container textarea:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.prompt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.voice-mic-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70px;
  min-width: 60px;
}

.voice-mic-wrapper .voice-mic-container {
  width: 56px;
  height: 56px;
}

.voice-mic-wrapper .voice-mic-container button {
  width: 56px;
  height: 56px;
}

.prompt-actions .send-btn {
  min-width: 96px;
}

.prompt-actions .send-btn:disabled {
  cursor: not-allowed;
}

.send-btn {
  padding: 0 10px;
  height: 70px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: normal;
  transition: background 0.2s, opacity 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 80px;
}

.send-btn:hover {
  background: #005bbd;
}

.send-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
  opacity: 0.7;
}

.send-btn .loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.send-btn .status-text {
  font-size: 13px;
  white-space: nowrap;
}

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

/* 히스토리 사이드바 */
.history-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  width: 350px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -2px 0 10px rgba(0,0,0,0.1);
  overflow-y: auto;
  z-index: 10000;
  padding: 20px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  border-left: 1px solid #e0e0e0;
}

.history-sidebar.show {
  transform: translateX(0);
}

.history-sidebar h3 {
  margin-bottom: 20px;
  font-size: 18px;
  color: #333;
  border-bottom: 2px solid #007aff;
  padding-bottom: 10px;
}

.history-sidebar ul {
  list-style: none;
  padding: 0;
}

.history-sidebar li {
  padding: 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.2s;
}

.history-sidebar li:hover {
  background: #f5f5f5;
}

.history-time {
  font-size: 12px;
  color: #888;
  margin-bottom: 5px;
}

.history-prompt {
  font-size: 14px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 24px;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.history-close:hover {
  background: #f0f0f0;
  color: #333;
}

/* 알림 토스트 */
.toast {
  position: fixed;
  bottom: 150px;
  right: 20px;
  background: #333;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10001;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.success {
  background: #28a745;
}

.toast.error {
  background: #dc3545;
}

/* 푸터 */
.bt {
  padding: 5px;
  text-align: center;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  font-size: 12px;
  color: #666;
}

.bt a {
  font-size:14px;
  color: #666;
  text-decoration: none;
  transition: color 0.2s;
}

.bt a:hover {
  color: #0066cc;
}


