/* ===== Editor UI for CRUD ===== */

/* PIN login pill (top-right of header) */
.editor-login-pill {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #E0E0E0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 100;
  transition: all 0.2s;
  color: #333;
}
.editor-login-pill:hover { background: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.editor-login-pill.logged-in { background: #2E7D32; color: #fff; border-color: #2E7D32; }

/* Card action buttons (only shown when logged in) */
body.editor-mode .kpi-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}
.kpi-actions {
  display: none;
}
.kpi-action-btn {
  background: #fff;
  border: 1px solid #DDD;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s;
}
.kpi-action-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
.kpi-action-btn.edit:hover { background: #FFF3E0; border-color: #FB8C00; }
.kpi-action-btn.del:hover { background: #FFEBEE; border-color: #E53935; }

/* Add-KPI button in tab footer */
.tab-add-row {
  display: none;
  margin: 16px 0;
  text-align: center;
}
body.editor-mode .tab-add-row { display: block; }
.tab-add-btn {
  background: #2E7D32;
  color: #fff;
  border: 0;
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.3);
  transition: all 0.2s;
}
.tab-add-btn:hover { background: #1B5E20; transform: translateY(-1px); }

/* Modal */
.editor-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.editor-modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 520px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.editor-modal h2 { margin-top: 0; margin-bottom: 16px; color: #2E7D32; font-size: 20px; }

.form-grid { display: grid; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 13px; font-weight: 600; color: #555; }
.form-row input, .form-row select, .form-row textarea {
  border: 1px solid #DDD;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: #2E7D32; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.btn-primary {
  background: #2E7D32; color: #fff; border: 0;
  padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-primary:hover { background: #1B5E20; }
.btn-secondary {
  background: #f5f5f5; color: #333; border: 1px solid #DDD;
  padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-secondary:hover { background: #EBEBEB; }
.btn-danger {
  background: #E53935; color: #fff; border: 0;
  padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-danger:hover { background: #C62828; }

/* Toast */
.editor-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.2s ease-out;
}
.editor-toast.success { background: #2E7D32; }
.editor-toast.error { background: #C62828; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Save banner */
.editor-status-bar {
  display: none;
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #DDD;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
body.editor-mode .editor-status-bar { display: inline-flex; align-items: center; gap: 6px; }
