/* Intelligence Page Editor — CSS for inline markdown editor + AI review panel */

/* ========== EDITOR CONTAINER ========== */
#editor-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 0;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border-bright);
  overflow-y: auto;
  z-index: 1000;
  transition: width 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

#editor-panel.open {
  width: 80vw;
  max-width: 1200px;
}

#editor-panel.fullscreen {
  width: 100vw;
  max-width: 100%;
  top: 0;
  left: 0;
  right: auto;
}

.editor-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-bright);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: var(--surface);
}

.editor-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.editor-header-buttons {
  display: flex;
  gap: 8px;
}

/* ========== EDITOR MODES ========== */
.editor-mode {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.editor-mode.active {
  display: flex;
  flex-direction: column;
}

/* Draft mode - split editor/preview */
#editor-mode-draft {
  flex-direction: row;
  gap: 16px;
}

.editor-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.editor-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

/* ========== EDITOR TEXTAREA ========== */
.editor-textarea {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px;
  border-radius: 4px;
  resize: none;
  transition: border-color 0.2s;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0, 200, 200, 0.1);
}

/* ========== MARKDOWN PREVIEW ========== */
.editor-preview {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
}

.editor-preview h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 16px 0 8px 0;
  color: var(--text);
}

.editor-preview h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 12px 0 6px 0;
  color: var(--text-dim);
}

.editor-preview h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 10px 0 4px 0;
  color: var(--text-faint);
}

.editor-preview p {
  margin: 8px 0;
}

.editor-preview code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 4px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
}

.editor-preview pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 8px 0;
}

.editor-preview pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-dim);
}

.editor-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.editor-preview th {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  font-weight: 600;
}

.editor-preview td {
  border: 1px solid var(--border);
  padding: 8px;
}

.editor-preview ul, .editor-preview ol {
  margin-left: 20px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.editor-preview li {
  margin: 4px 0;
}

/* ========== STATUS INDICATOR ========== */
.editor-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  padding: 8px 16px;
  background: var(--bg2);
}

.editor-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: pulse-slow 2s infinite;
}

.editor-status-dot.saved {
  background: var(--green);
  animation: none;
}

@keyframes pulse-slow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ========== AI REVIEW PANEL ========== */
#ai-review-panel {
  display: none;
  flex-direction: column;
  overflow-y: auto;
  gap: 12px;
}

#ai-review-panel.active {
  display: flex;
}

.ai-review-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
}

.ai-review-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--teal);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-review-content {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ai-review-content ul, .ai-review-content ol {
  margin-left: 20px;
  margin-top: 4px;
}

.ai-review-content li {
  margin: 2px 0;
}

.ai-review-risk {
  background: rgba(232, 25, 46, 0.1);
  border-left: 3px solid var(--red);
  padding: 8px 12px;
  border-radius: 2px;
  margin: 4px 0;
}

.ai-review-recommendation {
  background: rgba(124, 255, 178, 0.05);
  border-left: 3px solid var(--green);
  padding: 8px 12px;
  border-radius: 2px;
  margin: 4px 0;
}

/* ========== WORKFLOW BUTTONS ========== */
.editor-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px;
  border-top: 1px solid var(--border-bright);
  background: var(--surface);
  flex-shrink: 0;
}

.editor-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-bright);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.editor-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.editor-btn.primary {
  background: var(--teal);
  color: var(--bg);
  border-color: var(--teal);
}

.editor-btn.primary:hover {
  background: #00d8d8;
  border-color: #00d8d8;
}

.editor-btn.danger {
  color: var(--red);
  border-color: var(--red);
}

.editor-btn.danger:hover {
  background: rgba(232, 25, 46, 0.1);
}

.editor-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border);
}

/* ========== MODAL DIALOGS ========== */
.editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  display: none;
}

.editor-modal.open {
  display: flex;
}

.editor-modal-content {
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

.editor-modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.editor-modal-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.editor-modal-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 3px;
  margin-bottom: 16px;
}

.editor-modal-input:focus {
  outline: none;
  border-color: var(--teal);
}

.editor-modal-warning {
  background: rgba(249, 208, 48, 0.1);
  border-left: 3px solid var(--gold);
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 16px;
}

.editor-modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ========== EDIT BUTTON (on page) ========== */
#edit-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--teal);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  z-index: 999;
  transition: all 0.2s;
}

#edit-button:hover {
  background: #00d8d8;
  transform: scale(1.05);
}

/* ========== LOADING STATE ========== */
.editor-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== FILE IMPORT / DROPZONE ========== */
.editor-dropzone {
  border: 1px dashed var(--border-bright);
  background: var(--bg2);
  border-radius: 4px;
  padding: 14px;
  margin-bottom: 12px;
  transition: border-color 0.2s, background 0.2s;
}

.editor-dropzone.drag-active {
  border-color: var(--teal);
  background: rgba(0, 200, 200, 0.08);
}

.editor-dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.editor-dropzone-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.editor-import-status {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--blue-light);
  background: rgba(95, 168, 232, 0.08);
  color: var(--text-dim);
  font-size: 12px;
}

.editor-inline-toast {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 12px;
}

.editor-inline-toast.info {
  background: rgba(95, 168, 232, 0.08);
  border-left: 3px solid var(--blue-light);
  color: var(--text-dim);
}

.editor-inline-toast.success {
  background: rgba(124, 255, 178, 0.08);
  border-left: 3px solid var(--green);
  color: var(--text-dim);
}

.editor-inline-toast.error {
  background: rgba(232, 25, 46, 0.08);
  border-left: 3px solid var(--red);
  color: var(--text-dim);
}

.import-choice-buttons {
  flex-wrap: wrap;
  justify-content: flex-start;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  #editor-panel.open {
    width: 100vw;
  }

  #editor-mode-draft {
    flex-direction: column;
  }

  .editor-modal-content {
    max-width: 90%;
  }
}
